/** * Stores a value in this users "additional information" storage map with the given access key.<p> * * @param key the key to store the value under * @param value the value to store in the users "additional information" storage map * * @see #getAdditionalInfo() */ public void setAdditionalInfo(String key, Object value) { if (key == null) { throw new CmsIllegalArgumentException( Messages.get().container(Messages.ERR_USER_ADDINFO_KEY_NULL_1, getFullName())); } m_additionalInfo.put(key, value); }
/** * Checks if the provided property name is a valid property name, * that is contains only valid characters.<p> * * A property name can only be composed of digits, * standard ASCII letters and the symbols defined in {@link #NAME_CONSTRAINTS}.<p> * * @param name the property name to check * * @throws CmsIllegalArgumentException if the given property name is not valid */ public static void checkPropertyName(String name) throws CmsIllegalArgumentException { if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_BAD_PROPERTYNAME_EMPTY_0, name)); } CmsStringUtil.checkName(name, NAME_CONSTRAINTS, Messages.ERR_BAD_PROPERTYNAME_4, Messages.get()); }
/** * Checks if the provided property name is a valid property name, * that is contains only valid characters.<p> * * A property name can only be composed of digits, * standard ASCII letters and the symbols defined in {@link #NAME_CONSTRAINTS}.<p> * * @param name the property name to check * * @throws CmsIllegalArgumentException if the given property name is not valid */ public static void checkPropertyName(String name) throws CmsIllegalArgumentException { if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) { throw new CmsIllegalArgumentException( Messages.get().container(Messages.ERR_BAD_PROPERTYNAME_EMPTY_0, name)); } CmsStringUtil.checkName(name, NAME_CONSTRAINTS, Messages.ERR_BAD_PROPERTYNAME_4, Messages.get()); }
/** * Throws a runtime exception if name is empty.<p> * * @param name the project name to check */ public static void checkProjectName(String name) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_PROJECTNAME_VALIDATION_0)); } }
/** * Saves the current site root.<p> * * @throws RuntimeException in case there is already a site root saved * * @deprecated store the current site root locally before switching * to another site, and set it back again at the end, like: * <pre> * String storedSite = context.getSiteRoot(); * try { * context.setSiteRoot(""); * // do something with the context * } finally { * context.setSiteRoot(storedSite); * } * </pre> */ public void saveSiteRoot() throws RuntimeException { if (m_savedSiteRoot != null) { throw new CmsRuntimeException(Messages.get().container(Messages.ERR_NONEMPTY_SITEROOT_1, m_savedSiteRoot)); } m_savedSiteRoot = m_siteRoot; }
/** * Checks if this property is frozen, that is read only.<p> */ private void checkFrozen() { if (m_frozen) { throw new CmsRuntimeException(Messages.get().container(Messages.ERR_PROPERTY_FROZEN_1, toString())); } }
/** * Throws a runtime exception if name is empty.<p> * * @param name the project name to check */ public static void checkProjectName(String name) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) { throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_PROJECTNAME_VALIDATION_0)); } }
/** * Returns <code>true</code> if the given resource type id describes a folder type.<p> * * @param typeId the resource type id to check * * @return true if the given resource type id describes a folder type or false if it is no folder or an unknown type. */ public static final boolean isFolderType(int typeId) { try { return OpenCms.getResourceManager().getResourceType(typeId).isFolder(); } catch (CmsLoaderException e) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.ERR_UNKNOWN_RESOURCE_TYPE_1, new Integer(typeId)), e); } } return false; }
/** * Checks if this property is frozen, that is read only.<p> */ private void checkFrozen() { if (m_frozen) { throw new CmsRuntimeException(Messages.get().container(Messages.ERR_PROPERTY_FROZEN_1, toString())); } }
/** * Restores the saved site root.<p> * * @throws RuntimeException in case there is no site root saved * * @deprecated store the current site root locally before switching * to another site, and set it back again at the end, like: * <pre> * String storedSite = context.getSiteRoot(); * try { * context.setSiteRoot(""); * // do something with the context * } finally { * context.setSiteRoot(storedSite); * } * </pre> */ public void restoreSiteRoot() throws RuntimeException { if (m_savedSiteRoot == null) { throw new CmsRuntimeException(Messages.get().container(Messages.ERR_EMPTY_SITEROOT_0)); } m_siteRoot = m_savedSiteRoot; m_savedSiteRoot = null; }
/** * Returns <code>true</code> if the given resource type id describes a folder type.<p> * * @param typeId the resource type id to check * * @return true if the given resource type id describes a folder type or false if it is no folder or an unknown type. */ public static final boolean isFolderType(int typeId) { try { return OpenCms.getResourceManager().getResourceType(typeId).isFolder(); } catch (CmsLoaderException e) { if (LOG.isWarnEnabled()) { LOG.warn(Messages.get().getBundle().key(Messages.ERR_UNKNOWN_RESOURCE_TYPE_1, new Integer(typeId)), e); } } return false; }
/** * Sets the organizational unit fully qualified name.<p> * * @param ouFqn the organizational unit fully qualified name */ public void setOuFqn(String ouFqn) { String userOu = CmsOrganizationalUnit.getParentFqn(m_user.getName()); if (ouFqn != null) { if (ouFqn.startsWith(userOu) || (ouFqn.startsWith(CmsOrganizationalUnit.SEPARATOR) && ouFqn.substring(1).startsWith(userOu))) { m_ouFqn = ouFqn; } else { throw new CmsIllegalArgumentException( Messages.get().container(Messages.ERR_BAD_ORGUNIT_2, ouFqn, userOu)); } } else { m_ouFqn = userOu; } m_ouFqn = CmsOrganizationalUnit.removeLeadingSeparator(m_ouFqn); }
/** * Sets the organizational unit fully qualified name.<p> * * @param ouFqn the organizational unit fully qualified name */ public void setOuFqn(String ouFqn) { String userOu = CmsOrganizationalUnit.getParentFqn(m_user.getName()); if (ouFqn != null) { if (ouFqn.startsWith(userOu) || (ouFqn.startsWith(CmsOrganizationalUnit.SEPARATOR) && ouFqn.substring(1).startsWith(userOu))) { m_ouFqn = ouFqn; } else { throw new CmsIllegalArgumentException(Messages.get().container( Messages.ERR_BAD_ORGUNIT_2, ouFqn, userOu)); } } else { m_ouFqn = userOu; } m_ouFqn = CmsOrganizationalUnit.removeLeadingSeparator(m_ouFqn); }
throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_BAD_RESOURCENAME_EMPTY_0, name)); CmsStringUtil.checkName(name, NAME_CONSTRAINTS, Messages.ERR_BAD_RESOURCENAME_4, Messages.get()); throw new CmsIllegalArgumentException(Messages.get().container( Messages.ERR_BAD_RESOURCENAME_DOTS_1, lastName));
/** * Checks that the target path is not a subfolder of the source path.<p> * * @param source the source path * @param target the target path */ protected void checkNotSubPath(String source, String target) { source = CmsStringUtil.joinPaths("/", source, "/"); target = CmsStringUtil.joinPaths("/", target, "/"); if (target.startsWith(source)) { throw new CmsIllegalArgumentException( org.opencms.file.Messages.get().container( org.opencms.file.Messages.ERR_REWRITE_LINKS_ROOTS_DEPENDENT_2, source, target)); } }
/** * Checks if the project in the given database context is not the "Online" project, * and throws an Exception if this is the case.<p> * * This is used to ensure a user is in an "Offline" project * before write access to VFS resources is granted.<p> * * @param dbc the current OpenCms users database context * * @throws CmsVfsException if the project in the given database context is the "Online" project */ public void checkOfflineProject(CmsDbContext dbc) throws CmsVfsException { if (dbc.currentProject().isOnlineProject()) { throw new CmsVfsException( org.opencms.file.Messages.get().container( org.opencms.file.Messages.ERR_NOT_ALLOWED_IN_ONLINE_PROJECT_0)); } }
/** * Checks if the project in the given database context is not the "Online" project, * and throws an Exception if this is the case.<p> * * This is used to ensure a user is in an "Offline" project * before write access to VFS resources is granted.<p> * * @param dbc the current OpenCms users database context * * @throws CmsVfsException if the project in the given database context is the "Online" project */ public void checkOfflineProject(CmsDbContext dbc) throws CmsVfsException { if (dbc.currentProject().isOnlineProject()) { throw new CmsVfsException(org.opencms.file.Messages.get().container( org.opencms.file.Messages.ERR_NOT_ALLOWED_IN_ONLINE_PROJECT_0)); } }
/** * Returns <code>true</code> if the given resource type name describes a folder type.<p> * * @param typeName the resource type name to check * * @return true if the given resource type name describes a folder type */ public static final boolean isFolderType(String typeName) { try { return OpenCms.getResourceManager().getResourceType(typeName).isFolder(); } catch (CmsLoaderException e) { throw new CmsIllegalArgumentException( Messages.get().container(Messages.ERR_UNKNOWN_RESOURCE_TYPE_1, typeName), e); } }
/** * Returns <code>true</code> if the given resource type name describes a folder type.<p> * * @param typeName the resource type name to check * * @return true if the given resource type name describes a folder type */ public static final boolean isFolderType(String typeName) { try { return OpenCms.getResourceManager().getResourceType(typeName).isFolder(); } catch (CmsLoaderException e) { throw new CmsIllegalArgumentException(Messages.get().container( Messages.ERR_UNKNOWN_RESOURCE_TYPE_1, typeName), e); } }