/** * 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!"); } }
/** * 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!"); } }
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!"); } }
public void checkIfFolder(String what) { checkIfUseful(what); if (objecVariant != CMISObjectVariant.FOLDER) { throw new CmisInvalidArgumentException(what + " is not a folder!"); } }
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!"); } }
/** * See CMIS 1.0 section 2.2.3.4 getFolderParent */ public ObjectData getFolderParent(String folderId, String filter, ObjectInfoHandler objectInfos, boolean requiresObjectInfo) { List<ObjectParentData> parents = getObjectParents(folderId, filter, false, false, objectInfos, requiresObjectInfo); if (parents.isEmpty()) { throw new CmisInvalidArgumentException("The root folder has no parent!"); } return parents.get(0).getObject(); }
public DateTimeFormat getDateTimeFormatParameter(HttpServletRequest request) { String s = getStringParameter(request, Constants.PARAM_DATETIME_FORMAT); if (s == null) { return DateTimeFormat.SIMPLE; } try { return DateTimeFormat.fromValue(s.trim().toLowerCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { throw new CmisInvalidArgumentException("Invalid value for parameter " + Constants.PARAM_DATETIME_FORMAT + "!"); } }
protected void handleExtension(XmlPullParser parser, ExtensionsData extData) throws XmlPullParserException { List<CmisExtensionElement> extensions = extData.getExtensions(); if (extensions == null) { extensions = new ArrayList<CmisExtensionElement>(); extData.setExtensions(extensions); } if (extensions.size() + 1 > XMLConstraints.MAX_EXTENSIONS_WIDTH) { throw new CmisInvalidArgumentException("Too many extensions!"); } extensions.add(handleExtensionLevel(parser, 0)); }
protected GregorianCalendar readDateTime(final XMLStreamReader parser) throws XMLStreamException { assert parser != null; String value = readText(parser); GregorianCalendar result = DateTimeHelper.parseXmlDateTime(value); if (result == null) { throw new CmisInvalidArgumentException("Invalid datetime value!"); } return result; }
/** * 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()); }