use of org.apache.chemistry.opencmis.commons.impl.server.ObjectInfoImpl in project alfresco-repository by Alfresco.
the class AlfrescoCmisServiceImpl method getObjectInfoIntern.
/**
* Collects the {@link ObjectInfo} about an object.
*
* (Provided by OpenCMIS, but optimized for Alfresco.)
*/
@SuppressWarnings("unchecked")
@Override
protected ObjectInfo getObjectInfoIntern(String repositoryId, ObjectData object) {
// if the object has no properties, stop here
if (object.getProperties() == null || object.getProperties().getProperties() == null) {
throw new CmisRuntimeException("No properties!");
}
String objectId = object.getId();
CMISNodeInfo ni = getOrCreateNodeInfo(objectId);
ObjectInfoImpl info = new ObjectInfoImpl();
// general properties
info.setObject(object);
info.setId(objectId);
info.setName(getStringProperty(object, PropertyIds.NAME));
info.setCreatedBy(getStringProperty(object, PropertyIds.CREATED_BY));
info.setCreationDate(getDateTimeProperty(object, PropertyIds.CREATION_DATE));
info.setLastModificationDate(getDateTimeProperty(object, PropertyIds.LAST_MODIFICATION_DATE));
info.setTypeId(getIdProperty(object, PropertyIds.OBJECT_TYPE_ID));
info.setBaseType(object.getBaseTypeId());
if (ni.isRelationship()) {
// versioning
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
info.setVersionSeriesId(null);
info.setIsCurrentVersion(true);
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
// content
info.setHasContent(false);
info.setContentType(null);
info.setFileName(null);
// parent
info.setHasParent(false);
// policies and relationships
info.setSupportsRelationships(false);
info.setSupportsPolicies(false);
// renditions
info.setRenditionInfos(null);
// relationships
info.setRelationshipSourceIds(null);
info.setRelationshipTargetIds(null);
// global settings
info.setHasAcl(false);
info.setSupportsDescendants(false);
info.setSupportsFolderTree(false);
} else if (ni.isFolder()) {
// versioning
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
info.setVersionSeriesId(null);
info.setIsCurrentVersion(true);
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
// content
info.setHasContent(false);
info.setContentType(null);
info.setFileName(null);
// parent
info.setHasParent(!ni.isRootFolder());
// policies and relationships
info.setSupportsRelationships(true);
info.setSupportsPolicies(true);
// renditions
info.setRenditionInfos(null);
// relationships
setRelaionshipsToObjectInfo(object, info);
// global settings
info.setHasAcl(true);
info.setSupportsDescendants(true);
info.setSupportsFolderTree(true);
} else if (ni.isDocument()) {
// versioning
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
info.setVersionSeriesId(ni.getCurrentNodeId());
if (ni.isPWC()) {
info.setIsCurrentVersion(false);
info.setWorkingCopyId(ni.getObjectId());
info.setWorkingCopyOriginalId(ni.getCurrentObjectId());
} else {
info.setIsCurrentVersion(ni.isCurrentVersion());
if (ni.hasPWC()) {
info.setWorkingCopyId(ni.getCurrentNodeId() + CMISConnector.ID_SEPERATOR + CMISConnector.PWC_VERSION_LABEL);
info.setWorkingCopyOriginalId(ni.getCurrentObjectId());
} else {
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
}
}
// content
String fileName = getStringProperty(object, PropertyIds.CONTENT_STREAM_FILE_NAME);
String mimeType = getStringProperty(object, PropertyIds.CONTENT_STREAM_MIME_TYPE);
String streamId = getIdProperty(object, PropertyIds.CONTENT_STREAM_ID);
BigInteger length = getIntegerProperty(object, PropertyIds.CONTENT_STREAM_LENGTH);
boolean hasContent = fileName != null || mimeType != null || streamId != null || length != null;
if (hasContent) {
info.setHasContent(hasContent);
info.setContentType(mimeType);
info.setFileName(fileName);
} else {
info.setHasContent(false);
info.setContentType(null);
info.setFileName(null);
}
// parent
info.setHasParent(ni.isCurrentVersion() || ni.isPWC());
// policies and relationships
info.setSupportsRelationships(true);
info.setSupportsPolicies(true);
// renditions
String renditionFilter = getRequestParameterRenditionFilter();
List<RenditionInfo> renditionInfos = new ArrayList<>();
CMISNodeInfo nodeInfo = getOrCreateNodeInfo(objectId);
NodeRef nodeRef = nodeInfo.getNodeRef();
if (nodeRef != null) {
List<RenditionData> renditions = connector.getRenditions(nodeRef, renditionFilter, null, null);
for (RenditionData rendition : renditions) {
RenditionInfoImpl renditionInfo = new RenditionInfoImpl();
renditionInfo.setId(rendition.getStreamId());
renditionInfo.setKind(rendition.getKind());
renditionInfo.setContentType(rendition.getMimeType());
renditionInfo.setTitle(rendition.getTitle());
renditionInfo.setLength(rendition.getBigLength());
renditionInfos.add(renditionInfo);
}
}
info.setRenditionInfos(renditionInfos);
// relationships
setRelaionshipsToObjectInfo(object, info);
// global settings
info.setHasAcl(true);
info.setSupportsDescendants(true);
info.setSupportsFolderTree(true);
} else if (ni.isItem()) {
info.setHasAcl(true);
info.setHasContent(false);
}
return info;
}
Aggregations