Hi,
We are using Alfresco 3.3 with websphere AS 7.0.0.0. When the document is uploaded,the content of the document gets corrupted for word,excel and editable pdf files.Number of bytes written and read while downloading are same.When we download these files the files are corrupted and do not open.
Below is the code for uploading document:
<java>
String docChildRef = Constants.createQNameString(
NMSPCE_KYC_CNTNT_MDL, TYPE_KYC_DOCUMENT + timeStamp);
ParentReference docParent = new ParentReference(getStoreRef(),
null, clientFolder, Constants.ASSOC_CONTAINS,
docChildRef);
String name = documentId + CommonConstants.TILDE + docTitle
+ CommonConstants.TILDE + versionId
+ CommonConstants.TILDE + fileName; /
NamedValue nameValue = Utils.createNamedValue(
Constants.PROP_NAME, name);
NamedValue[] namePropsArr = new NamedValue[] { nameValue };
// Construct CML statement to create document content node
String contentType = Constants.createQNameString(
NMSPCE_KYC_CNTNT_MDL, TYPE_KYC_DOCUMENT);
CMLCreate createDoc = new CMLCreate("ref2", // id
docParent, null, null, null, contentType, namePropsArr);
// Add custom properties to the folder using CMLAddAspect
String docAspect = Constants.createQNameString(
NMSPCE_KYC_CNTNT_MDL, ASPECT_KYC_DOCUMENT);
NamedValue documentIdValue=null;
if(null!=documentId){
documentIdValue = Utils.createNamedValue(Constants
.createQNameString(NMSPCE_KYC_CNTNT_MDL,
PROP_DOCUMENT_ID), documentId.toString());
}
NamedValue uploadedByValue = Utils.createNamedValue(Constants
.createQNameString(NMSPCE_KYC_CNTNT_MDL,
PROP_UPLOADED_BY), uploadedBy);
NamedValue versionIdValue = Utils.createNamedValue(Constants
.createQNameString(NMSPCE_KYC_CNTNT_MDL,
PROP_VERSION_ID), versionId.toString());
NamedValue clientUuidValue = Utils.createNamedValue(
Constants.createQNameString(NMSPCE_KYC_CNTNT_MDL,
PROP_CLIENT_ID), clientUuid.toString());
NamedValue[] contentPropsArr = new NamedValue[] { nameValue,
documentIdValue, uploadedByValue, versionIdValue,
clientUuidValue };
CMLAddAspect documentAspect = new CMLAddAspect(docAspect,
contentPropsArr, null, "ref2"); // the "ref2" used here
// must be equal to the
// id parameter in
// CMLCreate
// Add title and description properties to the folder using
// CMLAddAspect
NamedValue documentTitle = Utils.createNamedValue(
Constants.PROP_TITLE, docTitle);
NamedValue documentDesciption = Utils.createNamedValue(
Constants.PROP_DESCRIPTION, docDescription);
NamedValue[] titledPropsArr = new NamedValue[] { documentTitle,
documentDesciption };
CMLAddAspect titleAspect = new CMLAddAspect(
Constants.ASPECT_TITLED, titledPropsArr, null, "ref2");
// Construct CML Block
CML cml = new CML();
cml.setCreate(new CMLCreate[] { createDoc });
cml.setAddAspect(new CMLAddAspect[] { documentAspect,
titleAspect });
try {
// Execute CML Block
UpdateResult[] updatedResultArr = getRepositoryService()
.update(cml);
Reference docRef = updatedResultArr[0].getDestination();
// Write the contents into repository using contentService
byte[] fileCntntByteArr = documentVO.getFileContent();
System.out.println("bytes to be written:"+ fileCntntByteArr.length);
if (fileCntntByteArr.length != 0) {
ContentFormat contentFormat = new ContentFormat(
mimeType, CONTNT_ENCODNG_FRMT);
Content content = getContentService().write(docRef,
Constants.PROP_CONTENT, fileCntntByteArr,
contentFormat);
<java>
Please help me in this case.