01-06-2011 05:50 AM
ParentReference parent = connecttoAlfUtils.ReferenceToParent(parentref);
parent.setChildName(Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, connecttoAlfUtils.normilizeNodeName(documentProperties.getFileName())));
NamedValue[] properties = new NamedValue[] { Utils.createNamedValue(Constants.PROP_NAME, documentProperties.getFileName()),
// I put content-type static her to test if it works but it does not
Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}content-type", "application/msword"),
Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}creator", documentProperties.getUserName()),
Utils.createNamedValue("{http://www.alfresco.org/model/content/1.0}description", documentProperties.getFileDesc())};
CMLCreate create = new CMLCreate("1", parent, null, null, null, Constants.TYPE_CONTENT, properties);
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
// Execute the CML create statement
UpdateResult[] results = null;
try {
System.out.println("Creating the document " + documentProperties.getFileName());
results = connecttoAlfUtils.getRepositoryService().update(cml);
document = results[0].getDestination();
} catch (Exception e) {
System.err.println("Can not create the document.");
throw e;
}
// Set the content
ContentFormat format = new ContentFormat(Constants.MIMETYPE_TEXT_PLAIN, "UTF-8");
try {
System.out.println("Setting the content of the document");
connecttoAlfUtils.getContentService().write(document, Constants.PROP_CONTENT, documentProperties.getContent(), format);
isSavedInAlfresco = true;
} catch (Exception e2) {
System.err.println("Can not set the content of the document.");
throw e2;
}
01-10-2011 04:07 AM
CMLCreate create = new CMLCreate("1", parent, null, Constants.ASSOC_CONTAINS, null, Constants.TYPE_CONTENT, properties);
getContentService().write(reference, Constants.PROP_CONTENT, content, null);
01-10-2011 04:43 AM
public void fileUpload(ValueChangeEvent event) throws IOException {
UploadedFile file = (UploadedFile) event.getNewValue();
FacesContext context = FacesContext.getCurrentInstance();
InputStream stream = file.getInputStream();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
int next = stream.read();
while (next > -1) {
bos.write(next);
next = stream.read();
}
bos.flush();
byte[] buffer = bos.toByteArray();
documentProperties.setContent() = buffer ;
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.