use of org.apache.chemistry.opencmis.commons.data.PropertyData in project iaf by ibissource.
the class IbisObjectService method createFolder.
@Override
public String createFolder(String repositoryId, Properties properties, String folderId, List<String> policies, Acl addAces, Acl removeAces, ExtensionsData extension) {
if (!eventDispatcher.contains(CmisEvent.CREATE_FOLDER)) {
return objectService.createFolder(repositoryId, properties, folderId, policies, addAces, removeAces, extension);
} else {
XmlBuilder cmisXml = new XmlBuilder("cmis");
cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
cmisXml.addSubElement(buildXml("folderId", folderId));
cmisXml.addSubElement(buildXml("policies", policies));
XmlBuilder propertiesXml = new XmlBuilder("properties");
for (Iterator<PropertyData<?>> it = properties.getPropertyList().iterator(); it.hasNext(); ) {
propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
}
cmisXml.addSubElement(propertiesXml);
Element result = eventDispatcher.trigger(CmisEvent.CREATE_FOLDER, cmisXml.toXML(), callContext);
return XmlUtils.getChildTagAsString(result, "id");
}
}
use of org.apache.chemistry.opencmis.commons.data.PropertyData in project iaf by ibissource.
the class IbisObjectService method updateProperties.
@Override
public void updateProperties(String repositoryId, Holder<String> objectId, Holder<String> changeToken, Properties properties, ExtensionsData extension) {
if (!eventDispatcher.contains(CmisEvent.UPDATE_PROPERTIES)) {
objectService.updateProperties(repositoryId, objectId, changeToken, properties, extension);
} else {
XmlBuilder cmisXml = new XmlBuilder("cmis");
cmisXml.addSubElement(buildXml("repositoryId", repositoryId));
if (objectId != null)
cmisXml.addSubElement(buildXml("objectId", objectId.getValue()));
if (changeToken != null)
cmisXml.addSubElement(buildXml("changeToken", changeToken.getValue()));
XmlBuilder propertiesXml = new XmlBuilder("properties");
for (Iterator<PropertyData<?>> it = properties.getPropertyList().iterator(); it.hasNext(); ) {
propertiesXml.addSubElement(CmisUtils.getPropertyXml(it.next()));
}
cmisXml.addSubElement(propertiesXml);
eventDispatcher.trigger(CmisEvent.UPDATE_PROPERTIES, cmisXml.toXML(), callContext);
}
}
use of org.apache.chemistry.opencmis.commons.data.PropertyData in project alfresco-remote-api by Alfresco.
the class FavouriteFolder method getFolder.
// public Folder(String id, String guid, Map<String, Serializable> properties)
// {
// super(id, guid, properties);
// }
public static FavouriteFolder getFolder(String id, String guid, Properties props) {
FavouriteFolder folder = new FavouriteFolder(id, guid);
Map<String, PropertyData<?>> properties = props.getProperties();
folder.setName((String) properties.get(PropertyIds.NAME).getFirstValue());
folder.setTitle((String) properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue());
folder.setCreatedBy((String) properties.get(PropertyIds.CREATED_BY).getFirstValue());
folder.setModifiedBy((String) properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue());
GregorianCalendar modifiedAt = (GregorianCalendar) properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
folder.setModifiedAt(modifiedAt.getTime());
GregorianCalendar createdAt = (GregorianCalendar) properties.get(PropertyIds.CREATION_DATE).getFirstValue();
folder.setCreatedAt(createdAt.getTime());
// document.setDescription((String)props.get(PropertyIds.DE).getFirstValue());
return folder;
}
use of org.apache.chemistry.opencmis.commons.data.PropertyData in project alfresco-remote-api by Alfresco.
the class FavouriteDocument method getDocument.
// public Document(String id, String guid, Map<String, Serializable> properties)
// {
// super(id, guid, properties);
// }
public static FavouriteDocument getDocument(String id, String guid, Properties props) {
FavouriteDocument document = new FavouriteDocument(id, guid);
Map<String, PropertyData<?>> properties = props.getProperties();
document.setName((String) properties.get(PropertyIds.NAME).getFirstValue());
document.setTitle((String) properties.get(ContentModel.PROP_TITLE.toString()).getFirstValue());
document.setCreatedBy((String) properties.get(PropertyIds.CREATED_BY).getFirstValue());
document.setModifiedBy((String) properties.get(PropertyIds.LAST_MODIFIED_BY).getFirstValue());
GregorianCalendar modifiedAt = (GregorianCalendar) properties.get(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue();
document.setModifiedAt(modifiedAt.getTime());
GregorianCalendar createdAt = (GregorianCalendar) properties.get(PropertyIds.CREATION_DATE).getFirstValue();
document.setCreatedAt(createdAt.getTime());
// document.setDescription((String)props.get(PropertyIds.DE).getFirstValue());
document.setMimeType((String) properties.get(PropertyIds.CONTENT_STREAM_MIME_TYPE).getFirstValue());
document.setSizeInBytes((BigInteger) properties.get(PropertyIds.CONTENT_STREAM_LENGTH).getFirstValue());
document.setVersionLabel((String) properties.get(PropertyIds.VERSION_LABEL).getFirstValue());
return document;
}
use of org.apache.chemistry.opencmis.commons.data.PropertyData in project alfresco-repository by Alfresco.
the class CMISTest method mnt10548test.
@Category(RedundantTests.class)
@Test
public void mnt10548test() throws Exception {
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
final Pair<FileInfo, FileInfo> folderAndDocument = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Pair<FileInfo, FileInfo>>() {
private static final String TEST_NAME = "mnt10548test-";
@Override
public Pair<FileInfo, FileInfo> execute() throws Throwable {
NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome();
/* Create folder within companyHome */
String folderName = TEST_NAME + GUID.generate();
FileInfo folderInfo = fileFolderService.create(companyHomeNodeRef, folderName, ContentModel.TYPE_FOLDER);
nodeService.setProperty(folderInfo.getNodeRef(), ContentModel.PROP_NAME, folderName);
assertNotNull(folderInfo);
/* Create content */
String docName = TEST_NAME + GUID.generate();
FileInfo document = fileFolderService.create(folderInfo.getNodeRef(), docName, ContentModel.TYPE_CONTENT);
assertNotNull(document);
nodeService.setProperty(document.getNodeRef(), ContentModel.PROP_NAME, docName);
/* Add some tags */
NodeRef nodeRef = document.getNodeRef();
taggingService.addTag(nodeRef, "tag1");
taggingService.addTag(nodeRef, "tag2");
taggingService.addTag(nodeRef, "tag3");
return new Pair<FileInfo, FileInfo>(folderInfo, document);
}
});
ObjectData objData = withCmisService(new CmisServiceCallback<ObjectData>() {
private static final String FILE_FOLDER_SEPARATOR = "/";
@Override
public ObjectData execute(CmisService cmisService) {
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
assertTrue(repositories.size() > 0);
RepositoryInfo repo = repositories.get(0);
String repositoryId = repo.getId();
String path = FILE_FOLDER_SEPARATOR + folderAndDocument.getFirst().getName() + FILE_FOLDER_SEPARATOR + folderAndDocument.getSecond().getName();
/* get CMIS object of document */
ObjectData objData = cmisService.getObjectByPath(repositoryId, path, null, false, null, null, false, false, null);
return objData;
}
}, CmisVersion.CMIS_1_1);
Map<String, PropertyData<?>> cmisProps = objData.getProperties().getProperties();
String taggable = ContentModel.ASPECT_TAGGABLE.getPrefixedQName(namespaceService).toPrefixString();
PropertyData<?> propData = cmisProps.get(taggable);
assertNotNull(propData);
List<?> props = propData.getValues();
assertTrue(props.size() == 3);
/* MNT-10548 fix : CMIS should return List of String, not List of NodeRef */
for (Object o : props) {
assertTrue(o.getClass() + " found but String expected", o instanceof String);
}
}
Aggregations