/** * Throws an exception if the given properties set is {@code null}. */ protected void checkProperties(Properties properties) { if (properties == null) { throw new CmisInvalidArgumentException("Properties must be set!"); } }
private void addFieldBytes(int len) { fieldBytes += len; if (fieldBytes > MAX_FIELD_BYTES) { throw new CmisInvalidArgumentException("Limit exceeded!"); } }
private void checkLength() throws IOException { if (counter > max) { throw new CmisInvalidArgumentException("Limit exceeded!"); } }
/** * Throws an exception if the given content object is {@code null}. */ protected void checkContentStream(ContentStream content) { if (content == null) { throw new CmisInvalidArgumentException("Content must be set!"); } }
/** * Throws an exception if the given type definition is {@code null}. */ protected void checkTypeDefinition(TypeDefinition typeDef) { if (typeDef == null) { throw new CmisInvalidArgumentException("Type definition must be set!"); } }
/** * 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!"); } }
/** * 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!"); } }
/** * 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!"); } }
/** * 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!"); } }
/** * 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!"); }
/** * 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; }
public String getObjectTypeIdProperty(Properties properties) { String objectTypeId = getIdProperty(properties, PropertyIds.OBJECT_TYPE_ID); if ((objectTypeId == null) || (objectTypeId.trim().length() == 0)) { throw new CmisInvalidArgumentException("Property " + PropertyIds.OBJECT_TYPE_ID + " must be set!"); } return objectTypeId; }
public String getSourceIdProperty(Properties properties) { String id = getIdProperty(properties, PropertyIds.SOURCE_ID); if ((id == null) || (id.trim().length() == 0)) { throw new CmisInvalidArgumentException("Property " + PropertyIds.SOURCE_ID + " must be set!"); } return id; }
protected Boolean readBoolean(final XMLStreamReader parser) throws XMLStreamException { assert parser != null; String value = readText(parser); if ("true".equals(value) || "1".equals(value)) { return Boolean.TRUE; } if ("false".equals(value) || "0".equals(value)) { return Boolean.FALSE; } throw new CmisInvalidArgumentException("Invalid boolean value!"); }
protected BigDecimal readDecimal(final XMLStreamReader parser) throws XMLStreamException { assert parser != null; String value = readText(parser); try { return new BigDecimal(value); } catch (NumberFormatException e) { throw new CmisInvalidArgumentException("Invalid decimal value!", e); } }
/** * Gets a link from the cache. */ protected String getLink(String repositoryId, String id, String rel, String type) { if (repositoryId == null) { throw new CmisInvalidArgumentException("Repository ID must be set!"); } if (id == null) { throw new CmisInvalidArgumentException("Object ID must be set!"); } return getLinkCache().getLink(repositoryId, id, rel, type); }
/** * Gets a type link from the cache. */ protected String getTypeLink(String repositoryId, String typeId, String rel, String type) { if (repositoryId == null) { throw new CmisInvalidArgumentException("Repository ID must be set!"); } if (typeId == null) { throw new CmisInvalidArgumentException("Type ID must be set!"); } return getLinkCache().getTypeLink(repositoryId, typeId, rel, type); }
public static void validateRequiredSystemProperties(Properties properties) { if (properties == null || properties.getProperties() == null) { throw new CmisInvalidArgumentException("Cannot create object, no properties are given"); } if (!properties.getProperties().containsKey(PropertyIds.OBJECT_TYPE_ID)) { throw new CmisInvalidArgumentException("Cannot create object, type id is missing"); } }
/** * Gets a link from the cache. */ protected String getLink(String repositoryId, String id, String rel, String type) { if (repositoryId == null) { throw new CmisInvalidArgumentException("Repository id must be set!"); } if (id == null) { throw new CmisInvalidArgumentException("Object id must be set!"); } return getLinkCache().getLink(repositoryId, id, rel, type); }
private static void checkCreateProperties(Properties properties) { if (properties == null || properties.getProperties() == null) { throw new CmisInvalidArgumentException("Properties must be set!"); } if (!properties.getProperties().containsKey(PropertyIds.OBJECT_TYPE_ID)) { throw new CmisInvalidArgumentException("Property " + PropertyIds.OBJECT_TYPE_ID + " must be set!"); } if (properties.getProperties().containsKey(PropertyIds.OBJECT_ID)) { throw new CmisInvalidArgumentException("Property " + PropertyIds.OBJECT_ID + " must not be set!"); } }