Iterator<ObjectType> iter = obList.iterator(); while (iter.hasNext()) { ObjectType ob = iter.next(); if(ob.getId() == id) { iter.remove(); break; } }
@Override public String toString() { readLock(); try { if (objectType == null) { return "<unknown>"; } return objectType.getBaseTypeId() + " (" + objectType.getId() + "): " + getId(); } finally { readUnlock(); } } }
/** * Finds the aspect type that contains the given property id. */ public static ObjectType findAspect(Collection<ObjectType> aspectTypes, String propertyId) { if (aspectTypes == null || propertyId == null) { return null; } for (ObjectType type : aspectTypes) { if (type != null && type.getPropertyDefinitions() != null && type.getPropertyDefinitions().containsKey(propertyId)) { return type; } } return null; }
/** * Determines supertypes for the given CMIS type in terms of JCR. * * @param cmisType given CMIS type * @return supertypes in JCR lexicon. */ private String[] superTypes( ObjectType cmisType ) { if (cmisType.getBaseTypeId() == BaseTypeId.CMIS_FOLDER) { return new String[] {JcrConstants.NT_FOLDER}; } if (cmisType.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT) { return new String[] {JcrConstants.NT_FILE}; } return new String[] {cmisType.getParentType().getId()}; }
boolean includePropertyDefintions = true; for (t in session.getTypeDescendants( null, // start at the top of the tree -1, // infinite depth recursion includePropertyDefintions // include prop defs )) { printTypes(t, ""); } static void printTypes(Tree tree, String tab) { ObjectType objType = tree.getItem(); println(tab + "TYPE:" + objType.getDisplayName() + " (" + objType.getDescription() + ")"); // Print some of the common attributes for this type print(tab + " Id:" + objType.getId()); print(" Fileable:" + objType.isFileable()); print(" Queryable:" + objType.isQueryable()); if (objType instanceof DocumentType) { print(" [DOC Attrs->] Versionable:" + ((DocumentType)objType).isVersionable()); print(" Content:" + ((DocumentType)objType).getContentStreamAllowed()); } println(""); // end the line for (t in tree.getChildren()) { // there are more - call self for next level printTypes(t, tab + " "); } }
if (Boolean.FALSE.equals(type.isQueryable())) { throw new IllegalArgumentException("Type '" + fte.getValue() + "' is not queryable!"); if (type.getBaseTypeId() != BaseTypeId.CMIS_SECONDARY) { if (primaryType == null) { primaryType = type; } else { throw new IllegalArgumentException( "Two primary types found: " + primaryType.getId() + " and " + type.getId()); if (isNotEmpty(type.getPropertyDefinitions())) { types.put(alias, type); propertyDef = te.getValue().getPropertyDefinitions().get(propertyId); if (propertyDef != null) { alias = te.getKey(); stmt.append(primaryType.getQueryName()); stmt.append(" AS "); stmt.append(primaryAlias); stmt.append(te.getValue().getQueryName()); stmt.append(" AS "); stmt.append(te.getKey()); propertyDef = te.getValue().getPropertyDefinitions().get(realPropertyId); if (propertyDef != null) { alias = te.getKey();
} else { for (SecondaryType secType : doc.getSecondaryTypes()) { if (secondaryTestType.getId().equals(secType.getId())) { found = true; break; Set<String> secondaryTypeProperties = new HashSet<String>(); if (secondaryTestType.getPropertyDefinitions() != null) { for (PropertyDefinition<?> propDef : secondaryTestType.getPropertyDefinitions().values()) { secondaryTypeProperties.add(propDef.getId());
public void runFolderQuery(Session session, Folder testFolder) { if (!Boolean.TRUE.equals(testFolder.getType().isQueryable())) { addResult(createResult(SKIPPED, "Folder type '" + testFolder.getType().getId() + "' is not queryable. Folder query test skipped!")); return; } CmisTestResult f; QueryStatement[] statements = new QueryStatement[] { session.createQueryStatement("SELECT * FROM ? WHERE ? = ?"), session.createQueryStatement("SELECT * FROM ? WHERE ? IN (?)") }; for (QueryStatement statement : statements) { statement.setType(1, testFolder.getType()); statement.setProperty(2, testFolder.getType().getPropertyDefinitions().get(PropertyIds.OBJECT_ID)); statement.setString(3, testFolder.getId()); addResult(createInfoResult("Folder query: " + statement.toQueryString())); int count = 0; for (QueryResult qr : statement.query(false)) { count++; String objectId = qr.getPropertyValueByQueryName("cmis:objectId"); f = createResult(FAILURE, "Folder query returned unexpected object. Id: " + objectId); addResult(assertEquals(testFolder.getId(), objectId, null, f)); } f = createResult(FAILURE, "Folder query should return exactly one hit, but returned " + count + "."); addResult(assertEquals(1, count, null, f)); } }
Map<String, PropertyDefinition<?>> propDefs = objectType.getPropertyDefinitions(); params.put(PropertyIds.OBJECT_TYPE_ID, objectType.getId()); params.put(PropertyIds.NAME, name.getLocalName()); switch (objectType.getBaseTypeId()) { case CMIS_FOLDER: params.put(PropertyIds.PATH, path);
type.setName(cmisType.getId()); type.setAbstract(false); type.setMixin(false); type.setOrderableChildNodes(true); type.setQueryable(true); if (!cmisType.isBaseType()) { type.setDeclaredSuperTypeNames(superTypes(cmisType)); Map<String, PropertyDefinition<?>> props = cmisType.getPropertyDefinitions(); Set<String> names = props.keySet();
@Override public void run(Session session) { if (supportsQuery(session) && !isFulltextOnly(session)) { if (Boolean.TRUE.equals(session.getRootFolder().getType().isQueryable())) { queryById(session); queryByDate(session); } else { addResult(createResult(SKIPPED, "Root folder type (" + session.getRootFolder().getType().getId() + ") is not queryable. Test Skipped!")); } } else { addResult(createResult(SKIPPED, "Metadata query not supported. Test Skipped!")); } }
if (objectType.isBaseType()) { writer.setPrimaryType(NodeType.NT_FILE); } else { writer.setPrimaryType(objectType.getId());
public BaseTypeId getBaseTypeId() { return folder.getType().getBaseTypeId(); }
@Override public void setType(int parameterIndex, ObjectType type) { if (type == null) { throw new IllegalArgumentException("Type must be set!"); } String queryName = type.getQueryName(); if (queryName == null) { throw new IllegalArgumentException("Type has no query name!"); } parametersMap.put(parameterIndex, queryName); }
/** * Creates a new type. */ protected ObjectType createType(Session session, TypeDefinition typeDef) { NewTypeSettableAttributes settableAttributes = session.getRepositoryInfo().getCapabilities() .getNewTypeSettableAttributes(); if (settableAttributes == null) { addResult(createResult(WARNING, "Repository Info does not indicate, which type attributes can be set!")); } else { // TODO: add more tests } ObjectType newType = null; try { newType = session.createType(typeDef); addResult(createInfoResult("Created type '" + typeDef.getId() + "'. Repository assigned the following type ID: " + newType.getId())); } catch (CmisBaseException e) { addResult(createResult(FAILURE, "Creating type '" + typeDef.getId() + "' failed: " + e.getMessage(), e, false)); return null; } addResult(checkTypeDefinition(session, newType, "Newly created type spec compliance.")); if (newType.getTypeMutability() == null) { addResult(createResult(FAILURE, "Newly created type does not provide type mutability data! ID: " + newType.getId())); } return newType; }
public boolean isBaseType() { return objectType.getParentTypeId() == null || objectType.getParentTypeId().length() == 0; }
if (Boolean.FALSE.equals(type.isCreatable())) { addResult(createResult(SKIPPED, "Folder type '" + objectTypeId + "' is not creatable!", true)); return null; String[] propertiesToCheck = new String[result.getType().getPropertyDefinitions().size()]; for (String propId : result.getType().getPropertyDefinitions().keySet()) { propertiesToCheck[i++] = propId;
public Boolean isQueryable() { return folder.getType().isQueryable(); }
if (Boolean.FALSE.equals(type.isCreatable())) { addResult(createResult(SKIPPED, "Policy type '" + objectTypeId + "' is not creatable!", true)); return null; boolean isFilable = Boolean.TRUE.equals(type.isFileable());
public Boolean isFileable() { return folder.getType().isFileable(); }