}
ObjectInfoImpl info = new ObjectInfoImpl();
// get the repository info
RepositoryInfo repositoryInfo = getRepositoryInfo(repositoryId, null);
// general properties
info.setObject(object);
info.setId(object.getId());
info.setName(getStringProperty(object, PropertyIds.NAME));
info.setCreatedBy(getStringProperty(object, PropertyIds.CREATED_BY));
info.setCreationDate(getDateTimeProperty(object, PropertyIds.CREATED_BY));
info.setLastModificationDate(getDateTimeProperty(object, PropertyIds.LAST_MODIFICATION_DATE));
info.setTypeId(getIdProperty(object, PropertyIds.OBJECT_TYPE_ID));
info.setBaseType(object.getBaseTypeId());
// versioning
info.setIsCurrentVersion(object.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT);
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
info.setVersionSeriesId(getIdProperty(object, PropertyIds.VERSION_SERIES_ID));
if (info.getVersionSeriesId() != null) {
Boolean isLatest = getBooleanProperty(object, PropertyIds.IS_LATEST_VERSION);
info.setIsCurrentVersion(isLatest == null ? true : isLatest.booleanValue());
Boolean isCheckedOut = getBooleanProperty(object, PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
if (isCheckedOut != null && isCheckedOut.booleanValue()) {
info.setWorkingCopyId(getIdProperty(object, PropertyIds.VERSION_SERIES_CHECKED_OUT_ID));
// get latest version
List<ObjectData> versions = getAllVersions(repositoryId, object.getId(), info.getVersionSeriesId(),
null, Boolean.FALSE, null);
if (versions != null && versions.size() > 0) {
info.setWorkingCopyOriginalId(versions.get(0).getId());
}
}
}
// 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
List<ObjectParentData> parents = getObjectParents(repositoryId, object.getId(), null, Boolean.FALSE,
IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, null);
info.setHasParent(parents.size() > 0);
// policies and relationships
info.setSupportsRelationships(false);
info.setSupportsPolicies(false);
TypeDefinitionList baseTypesList = getTypeChildren(repositoryId, null, Boolean.FALSE, BigInteger.valueOf(4),
BigInteger.ZERO, null);
for (TypeDefinition type : baseTypesList.getList()) {
if (BaseTypeId.CMIS_RELATIONSHIP.value().equals(type.getId())) {
info.setSupportsRelationships(true);
} else if (BaseTypeId.CMIS_POLICY.value().equals(type.getId())) {
info.setSupportsPolicies(true);
}
}
// renditions
info.setRenditionInfos(null);
List<RenditionData> renditions = object.getRenditions();
if (renditions != null && renditions.size() > 0) {
List<RenditionInfo> renditionInfos = new ArrayList<RenditionInfo>();
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
info.setRelationshipSourceIds(null);
info.setRelationshipTargetIds(null);
List<ObjectData> relationships = object.getRelationships();
if (relationships != null && relationships.size() > 0) {
List<String> sourceIds = new ArrayList<String>();
List<String> targetIds = new ArrayList<String>();
for (ObjectData relationship : relationships) {
String sourceId = getIdProperty(relationship, PropertyIds.SOURCE_ID);
String targetId = getIdProperty(relationship, PropertyIds.TARGET_ID);
if (object.getId().equals(sourceId)) {
sourceIds.add(relationship.getId());
}
if (object.getId().equals(targetId)) {
targetIds.add(relationship.getId());
}
}
if (sourceIds.size() > 0) {
info.setRelationshipSourceIds(sourceIds);
}
if (targetIds.size() > 0) {
info.setRelationshipTargetIds(targetIds);
}
}
// global settings
info.setHasAcl(false);
info.setSupportsDescendants(false);
info.setSupportsFolderTree(false);
RepositoryCapabilities capabilities = repositoryInfo.getCapabilities();
if (capabilities != null) {
info.setHasAcl(capabilities.getAclCapability() == CapabilityAcl.DISCOVER
|| capabilities.getAclCapability() == CapabilityAcl.MANAGE);
if (object.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) {
info.setSupportsDescendants(Boolean.TRUE.equals(capabilities.isGetDescendantsSupported()));