use of org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException in project copper-cms by PogeyanOSS.
the class AbstractSessionTest method createRelationship.
/**
* Creates a relationship.
*/
protected Relationship createRelationship(Session session, String name, ObjectId source, ObjectId target, String objectTypeId) {
if (name == null) {
throw new IllegalArgumentException("Name is not set!");
}
if (objectTypeId == null) {
throw new IllegalArgumentException("Object Type ID is not set!");
}
// check type
ObjectType type;
try {
type = session.getTypeDefinition(objectTypeId);
} catch (CmisObjectNotFoundException e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Relationship type '" + objectTypeId + "' is not available: " + e.getMessage(), e, true));
return null;
}
if (Boolean.FALSE.equals(type.isCreatable())) {
addResult(createResult(SKIPPED, "Relationship type '" + objectTypeId + "' is not creatable!", true));
return null;
}
// create
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, name);
properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
properties.put(PropertyIds.SOURCE_ID, source.getId());
properties.put(PropertyIds.TARGET_ID, target.getId());
ObjectId relId;
Relationship result = null;
try {
relId = session.createRelationship(properties);
result = (Relationship) session.getObject(relId, SELECT_ALL_NO_CACHE_OC);
} catch (Exception e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Relationship could not be created! Exception: " + e.getMessage(), e, true));
}
if (result != null) {
try {
// check the new relationship
addResult(checkObject(session, result, getAllProperties(result), "New document object spec compliance"));
} catch (CmisBaseException e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Newly created document is invalid! Exception: " + e.getMessage(), e, true));
}
}
return result;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException in project copper-cms by PogeyanOSS.
the class AbstractSessionTest method checkVersionHistory.
protected CmisTestResult checkVersionHistory(Session session, CmisObject object, String[] properties, String message) {
List<CmisTestResult> results = new ArrayList<CmisTestResult>();
CmisTestResult f;
if (object.getBaseTypeId() != BaseTypeId.CMIS_DOCUMENT) {
// skip non-document objects
return null;
}
if (!Boolean.TRUE.equals(((DocumentTypeDefinition) object.getType()).isVersionable())) {
// skip non-versionable types
return null;
}
Document doc = (Document) object;
// check version series ID
String versionSeriesId = doc.getVersionSeriesId();
f = createResult(FAILURE, "Versionable document has no version series ID property!");
addResult(results, assertStringNotEmpty(versionSeriesId, null, f));
if (versionSeriesId == null) {
CmisTestResultImpl result = createResult(getWorst(results), message);
result.getChildren().addAll(results);
return result;
}
// get version history
List<Document> versions = doc.getAllVersions(SELECT_ALL_NO_CACHE_OC);
f = createResult(FAILURE, "Version history is null!");
addResult(results, assertNotNull(versions, null, f));
if (versions == null) {
CmisTestResultImpl result = createResult(getWorst(results), message);
result.getChildren().addAll(results);
return result;
}
f = createResult(FAILURE, "Version history must have at least one version!");
addResult(results, assertListNotEmpty(versions, null, f));
if (!versions.isEmpty()) {
// get latest version
Document lastestVersion = doc.getObjectOfLatestVersion(false, SELECT_ALL_NO_CACHE_OC);
addResult(results, checkObject(session, lastestVersion, properties, "Latest version check: " + lastestVersion.getId()));
f = createResult(FAILURE, "Latest version is not flagged as latest version! ID: " + lastestVersion.getId());
addResult(results, assertIsTrue(lastestVersion.isLatestVersion(), null, f));
// get latest major version
Document lastestMajorVersion = null;
try {
lastestMajorVersion = doc.getObjectOfLatestVersion(true, SELECT_ALL_NO_CACHE_OC);
f = createResult(FAILURE, "getObjectOfLatestVersion returned an invalid object!");
addResult(results, assertNotNull(lastestMajorVersion, null, f));
} catch (CmisObjectNotFoundException e) {
// no latest major version
}
if (lastestMajorVersion != null) {
addResult(results, checkObject(session, lastestMajorVersion, properties, "Latest major version check: " + lastestMajorVersion.getId()));
f = createResult(FAILURE, "Latest major version is not flagged as latest major version! ID: " + lastestMajorVersion.getId());
addResult(results, assertIsTrue(lastestMajorVersion.isLatestMajorVersion(), null, f));
}
// iterate through the version history and test each version
// document
long creatationDate = Long.MAX_VALUE;
int latestVersion = 0;
int latestMajorVersion = 0;
long latestModificationDate = Long.MAX_VALUE;
int latestModifictaionIndex = Integer.MIN_VALUE;
Set<String> versionLabels = new HashSet<String>();
boolean found = false;
boolean foundLastestVersion = false;
boolean foundLastestMajorVersion = false;
for (int i = 0; i < versions.size(); i++) {
Document version = versions.get(i);
f = createResult(FAILURE, "Version " + i + " is null!");
addResult(results, assertNotNull(version, null, f));
if (version == null) {
continue;
}
addResult(results, checkObject(session, version, properties, "Version check: " + version.getId()));
// check first entry
if (i == 0) {
if (version.isVersionSeriesCheckedOut()) {
f = createResult(WARNING, "Version series is checked-out and the PWC is not the latest version! ID: " + version.getId() + " (Note: The words of the CMIS specification define that the PWC is the latest version." + " But that is not the intention of the spec and will be changed in CMIS 1.1." + " Thus this a warning, not an error.)");
addResult(results, assertIsTrue(version.isLatestVersion(), null, f));
} else {
f = createResult(FAILURE, "Version series is not checked-out and first version history entry is not the latest version! ID: " + version.getId());
addResult(results, assertIsTrue(version.isLatestVersion(), null, f));
}
}
// check version ID
f = createResult(FAILURE, "Version series id does not match! ID: " + version.getId());
addResult(results, assertEquals(versionSeriesId, version.getVersionSeriesId(), null, f));
// check creation date
if (creatationDate == version.getCreationDate().getTimeInMillis()) {
addResult(results, createResult(WARNING, "Two or more versions have the same creation date!"));
} else {
f = createResult(FAILURE, "Version history order incorrect! Must be sorted bei creation date!");
addResult(results, assertIsTrue(version.getCreationDate().getTimeInMillis() <= creatationDate, null, f));
}
// count latest versions and latest major versions
if (version.isLatestVersion()) {
latestVersion++;
}
if (version.isLatestMajorVersion()) {
latestMajorVersion++;
}
// find latest modification date
if (latestModificationDate == version.getLastModificationDate().getTimeInMillis()) {
addResult(results, createResult(WARNING, "Two or more versions have the same last modification date!"));
} else if (latestModificationDate < version.getLastModificationDate().getTimeInMillis()) {
latestModificationDate = version.getLastModificationDate().getTimeInMillis();
latestModifictaionIndex = i;
}
// check for version label duplicates
String versionLabel = version.getVersionLabel();
f = createResult(WARNING, "More than one version have this version label: " + versionLabel);
addResult(results, assertIsFalse(versionLabels.contains(versionLabel), null, f));
versionLabels.add(versionLabel);
// check PWC
if (version.getId().equals(version.getVersionSeriesCheckedOutId())) {
f = createResult(FAILURE, "PWC must not be flagged as latest major version! ID: " + version.getId());
addResult(results, assertIsFalse(version.isLatestMajorVersion(), null, f));
}
// check checked out
if (Boolean.TRUE.equals(doc.isVersionSeriesCheckedOut())) {
f = createResult(WARNING, "Version series is marked as checked out but cmis:versionSeriesCheckedOutId is not set! ID: " + version.getId());
addResult(results, assertStringNotEmpty(doc.getVersionSeriesCheckedOutId(), null, f));
f = createResult(WARNING, "Version series is marked as checked out but cmis:versionSeriesCheckedOutBy is not set! ID: " + version.getId());
addResult(results, assertStringNotEmpty(doc.getVersionSeriesCheckedOutBy(), null, f));
} else if (Boolean.FALSE.equals(doc.isVersionSeriesCheckedOut())) {
f = createResult(FAILURE, "Version series is not marked as checked out but cmis:versionSeriesCheckedOutId is set! ID: " + version.getId());
addResult(results, assertNull(doc.getVersionSeriesCheckedOutId(), null, f));
f = createResult(FAILURE, "Version series is not marked as checked out but cmis:versionSeriesCheckedOutIdBy is set! ID: " + version.getId());
addResult(results, assertNull(doc.getVersionSeriesCheckedOutBy(), null, f));
}
// found origin object?
if (version.getId().equals(object.getId())) {
found = true;
}
// found latest version?
if (version.getId().equals(lastestVersion.getId())) {
foundLastestVersion = true;
}
// found latest major version?
if (lastestMajorVersion != null && version.getId().equals(lastestMajorVersion.getId())) {
foundLastestMajorVersion = true;
}
}
// check latest versions
f = createResult(FAILURE, "Version series ID has " + latestVersion + " latest versions! There must be only one!");
addResult(results, assertEquals(1, latestVersion, null, f));
if (!foundLastestVersion) {
addResult(results, createResult(FAILURE, "Latest version not found in version history!"));
}
// check latest major versions
if (lastestMajorVersion == null) {
f = createResult(FAILURE, "Version series ID has " + latestMajorVersion + " latest major version(s) but getObjectOfLatestVersion() didn't return a major version!");
addResult(results, assertEquals(0, latestMajorVersion, null, f));
} else {
f = createResult(FAILURE, "Version series ID has " + latestMajorVersion + " latest major versions but there should be exactly one!");
addResult(results, assertEquals(1, latestMajorVersion, null, f));
if (!foundLastestMajorVersion) {
addResult(results, createResult(FAILURE, "Latest major version not found in version history!"));
}
}
// check latest version
if (latestModifictaionIndex >= 0) {
f = createResult(FAILURE, "Version with the latest modification date is not flagged as latest version! ID: " + versions.get(latestModifictaionIndex));
addResult(results, assertIsTrue(versions.get(latestModifictaionIndex).isLatestVersion(), null, f));
}
// check if the origin object was found
if (!found) {
addResult(results, createResult(FAILURE, "Document not found in its version history!"));
}
}
CmisTestResultImpl result = createResult(getWorst(results), message);
result.getChildren().addAll(results);
return result.getStatus().getLevel() <= OK.getLevel() ? null : result;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException in project copper-cms by PogeyanOSS.
the class AbstractSessionTest method createDocument.
/**
* Creates a document.
*/
protected Document createDocument(Session session, Folder parent, String name, String objectTypeId, String[] secondaryTypeIds, String content) {
if (parent == null) {
throw new IllegalArgumentException("Parent is not set!");
}
if (name == null) {
throw new IllegalArgumentException("Name is not set!");
}
if (objectTypeId == null) {
throw new IllegalArgumentException("Object Type ID is not set!");
}
if (content == null) {
content = "";
}
// check type
ObjectType type;
try {
type = session.getTypeDefinition(objectTypeId);
} catch (CmisObjectNotFoundException e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Document type '" + objectTypeId + "' is not available: " + e.getMessage(), e, true));
return null;
}
if (Boolean.FALSE.equals(type.isCreatable())) {
addResult(createResult(SKIPPED, "Document type '" + objectTypeId + "' is not creatable!", true));
return null;
}
// create
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, name);
properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId);
if (secondaryTypeIds != null) {
properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, Arrays.asList(secondaryTypeIds));
}
type = session.getTypeDefinition(objectTypeId);
if (!(type instanceof DocumentTypeDefinition)) {
addResult(createResult(FAILURE, "Type is not a document type! Type: " + objectTypeId, true));
return null;
}
DocumentTypeDefinition docType = (DocumentTypeDefinition) type;
VersioningState versioningState = (Boolean.TRUE.equals(docType.isVersionable()) ? VersioningState.MAJOR : VersioningState.NONE);
byte[] contentBytes = null;
Document result = null;
try {
contentBytes = IOUtils.toUTF8Bytes(content);
ContentStream contentStream = new ContentStreamImpl(name, BigInteger.valueOf(contentBytes.length), "text/plain", new ByteArrayInputStream(contentBytes));
// create the document
result = parent.createDocument(properties, contentStream, versioningState, null, null, null, SELECT_ALL_NO_CACHE_OC);
contentStream.getStream().close();
} catch (Exception e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Document could not be created! Exception: " + e.getMessage(), e, true));
return null;
}
try {
CmisTestResult f;
// check document name
f = createResult(FAILURE, "Document name does not match!", false);
addResult(assertEquals(name, result.getName(), null, f));
// check content length
f = createResult(WARNING, "Content length does not match!", false);
addResult(assertEquals((long) contentBytes.length, result.getContentStreamLength(), null, f));
// check the new document
addResult(checkObject(session, result, getAllProperties(result), "New document object spec compliance"));
// check content
try {
ContentStream contentStream = result.getContentStream();
f = createResult(WARNING, "Document filename and the filename of the content stream do not match!", false);
addResult(assertEquals(name, contentStream.getFileName(), null, f));
f = createResult(WARNING, "cmis:contentStreamFileName and the filename of the content stream do not match!", false);
addResult(assertEquals(result.getContentStreamFileName(), contentStream.getFileName(), null, f));
String fetchedContent = getStringFromContentStream(result.getContentStream());
if (!content.equals(fetchedContent)) {
addResult(createResult(FAILURE, "Content of newly created document doesn't match the orign content!"));
}
} catch (IOException e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Content of newly created document couldn't be read! Exception: " + e.getMessage(), e, true));
}
} catch (CmisBaseException e) {
addResult(createResult(UNEXPECTED_EXCEPTION, "Newly created document is invalid! Exception: " + e.getMessage(), e, true));
}
// check parents
List<Folder> parents = result.getParents(SELECT_ALL_NO_CACHE_OC);
boolean found = false;
for (Folder folder : parents) {
if (parent.getId().equals(folder.getId())) {
found = true;
break;
}
}
if (!found) {
addResult(createResult(FAILURE, "The folder the document has been created in is not in the list of the document parents!"));
}
return result;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException in project copper-cms by PogeyanOSS.
the class AbstractSessionTest method checkTypeDefinition.
protected CmisTestResult checkTypeDefinition(Session session, TypeDefinition type, String message) {
List<CmisTestResult> results = new ArrayList<CmisTestResult>();
CmisTestResult f;
f = createResult(FAILURE, "Type is null!");
addResult(results, assertNotNull(type, null, f));
if (type != null) {
f = createResult(FAILURE, "Type ID is not set!");
addResult(results, assertStringNotEmpty(type.getId(), null, f));
f = createResult(FAILURE, "Base type ID is not set!");
addResult(results, assertNotNull(type.getBaseTypeId(), null, f));
f = createResult(FAILURE, "Local name is not set!");
addResult(results, assertStringNotEmpty(type.getLocalName(), null, f));
// f = createResult(FAILURE, "Local namespace is not set!");
// addResult(results, assertStringNotEmpty(type.(), null, f));
boolean isQueryNameRequired = Boolean.TRUE.equals(type.isQueryable());
addResult(results, checkQueryName(type.getQueryName(), isQueryNameRequired, "Type Query Name: " + type.getQueryName()));
if ((type.getId() != null) && (type.getBaseTypeId() != null)) {
if (type.getBaseTypeId().value().equals(type.getId())) {
f = createResult(FAILURE, "Base type has parent type!");
addResult(results, assertStringNullOrEmpty(type.getParentTypeId(), null, f));
f = createResult(FAILURE, "Query name of base type is wrong!");
addResult(results, assertEquals(type.getId(), type.getQueryName(), null, f));
} else {
f = createResult(FAILURE, "Parent type is not set!");
addResult(results, assertStringNotEmpty(type.getParentTypeId(), null, f));
}
}
f = createResult(FAILURE, "Creatable flag is not set!");
addResult(results, assertNotNull(type.isCreatable(), null, f));
f = createResult(FAILURE, "Fileable flag is not set!");
addResult(results, assertNotNull(type.isFileable(), null, f));
f = createResult(FAILURE, "Controllable ACL flag is not set!");
addResult(results, assertNotNull(type.isControllableAcl(), null, f));
f = createResult(FAILURE, "Controllable Policy flag is not set!");
addResult(results, assertNotNull(type.isControllablePolicy(), null, f));
f = createResult(FAILURE, "Fulltext indexed flag is not set!");
addResult(results, assertNotNull(type.isFulltextIndexed(), null, f));
f = createResult(FAILURE, "Included in super type flag is not set!");
addResult(results, assertNotNull(type.isIncludedInSupertypeQuery(), null, f));
f = createResult(FAILURE, "Queryable flag is not set!");
addResult(results, assertNotNull(type.isQueryable(), null, f));
f = createResult(WARNING, "Type display name is not set!");
addResult(results, assertStringNotEmpty(type.getDisplayName(), null, f));
f = createResult(WARNING, "Type description is not set!");
addResult(results, assertStringNotEmpty(type.getDescription(), null, f));
if (BaseTypeId.CMIS_DOCUMENT.equals(type.getBaseTypeId())) {
DocumentTypeDefinition docType = (DocumentTypeDefinition) type;
f = createResult(FAILURE, "Versionable flag is not set!");
addResult(results, assertNotNull(docType.isVersionable(), null, f));
f = createResult(FAILURE, "Content stream allowed flag is not set!");
addResult(results, assertNotNull(docType.getContentStreamAllowed(), null, f));
} else if (BaseTypeId.CMIS_FOLDER.equals(type.getBaseTypeId())) {
if (type.isFileable() != null) {
f = createResult(FAILURE, "Folder types must be fileable!");
addResult(results, assertIsTrue(type.isFileable(), null, f));
}
} else if (BaseTypeId.CMIS_RELATIONSHIP.equals(type.getBaseTypeId())) {
RelationshipTypeDefinition relType = (RelationshipTypeDefinition) type;
f = createResult(FAILURE, "Allowed Source Type IDs are not set!");
addResult(results, assertNotNull(relType.getAllowedSourceTypeIds(), null, f));
if (relType.getAllowedSourceTypeIds() != null) {
for (String typeId : relType.getAllowedSourceTypeIds()) {
try {
session.getTypeDefinition(typeId);
} catch (CmisInvalidArgumentException e) {
addResult(results, createResult(WARNING, "Allowed Source Type IDs contain a type ID that doesn't exist: " + typeId));
} catch (CmisObjectNotFoundException e) {
addResult(results, createResult(WARNING, "Allowed Source Type IDs contain a type ID that doesn't exist: " + typeId));
}
}
}
f = createResult(FAILURE, "Allowed Target Type IDs are not set!");
addResult(results, assertNotNull(relType.getAllowedTargetTypeIds(), null, f));
if (relType.getAllowedTargetTypeIds() != null) {
for (String typeId : relType.getAllowedTargetTypeIds()) {
try {
session.getTypeDefinition(typeId);
} catch (CmisInvalidArgumentException e) {
addResult(results, createResult(WARNING, "Allowed Target Type IDs contain a type ID that doesn't exist: " + typeId));
} catch (CmisObjectNotFoundException e) {
addResult(results, createResult(WARNING, "Allowed Target Type IDs contain a type ID that doesn't exist: " + typeId));
}
}
}
if (type.isFileable() != null) {
f = createResult(FAILURE, "Relationship types must not be fileable!");
addResult(results, assertIsFalse(type.isFileable(), null, f));
}
} else if (BaseTypeId.CMIS_POLICY.equals(type.getBaseTypeId())) {
// nothing to do
} else if (BaseTypeId.CMIS_SECONDARY.equals(type.getBaseTypeId())) {
if (type.isCreatable() != null) {
f = createResult(FAILURE, "Secondary types must not be creatable!");
addResult(results, assertIsFalse(type.isCreatable(), null, f));
}
if (type.isFileable() != null) {
f = createResult(FAILURE, "Secondary types must not be fileable!");
addResult(results, assertIsFalse(type.isFileable(), null, f));
}
if (type.isControllableAcl() != null) {
f = createResult(FAILURE, "The controllable ACL flag must be false for secondary types!");
addResult(results, assertIsFalse(type.isControllableAcl(), null, f));
}
if (type.isControllablePolicy() != null) {
f = createResult(FAILURE, "The controllable policy flag must be false for secondary types!");
addResult(results, assertIsFalse(type.isControllablePolicy(), null, f));
}
}
// check properties
if (!BaseTypeId.CMIS_SECONDARY.equals(type.getBaseTypeId())) {
f = createResult(FAILURE, "Type has no property definitions!");
addResult(results, assertNotNull(type.getPropertyDefinitions(), null, f));
if (type.getPropertyDefinitions() != null) {
for (PropertyDefinition<?> propDef : type.getPropertyDefinitions().values()) {
if (propDef == null) {
addResult(results, createResult(FAILURE, "A property definition is null!"));
} else if (propDef.getId() == null) {
addResult(results, createResult(FAILURE, "A property definition ID is null!"));
} else {
addResult(results, checkPropertyDefinition(propDef, "Property definition: " + propDef.getId()));
}
}
}
CmisPropertyDefintion cpd;
// cmis:name
cpd = new CmisPropertyDefintion(PropertyIds.NAME, null, PropertyType.STRING, Cardinality.SINGLE, null, null, null);
addResult(results, cpd.check(type));
// cmis:objectId
cpd = new CmisPropertyDefintion(PropertyIds.OBJECT_ID, false, PropertyType.ID, Cardinality.SINGLE, Updatability.ONCREATE, null, null);
addResult(results, cpd.check(type));
// cmis:baseTypeId
cpd = new CmisPropertyDefintion(PropertyIds.BASE_TYPE_ID, false, PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:objectTypeId
cpd = new CmisPropertyDefintion(PropertyIds.OBJECT_TYPE_ID, true, PropertyType.ID, Cardinality.SINGLE, Updatability.ONCREATE, null, null);
addResult(results, cpd.check(type));
// cmis:createdBy
cpd = new CmisPropertyDefintion(PropertyIds.CREATED_BY, false, PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, true, true);
addResult(results, cpd.check(type));
// cmis:creationDate
cpd = new CmisPropertyDefintion(PropertyIds.CREATION_DATE, false, PropertyType.DATETIME, Cardinality.SINGLE, Updatability.READONLY, true, true);
addResult(results, cpd.check(type));
// cmis:lastModifiedBy
cpd = new CmisPropertyDefintion(PropertyIds.LAST_MODIFIED_BY, false, PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, true, true);
addResult(results, cpd.check(type));
// cmis:lastModificationDate
cpd = new CmisPropertyDefintion(PropertyIds.LAST_MODIFICATION_DATE, false, PropertyType.DATETIME, Cardinality.SINGLE, Updatability.READONLY, true, true);
addResult(results, cpd.check(type));
// cmis:changeToken
cpd = new CmisPropertyDefintion(PropertyIds.CHANGE_TOKEN, false, PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// CMIS 1.1 properties
if (session.getRepositoryInfo().getCmisVersion() == CmisVersion.CMIS_1_1) {
// cmis:description
cpd = new CmisPropertyDefintion(PropertyIds.DESCRIPTION, null, PropertyType.STRING, Cardinality.SINGLE, null, null, null);
addResult(results, cpd.check(type));
// cmis:secondaryObjectTypeIds
cpd = new CmisPropertyDefintion(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, false, PropertyType.ID, Cardinality.MULTI, null, null, false);
addResult(results, cpd.check(type));
if (BaseTypeId.CMIS_DOCUMENT.equals(type.getBaseTypeId())) {
// cmis:isPrivateWorkingCopy
cpd = new CmisPropertyDefintion(PropertyIds.IS_PRIVATE_WORKING_COPY, null, PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
}
}
if (BaseTypeId.CMIS_DOCUMENT.equals(type.getBaseTypeId())) {
// cmis:isImmutable
cpd = new CmisPropertyDefintion(PropertyIds.IS_IMMUTABLE, false, PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:isLatestVersion
cpd = new CmisPropertyDefintion(PropertyIds.IS_LATEST_VERSION, false, PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:isMajorVersion
cpd = new CmisPropertyDefintion(PropertyIds.IS_MAJOR_VERSION, false, PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:isLatestMajorVersion
cpd = new CmisPropertyDefintion(PropertyIds.IS_LATEST_MAJOR_VERSION, false, PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:versionLabel
cpd = new CmisPropertyDefintion(PropertyIds.VERSION_LABEL, false, PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:versionSeriesId
cpd = new CmisPropertyDefintion(PropertyIds.VERSION_SERIES_ID, false, PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:isVersionSeriesCheckedOut
cpd = new CmisPropertyDefintion(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT, false, PropertyType.BOOLEAN, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:versionSeriesCheckedOutBy
cpd = new CmisPropertyDefintion(PropertyIds.VERSION_SERIES_CHECKED_OUT_BY, false, PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:versionSeriesCheckedOutId
cpd = new CmisPropertyDefintion(PropertyIds.VERSION_SERIES_CHECKED_OUT_ID, false, PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:checkinComment
cpd = new CmisPropertyDefintion(PropertyIds.CHECKIN_COMMENT, false, PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:contentStreamLength
cpd = new CmisPropertyDefintion(PropertyIds.CONTENT_STREAM_LENGTH, false, PropertyType.INTEGER, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:contentStreamMimeType
cpd = new CmisPropertyDefintion(PropertyIds.CONTENT_STREAM_MIME_TYPE, false, PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:contentStreamFileName
cpd = new CmisPropertyDefintion(PropertyIds.CONTENT_STREAM_FILE_NAME, false, PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:contentStreamId
cpd = new CmisPropertyDefintion(PropertyIds.CONTENT_STREAM_ID, false, PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
} else if (BaseTypeId.CMIS_FOLDER.equals(type.getBaseTypeId())) {
// cmis:parentId
cpd = new CmisPropertyDefintion(PropertyIds.PARENT_ID, false, PropertyType.ID, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:path
cpd = new CmisPropertyDefintion(PropertyIds.PATH, false, PropertyType.STRING, Cardinality.SINGLE, Updatability.READONLY, null, null);
addResult(results, cpd.check(type));
// cmis:allowedChildObjectTypeIds
cpd = new CmisPropertyDefintion(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS, false, PropertyType.ID, Cardinality.MULTI, Updatability.READONLY, null, false);
addResult(results, cpd.check(type));
} else if (BaseTypeId.CMIS_RELATIONSHIP.equals(type.getBaseTypeId())) {
// cmis:sourceId
cpd = new CmisPropertyDefintion(PropertyIds.SOURCE_ID, true, PropertyType.ID, Cardinality.SINGLE, null, null, null);
addResult(results, cpd.check(type));
// cmis:targetId
cpd = new CmisPropertyDefintion(PropertyIds.TARGET_ID, true, PropertyType.ID, Cardinality.SINGLE, null, null, null);
addResult(results, cpd.check(type));
} else if (BaseTypeId.CMIS_POLICY.equals(type.getBaseTypeId())) {
// cmis:policyText
cpd = new CmisPropertyDefintion(PropertyIds.POLICY_TEXT, null, PropertyType.STRING, Cardinality.SINGLE, null, null, null);
addResult(results, cpd.check(type));
}
}
}
CmisTestResultImpl result = createResult(getWorst(results), message);
result.getChildren().addAll(results);
return result.getStatus().getLevel() <= OK.getLevel() ? null : result;
}
use of org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException in project copper-cms by PogeyanOSS.
the class CreateAndDeleteTypeTest method createTypeWithProperties.
private void createTypeWithProperties(Session session, ObjectType parentType) {
CmisTestResult failure = null;
CreatablePropertyTypes cpt = session.getRepositoryInfo().getCapabilities().getCreatablePropertyTypes();
if (cpt == null || cpt.canCreate() == null || cpt.canCreate().isEmpty()) {
addResult(createResult(FAILURE, "Repository Info does not indicate, which property types can be created!"));
return;
}
// define the type
DocumentTypeDefinitionImpl newTypeDef = createDocumentTypeDefinition(session, "tck:testid_with_properties", parentType);
// add a property for each creatable property type
for (PropertyType propType : PropertyType.values()) {
if (!cpt.canCreate().contains(propType)) {
continue;
}
newTypeDef.addPropertyDefinition(createPropertyDefinition(propType));
}
// create the type
ObjectType newType = createType(session, newTypeDef);
if (newType == null) {
return;
}
// get the type
ObjectType newType2 = null;
try {
newType2 = session.getTypeDefinition(newType.getId());
// assert type definitions
failure = createResult(FAILURE, "The type definition returned by createType() doesn't match the type definition returned by getTypeDefinition()!");
addResult(assertEquals(newType, newType2, null, failure));
} catch (CmisObjectNotFoundException e) {
addResult(createResult(FAILURE, "Newly created type can not be fetched. Id: " + newType.getId(), e, false));
}
// check properties
List<PropertyDefinition<?>> newPropDefs = new ArrayList<PropertyDefinition<?>>();
for (Map.Entry<String, PropertyDefinition<?>> propDef : newType.getPropertyDefinitions().entrySet()) {
if (Boolean.FALSE.equals(propDef.getValue().isInherited())) {
newPropDefs.add(propDef.getValue());
}
}
failure = createResult(FAILURE, "The number of defined properties and the number of non-inherited properties don't match!");
addResult(assertEquals(newTypeDef.getPropertyDefinitions().size(), newPropDefs.size(), null, failure));
// check the order of the properties, which must match the order of the
// original type definition
// (OpenCMIS keeps the order of the property definitions.)
int i = 0;
for (Map.Entry<String, PropertyDefinition<?>> propDef : newTypeDef.getPropertyDefinitions().entrySet()) {
PropertyDefinition<?> newPropDef = newPropDefs.get(i);
failure = createResult(FAILURE, "Property " + (i + 1) + " must be of type " + propDef.getValue().getPropertyType() + " but is of type " + newPropDef.getPropertyType() + "!");
addResult(assertEquals(propDef.getValue().getPropertyType(), newPropDef.getPropertyType(), null, failure));
addResult(createInfoResult("Repository assigned the property '" + propDef.getValue().getId() + "' the following property id: " + newPropDef.getId()));
i++;
}
// delete the type
deleteType(session, newType.getId());
}
Aggregations