/** * Sets the current project to the provided project name.<p> * * @param name the project name to set * @return the project set * @throws Exception if something goes wrong */ public CmsProject setCurrentProject(String name) throws Exception { return m_cms.getRequestContext().setCurrentProject(m_cms.readProject(name)); }
/** * Delegate method for {@link CmsObject#getSitePath(CmsResource)}.<p> * * @see CmsObject#getSitePath(org.opencms.file.CmsResource) * * @param resource the resource to get the adjusted site root path for * * @return the absolute resource path adjusted for the current site */ public String getSitePath(CmsResource resource) { return m_cms.getSitePath(resource); }
/** * @see org.opencms.file.wrapper.I_CmsResourceWrapper#readFile(org.opencms.file.CmsObject, java.lang.String, org.opencms.file.CmsResourceFilter) */ public CmsFile readFile(CmsObject cms, String resourcename, CmsResourceFilter filter) throws CmsException { if (m_isWrappedResource) { return cms.readFile(resourcename, filter); } return null; }
/** * Returns the manager group of a project.<p> * * @param project the id of the project to return the manager group for * @return the manager group of the project * @throws Exception if something goes wrong */ public CmsGroup readManagerGroup(CmsUUID project) throws Exception { return m_cms.readManagerGroup(m_cms.readProject(project)); }
/** * Deletes a resource.<p> * * @param name the name of the resource to delete * * @throws Exception if something goes wrong */ public void deleteResource(String name) throws Exception { m_cms.lockResource(name); m_cms.deleteResource(name, CmsResource.DELETE_PRESERVE_SIBLINGS); }
/** * Returns the owner of a project.<p> * * @param project the id of the project * @return the owner of the project * @throws Exception if something goes wrong */ public CmsUser readOwnerOfProject(CmsUUID project) throws Exception { return m_cms.readOwner(m_cms.readProject(project)); }
/** * Constructor, setting the user to the current user from the context.<p> * * @param cms the current users context */ public CmsVisitedByFilter(CmsObject cms) { this(); m_user = cms.getRequestContext().getCurrentUser(); }
/** The dialog mode. */ public static enum DialogMode { /** Allow copy only. */ copy, /** Allow copy and move. */ copy_and_move, /** Allow move only. */ move }
/** * @see org.opencms.file.wrapper.A_CmsResourceWrapper#lockResource(org.opencms.file.CmsObject, java.lang.String) */ @Override public boolean lockResource(CmsObject cms, String resourcename) throws CmsException { CmsResource res = getResource(cms, resourcename, CmsResourceFilter.DEFAULT); if (res != null) { cms.lockResource(cms.getRequestContext().removeSiteRoot(res.getRootPath())); return true; } return false; }
/** * Checks if the published resource is inside the time window set with release and expiration date.<p> * * @param resource the published resource to check * @return true if the published resource is inside the time window, otherwise false */ protected boolean isResourceInTimeWindow(CmsPublishedResource resource) { return m_cms.existsResource( m_cms.getRequestContext().removeSiteRoot(resource.getRootPath()), CmsResourceFilter.DEFAULT); }
/** * @see org.opencms.file.wrapper.I_CmsResourceWrapper#readResource(org.opencms.file.CmsObject, java.lang.String, org.opencms.file.CmsResourceFilter) */ public CmsResource readResource(CmsObject cms, String resourcename, CmsResourceFilter filter) throws CmsException { if (m_isWrappedResource) { return cms.readResource(resourcename, filter); } return null; }
/** * @see org.opencms.ui.contextmenu.I_CmsHasMenuItemVisibility#getVisibility(org.opencms.file.CmsObject, java.util.List) */ public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, List<CmsResource> resources) { boolean visible = ((resources == null) || resources.isEmpty()) && cms.existsResource(CmsWorkplace.JSP_WORKPLACE_URI); return visible ? CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE : CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE; } }
/** * @see org.opencms.file.wrapper.A_CmsResourceWrapper#unlockResource(org.opencms.file.CmsObject, java.lang.String) */ @Override public boolean unlockResource(CmsObject cms, String resourcename) throws CmsException { CmsResource res = getResource(cms, resourcename, CmsResourceFilter.DEFAULT); if (res != null) { cms.unlockResource(cms.getRequestContext().removeSiteRoot(res.getRootPath())); return true; } return false; }
/** * @see org.opencms.workplace.tools.accounts.A_CmsUsersList#readUser(java.lang.String) */ @Override protected CmsUser readUser(String name) throws CmsException { return getCms().readUser(name); }
/** * Rewrites the content of the given file.<p> * * @param resource the resource to rewrite the content for * * @throws CmsException if something goes wrong */ private static void hardTouch(CmsObject cms, CmsResource resource) throws CmsException { CmsFile file = cms.readFile(resource); file.setContents(file.getContents()); cms.writeFile(file); }
/** * @see org.opencms.ui.dialogs.permissions.CmsPermissionView.PermissionChangeHandler#setPermissions(java.lang.String, java.lang.String, int, int, int) */ public void setPermissions(String principalType, String principalName, int allowed, int denied, int flags) { try { ensureLock(); m_cms.chacc(m_cms.getSitePath(m_resource), principalType, principalName, allowed, denied, flags); } catch (CmsException e) { m_context.error(e); } }
/** * Unlocks a resource.<p> * * @param resourcename the name of the resource to unlock (full current site relative path) * * @throws CmsException if something goes wrong */ public void unlockResource(String resourcename) throws CmsException { CmsResource resource = readResource(resourcename, CmsResourceFilter.ALL); getResourceType(resource).unlockResource(this, m_securityManager, resource); }
/** * @see org.opencms.ui.dialogs.permissions.CmsPermissionView.PermissionChangeHandler#deletePermissionSet(java.lang.String, java.lang.String) */ public void deletePermissionSet(String principalType, String principalName) { try { ensureLock(); m_cms.rmacc(m_cms.getSitePath(m_resource), principalType, principalName); refreshOwnEntries(); } catch (CmsException e) { m_context.error(e); } }
/** * Locks a resource.<p> * * This will be an exclusive, persistent lock that is removed only if the user unlocks it.<p> * * @param resourcename the name of the resource to lock (full current site relative path) * * @throws CmsException if something goes wrong */ public void lockResource(String resourcename) throws CmsException { lockResource(resourcename, CmsLockType.EXCLUSIVE); }
/** * Deletes a project by name.<p> * * @param name the name of the project to delete * @throws Exception if something goes wrong * * @see CmsObject#deleteProject(CmsUUID) */ public void deleteProject(String name) throws Exception { m_cms.deleteProject(m_cms.readProject(name).getUuid()); }