02-27-2009 01:06 AM
02-27-2009 03:14 AM
03-18-2009 09:26 AM
UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml);
Reference content = result[0].getDestination();
byte[] bytes = ContentUtils.convertToByteArray(stream);
ContentFormat contentFormat = new ContentFormat(tipo, "UTF-8");
WebServiceFactory.getContentService().write(content, Constants.PROP_CONTENT, bytes, contentFormat);
System.out.println("DONE");
uuid=content.getUuid();
03-18-2009 12:32 PM
You need to tweak your code to upload the content direct to the server over http
03-19-2009 10:37 AM
04-15-2009 11:51 AM
04-16-2009 04:01 AM
I also read somewhere that Axis is only able to handle 32mb documents in soap requests. Are you familiar with such a boundary?
04-16-2009 04:23 AM
07-01-2009 05:21 AM
11-02-2009 10:51 PM
private String writeContentInSpace(String contentName, String title,
String description, String spaceName, String mimeType,
String encoding, byte[] content, String author, String isbn,
int pageCount, String classification, String clientName,
String clientMail, String imageId) {
try {
// Start the session
AuthenticationUtils.startSession(userName, password);
} catch (AuthenticationFault fault) {
fault.printStackTrace();
return "Exception occured";
}
try {
// Searching for the space UUID
// Get a reference to the repository web service
RepositoryServiceSoapBindingStub repositoryService;
repositoryService = WebServiceFactory.getRepositoryService();
// Get a reference to the space we have named
Store storeRef = new Store(Constants.WORKSPACE_STORE, "SpacesStore");
Node[] nodes = null;
Reference reference = null;
Predicate predicate = null;
try {
reference = new Reference(storeRef, null,
"/app:company_home/cm:" + spaceName);
predicate = new Predicate(new Reference[] { reference }, null,
null);
nodes = repositoryService.get(predicate);
} catch (Exception ex) {
System.out.println("Exception occured " + ex.getMessage());
ex.printStackTrace();
}
// Searching for the UUID out of the result
String spaceUUID = "";
if (nodes[0] != null) {
NamedValue[] properties = nodes[0].getProperties();
for (int j = 0; j < properties.length; j++) {
NamedValue nv = properties[j];
if ("{http://www.alfresco.org/model/content/1.0}name"
.equals(nv.getName())
&& nv.getValue().equals(spaceName)) {
System.out.println("In Space : " + nv.getValue());
}
if ("{http://www.alfresco.org/model/system/1.0}node-uuid"
.equals(nv.getName())) {
System.out.println("Space UUID: " + nv.getValue());
spaceUUID = nv.getValue();
}
}
}
// Create a reference to the parent where we want to insert content
Reference referenceWrite = new Reference(storeRef, spaceUUID, null);
ParentReference parentReference = new ParentReference(
referenceWrite.getStore(), referenceWrite.getUuid(), null,
Constants.ASSOC_CONTAINS, Constants.ASSOC_CONTAINS);
// Create content
String page_count_str = Integer.toString(pageCount);
NamedValue[] newProperties = new NamedValue[] {
Utils.createNamedValue(Constants.PROP_NAME, contentName),
Utils.createNamedValue(Constants.PROP_DESCRIPTION,
description),
Utils.createNamedValue(Constants.PROP_TITLE, title),
Utils.createNamedValue(Constants.PROP_AUTHOR, author),
Utils.createNamedValue(Constants.PROP_ISBN, isbn),
Utils.createNamedValue(Constants.PROP_CLIENT_MAIL,
clientMail),
Utils.createNamedValue(Constants.PROP_CLIENT_NAME,
clientName),
Utils.createNamedValue(Constants.PROP_PAGE_COUNT,
page_count_str),
Utils.createNamedValue(Constants.PROP_CLASSIFICATION,
classification),
/* Utils.createNamedValue("IMAGE_ID", imageId), */
};
CMLCreate create = new CMLCreate("1", parentReference, null, null,
null, Constants.TYPE_CONTENT, newProperties);
CMLAddAspect addAspect = new CMLAddAspect();
addAspect.setAspect(Constants.ASPECT_VERSIONABLE);
addAspect.setProperty(newProperties);
addAspect.setWhere(new Predicate(
new Reference[] { referenceWrite }, null, null));
addAspect.setWhere_id("1");
CML cml = new CML();
cml.setCreate(new CMLCreate[] { create });
cml.setAddAspect(new CMLAddAspect[] { addAspect });
// update
UpdateResult[] results;
results = WebServiceFactory.getRepositoryService().update(cml);
// Set content
ContentFormat format = new ContentFormat(mimeType.toString(),
encoding);
Content newContent;
newContent = WebServiceFactory.getContentService().write(
results[0].getDestination(), Constants.PROP_CONTENT,
content, format);
// System.out.println("UUID of uploaded content : " +
// newContent.getNode().getUuid());
System.out.println("File Uploaded.");
// versioning(storeRef);
return newContent.getNode().getUuid();
} catch (Exception e) {
// e.printStackTrace();
return "Exception occured";
} finally {
// End the session
AuthenticationUtils.endSession();
}
}
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.