org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException Java Examples
The following examples show how to use
org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 7 votes |
public ObjectInfo getObjectInfo(String objectId, ObjectInfoHandler handler) { debug("getObjectInfo " + objectId); validatePermission(objectId, null, null); try { // check id if ((objectId == null)) throw new CmisInvalidArgumentException("Object Id must be set."); ObjectInfoImpl info = new ObjectInfoImpl(); PersistentObject object = getObject(objectId); compileProperties(object, null, info); ObjectData data = compileObjectType(null, object, null, true, true, handler); info.setObject(data); return info; } catch (Throwable t) { log.warn("Not able to retrieve object {}", objectId); return (ObjectInfo) catchError(t); } }
Example #2
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Checks the depth parameter if it complies with CMIS specification and * returns the default value if {@code depth} is {@code null}. */ protected BigInteger getDepth(BigInteger depth) { if (depth == null) { return defaultDepth; } if (depth.compareTo(BigInteger.ZERO) == 0) { throw new CmisInvalidArgumentException("depth must not be 0!"); } if (depth.compareTo(MINUS_ONE) == -1) { throw new CmisInvalidArgumentException("depth must not be <-1!"); } return depth; }
Example #3
Source File: DirectLuceneBuilder.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
@Override public <Q, S, E extends Throwable> String getLuceneSortField(LuceneQueryParserAdaptor<Q, S, E> lqpa) throws E { String field = getLuceneFieldName(); // need to find the real field to use PropertyDefinition propertyDef = dictionaryService.getProperty(QName.createQName(field.substring(1))); if (propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT)) { throw new CmisInvalidArgumentException("Order on content properties is not curently supported"); } else if ((propertyDef.getDataType().getName().equals(DataTypeDefinition.MLTEXT)) || (propertyDef.getDataType().getName().equals(DataTypeDefinition.TEXT))) { field = lqpa.getSortField(field); } else if (propertyDef.getDataType().getName().equals(DataTypeDefinition.DATETIME)) { field = lqpa.getDatetimeSortField(field, propertyDef); } return field; }
Example #4
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Checks the depth parameter if it complies with CMIS specification and * returns the default value if {@code depth} is {@code null}. */ protected BigInteger getTypesDepth(BigInteger depth) { if (depth == null) { return defaultTypesDepth; } if (depth.compareTo(BigInteger.ZERO) == 0) { throw new CmisInvalidArgumentException("depth must not be 0!"); } if (depth.compareTo(MINUS_ONE) == -1) { throw new CmisInvalidArgumentException("depth must not be <-1!"); } return depth; }
Example #5
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Throws an exception if the given property isn't set or of the wrong type. */ protected void checkProperty(Properties properties, String propertyId, Class<?> clazz) { if (properties.getProperties() == null) { throw new CmisInvalidArgumentException("Property " + propertyId + " must be set!"); } PropertyData<?> property = properties.getProperties().get(propertyId); if (property == null) { throw new CmisInvalidArgumentException("Property " + propertyId + " must be set!"); } Object value = property.getFirstValue(); if (value == null) { throw new CmisInvalidArgumentException("Property " + propertyId + " must have a value!"); } if (!clazz.isAssignableFrom(value.getClass())) { throw new CmisInvalidArgumentException("Property " + propertyId + " has the wrong type!"); } }
Example #6
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Throws an exception if the given list is {@code null} or empty or * invalid. */ protected void checkBulkUpdateList(List<BulkUpdateObjectIdAndChangeToken> list) { if (list == null) { throw new CmisInvalidArgumentException("Object Id list must be set!"); } if (list.isEmpty()) { throw new CmisInvalidArgumentException("Object Id list must not be empty!"); } for (BulkUpdateObjectIdAndChangeToken entry : list) { if (entry == null) { throw new CmisInvalidArgumentException("Object Id list has gaps!"); } if (entry.getId() == null) { throw new CmisInvalidArgumentException("Object Id list contains an entry without ID!"); } if (entry.getId().length() == 0) { throw new CmisInvalidArgumentException("Object Id list contains an entry with an empty ID!"); } } }
Example #7
Source File: AlfrescoCmisServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public ContentStream getContentStream( String repositoryId, String objectId, String streamId, BigInteger offset, BigInteger length, ExtensionsData extension) { checkRepositoryId(repositoryId); // what kind of object is it? CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object"); // relationships cannot have content if (info.isVariant(CMISObjectVariant.ASSOC)) { throw new CmisInvalidArgumentException("Object is a relationship and cannot have content!"); } // now get it return connector.getContentStream(info, streamId, offset, length); }
Example #8
Source File: BaseTypeIdLuceneBuilder.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 6 votes |
private String getType(String tableName) { TypeDefinitionWrapper typeDef = dictionaryService.findTypeByQueryName(tableName); if (typeDef == null) { throw new CmisInvalidArgumentException("Unknown type: " + tableName); } if(!typeDef.isBaseType()) { throw new CmisInvalidArgumentException("Not a base type: " + tableName); } if(!typeDef.getTypeDefinition(false).isQueryable()) { throw new CmisInvalidArgumentException("Type is not queryable: " + tableName); } return typeDef.getAlfrescoClass().toString(); }
Example #9
Source File: AlfrescoCmisServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override public ObjectList query(String repositoryId, String statement, Boolean searchAllVersions, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) { checkRepositoryId(repositoryId); if (searchAllVersions.booleanValue()) { throw new CmisInvalidArgumentException("Search all version is not supported!"); } return connector.query( statement, includeAllowableActions, includeRelationships, renditionFilter, maxItems, skipCount); }
Example #10
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public String getNameProperty(Properties properties, String fallback) { String name = getStringProperty(properties, PropertyIds.NAME); if ((name == null) || (name.trim().length() == 0)) { if (fallback == null) { throw new CmisInvalidArgumentException("Property " + PropertyIds.NAME + " must be set!"); } else { name = fallback; } } return name; }
Example #11
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Throws an exception if the given id is {@code null} or empty. */ protected void checkId(String name, String id) { if (id == null) { throw new CmisInvalidArgumentException(name + " must be set!"); } if (id.length() == 0) { throw new CmisInvalidArgumentException(name + " must not be empty!"); } }
Example #12
Source File: TypeManager.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * CMIS getTypesDescendants * * @param context call context * @param typeId id of the type * @param depth depth specification * @param includePropertyDefinitions if the properties definition must be included * * @return list of definitions */ public List<TypeDefinitionContainer> getTypesDescendants(CallContext context, String typeId, BigInteger depth, Boolean includePropertyDefinitions) { List<TypeDefinitionContainer> result = new ArrayList<TypeDefinitionContainer>(); // check depth int d = (depth == null ? -1 : depth.intValue()); if (d == 0) { throw new CmisInvalidArgumentException("Depth must not be 0!"); } // set property definition flag to default value if not set boolean ipd = (includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue()); if (typeId == null) { result.add(getTypesDescendants(d, types.get(FOLDER_TYPE_ID), ipd)); result.add(getTypesDescendants(d, types.get(DOCUMENT_TYPE_ID), ipd)); // result.add(getTypesDescendants(depth, // fTypes.get(RELATIONSHIP_TYPE_ID), includePropertyDefinitions)); // result.add(getTypesDescendants(depth, fTypes.get(POLICY_TYPE_ID), // includePropertyDefinitions)); } else { TypeDefinitionContainer tc = types.get(typeId); if (tc != null) { result.add(getTypesDescendants(d, tc, ipd)); } } return result; }
Example #13
Source File: CMIS_FTSLexer.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public Token nextTokenImpl() { while (true) { state.token = null; state.channel = Token.DEFAULT_CHANNEL; state.tokenStartCharIndex = input.index(); state.tokenStartCharPositionInLine = input.getCharPositionInLine(); state.tokenStartLine = input.getLine(); state.text = null; if ( input.LA(1)==CharStream.EOF ) { return getEOFToken(); } try { mTokens(); if ( state.token==null ) { emit(); } else if ( state.token==Token.SKIP_TOKEN ) { continue; } return state.token; } catch (RecognitionException re) { throw new CmisInvalidArgumentException(getErrorString(re), re); } } }
Example #14
Source File: AlfrescoCmisServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void removeObjectFromFolder(String repositoryId, String objectId, String folderId, ExtensionsData extension) { checkRepositoryId(repositoryId); // get node ref CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object"); if (!info.isDocument()) { throw new CmisInvalidArgumentException("Object is not a document!"); } final NodeRef nodeRef = info.getNodeRef(); // get the folder node ref final NodeRef folderNodeRef = getOrCreateFolderInfo(folderId, "Folder").getNodeRef(); // check primary parent if (connector.getNodeService().getPrimaryParent(nodeRef).getParentRef().equals(folderNodeRef)) { throw new CmisConstraintException( "Unfiling from primary parent folder is not supported! Use deleteObject() instead."); } connector.getNodeService().removeChild(folderNodeRef, nodeRef); }
Example #15
Source File: AlfrescoCmisServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void addObjectToFolder( String repositoryId, String objectId, String folderId, Boolean allVersions, ExtensionsData extension) { checkRepositoryId(repositoryId); if (!allVersions) { throw new CmisInvalidArgumentException("Only allVersions=true supported!"); } // get node ref CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object"); if (!info.isDocument()) { throw new CmisInvalidArgumentException("Object is not a document!"); } final NodeRef nodeRef = info.getNodeRef(); // get the folder node ref final CMISNodeInfo folderInfo = getOrCreateFolderInfo(folderId, "Folder"); connector.checkChildObjectType(folderInfo, info.getType().getTypeId()); final QName name = QName.createQName( NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName((String) connector.getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME))); connector.getNodeService().addChild( folderInfo.getNodeRef(), nodeRef, ContentModel.ASSOC_CONTAINS, name); }
Example #16
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void removeSecondaryTypes(NodeRef nodeRef, List<String> secondaryTypes) { if(secondaryTypes != null && secondaryTypes.size() > 0) { for(String secondaryType : secondaryTypes) { TypeDefinitionWrapper type = getType(secondaryType); if (type == null) { throw new CmisInvalidArgumentException("Invalid secondaryType: " + secondaryType); } nodeService.removeAspect(nodeRef, type.getAlfrescoName()); } } }
Example #17
Source File: CmisFunctionEvaluationContext.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
@Override public String getAlfrescoPropertyName(String propertyName) { PropertyDefinitionWrapper propertyDef = cmisDictionaryService.findProperty(propertyName); if(propertyDef != null) { return propertyDef.getPropertyLuceneBuilder().getLuceneFieldName().substring(1); } else { throw new CmisInvalidArgumentException("Unknown column/property " + propertyName); } }
Example #18
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void addSecondaryTypes(NodeRef nodeRef, List<String> secondaryTypes) { if(secondaryTypes != null && secondaryTypes.size() > 0) { for(String secondaryType : secondaryTypes) { TypeDefinitionWrapper type = getType(secondaryType); if (type == null) { throw new CmisInvalidArgumentException("Invalid secondaryType: " + secondaryType); } nodeService.addAspect(nodeRef, type.getAlfrescoName(), null); } } }
Example #19
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Throws an exception if the given ids are all {@code null} or empty. */ protected void checkIds(String name, String... ids) { for (String id : ids) { if (id != null && id.length() > 0) { return; } } throw new CmisInvalidArgumentException(name + " must be set!"); }
Example #20
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Throws an exception if the given holder or id is {@code null} or empty. */ protected void checkHolderId(String name, Holder<String> holder) { if (holder == null) { throw new CmisInvalidArgumentException(name + " must be set!"); } checkId(name, holder.getValue()); }
Example #21
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Throws an exception if the given path is {@code null} or invalid. */ protected void checkPath(String name, String path) { if (path == null) { throw new CmisInvalidArgumentException(name + " must be set!"); } if (path.length() == 0) { throw new CmisInvalidArgumentException(name + " must not be empty!"); } if (path.charAt(0) != '/') { throw new CmisInvalidArgumentException(name + " must start with '/'!"); } }
Example #22
Source File: AlfrescoCmisServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public FailedToDeleteData deleteTree( String repositoryId, String folderId, Boolean allVersions, UnfileObject unfileObjects, final Boolean continueOnFailure, ExtensionsData extension) { checkRepositoryId(repositoryId); if (!allVersions) { throw new CmisInvalidArgumentException("Only allVersions=true supported!"); } if (unfileObjects == UnfileObject.UNFILE) { throw new CmisInvalidArgumentException("Unfiling not supported!"); } final NodeRef folderNodeRef = getOrCreateFolderInfo(folderId, "Folder").getNodeRef(); final FailedToDeleteDataImpl result = new FailedToDeleteDataImpl(); try { connector.deleteNode(folderNodeRef, true); } catch (Exception e) { List<String> ids = new ArrayList<String>(); ids.add(folderId); result.setIds(ids); } return result; }
Example #23
Source File: ObjectTypeIdLuceneBuilder.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
@Override public <Q, S, E extends Throwable> Q buildLuceneGreaterThanOrEquals(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws E { throw new CmisInvalidArgumentException("Property " + PropertyIds.OBJECT_TYPE_ID + " can not be used in a 'greater than or equals' comparison"); }
Example #24
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Throws an exception if the given query statement is {@code null} or * empty. */ protected void checkQueryStatement(String statement) { if (statement == null) { throw new CmisInvalidArgumentException("Statement must be set!"); } if (statement.length() == 0) { throw new CmisInvalidArgumentException("Statement must not be empty!"); } }
Example #25
Source File: CMISLexer.java From alfresco-data-model with GNU Lesser General Public License v3.0 | 5 votes |
public Token nextToken() { while (true) { state.token = null; state.channel = Token.DEFAULT_CHANNEL; state.tokenStartCharIndex = input.index(); state.tokenStartCharPositionInLine = input.getCharPositionInLine(); state.tokenStartLine = input.getLine(); state.text = null; if ( input.LA(1)==CharStream.EOF ) { return getEOFToken(); } try { mTokens(); if ( state.token==null ) { emit(); } else if ( state.token==Token.SKIP_TOKEN ) { continue; } return state.token; } catch (RecognitionException re) { throw new CmisInvalidArgumentException(getErrorString(re), re); } } }
Example #26
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Throws an exception if the given list is {@code null} or empty. */ protected void checkList(String name, List<?> list) { if (list == null) { throw new CmisInvalidArgumentException(name + " must be set!"); } if (list.isEmpty()) { throw new CmisInvalidArgumentException(name + " must not be empty!"); } }
Example #27
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns the default maxItems if {@code maxItems} == {@code null}, throws * an exception if {@code maxItems} < 0, returns {@code maxItems} * otherwise. */ protected BigInteger getTypesMaxItems(BigInteger maxItems) { if (maxItems == null) { return defaultTypesMaxItems; } if (maxItems.compareTo(BigInteger.ZERO) == -1) { throw new CmisInvalidArgumentException("maxItems must not be negative!"); } return maxItems; }
Example #28
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns the default maxItems if {@code maxItems} == {@code null}, throws * an exception if {@code maxItems} < 0, returns {@code maxItems} * otherwise. */ protected BigInteger getMaxItems(BigInteger maxItems) { if (maxItems == null) { return defaultMaxItems; } if (maxItems.compareTo(BigInteger.ZERO) == -1) { throw new CmisInvalidArgumentException("maxItems must not be negative!"); } return maxItems; }
Example #29
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns 0 if {@code skipCount} == {@code null}, throws an exception if * {@code skipCount} < 0, returns {@code skipCount} otherwise. */ protected BigInteger getSkipCount(BigInteger skipCount) { if (skipCount == null) { return BigInteger.ZERO; } if (skipCount.compareTo(BigInteger.ZERO) == -1) { throw new CmisInvalidArgumentException("skipCount must not be negative!"); } return skipCount; }
Example #30
Source File: ConformanceCmisServiceWrapper.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Throws an exception if the given value is negative. */ protected void checkNullOrPositive(String name, BigInteger value) { if (value == null) { return; } if (value.compareTo(BigInteger.ZERO) == -1) { throw new CmisInvalidArgumentException(name + " must not be negative!"); } }