Hello everyone,
I'm facing an error when I try to add an image file using the following code:
private AlfrescoDocument addDocument(File fileToUpload, Folder
parentFolder, Map<String, Object> properties) {
String documentName = "myDoc";
ContentStreamImpl contentStream = new ContentStreamImpl();
String fileMimeType = new
MimetypesFileTypeMap().getContentType(fileToUpload);
try {
FileInputStream fileToUploadStream = new
FileInputStream(fileToUpload);
contentStream = new ContentStreamImpl(documentName,
BigInteger.valueOf(fileToUpload.getTotalSpace()), fileMimeType,
fileToUploadStream);
} catch (FileNotFoundException e) {
logger.error(e.getCause());
e.printStackTrace();
}
return (AlfrescoDocument)
parentFolder.createDocument(properties, contentStream, VersioningState.MAJOR);
}
Here's the exception:
ERROR [main] (CmisAtomImporter.java:87) -
java.lang.ArrayIndexOutOfBoundsException
org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException:
Cannot access
http://localhost:8080/alfresco/service/cmis/s/workspace:SpacesStore/i/94d37493-d2ab-4e9d-b803-a8497622d39f/children?versioningState=major:
null
at
org.apache.chemistry.opencmis.client.bindings.spi.atompub.HttpUtils.invoke(HttpUtils.java:149)
at
org.apache.chemistry.opencmis.client.bindings.spi.atompub.HttpUtils.invokePOST(HttpUtils.java:64)
at
org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:493)
at
org.apache.chemistry.opencmis.client.bindings.spi.atompub.ObjectServiceImpl.createDocument(ObjectServiceImpl.java:109)
at
org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(SessionImpl.java:612)
at
org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:96)
at
org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:410)
at
com.savoirfairelinux.repository.importer.cmis.CmisAtomImporter.addDocument(CmisAtomImporter.java:100)
at
com.savoirfairelinux.repository.importer.cmis.CmisAtomImporter.doImport(CmisAtomImporter.java:70)
at
com.savoirfairelinux.repository.client.RepositoryImporter.run(RepositoryImporter.java:27)
at com.savoirfairelinux.repository.client.Main.main(Main.java:21)
And here's the alfresco log:
org.springframework.extensions.webscripts.WebScriptException: 02160083
Wrapped Exception (with status template): 02160236 Failed to execute script
'classpath*:alfresco/templates/webscripts/org/alfresco/cmis/children.post.atom.js':
02160235 com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal character
(NULL, unicode 0) encountered: not valid in any content at [row,col
{unknown-source}]: [1,2093905]
...
Caused by: org.alfresco.scripts.ScriptException: 02160236 Failed to
execute script
'classpath*:alfresco/templates/webscripts/org/alfresco/cmis/children.post.atom.js':
02160235 com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal character
(NULL, unicode 0) encountered: not valid in any content at [row,col
{unknown-source}]: [1,2093905]
...
It seems an encoding problem and it only happens with a few files, I've
searched the problem and tried to change the encoding but the problem persists,
do you have any tip?
Thank you.