/** * @see org.opencms.workflow.CmsDefaultPublishResourceFormatter.I_PublishResourceValidator#findInvalidResources(java.util.Set) */ public Set<CmsResource> findInvalidResources(Set<CmsResource> input) { Set<CmsResource> result = Sets.newHashSet(); CmsUUID optionsProject = m_options.getProjectId(); for (CmsResource resource : input) { CmsUUID projectId = resource.getProjectLastModified(); if (isWorkflowProject(projectId) && ((optionsProject == null) || !projectId.equals(optionsProject))) { result.add(resource); } } return result; }
/** * @see org.opencms.workflow.CmsDefaultPublishResourceFormatter.I_PublishResourceValidator#findInvalidResources(java.util.Set) */ @SuppressWarnings("synthetic-access") public Set<CmsResource> findInvalidResources(Set<CmsResource> resources) { Set<CmsResource> result = new HashSet<CmsResource>(); Set<CmsUUID> projectIds = new HashSet<CmsUUID>(); try { for (CmsProject project : OpenCms.getOrgUnitManager().getAllManageableProjects(m_cms, "", true)) { projectIds.add(project.getUuid()); } } catch (CmsException e) { // should never happen LOG.error(e.getLocalizedMessage(), e); } for (CmsResource resource : resources) { try { if (!projectIds.contains(resource.getProjectLastModified()) && !m_cms.hasPermissions(resource, CmsPermissionSet.ACCESS_DIRECT_PUBLISH)) { result.add(resource); } } catch (Exception e) { // error reading the permissions, should usually never happen if (LOG.isErrorEnabled()) { LOG.error(e.getLocalizedMessage(), e); } } } return result; }
/** * Returns the id of the project which the resource belongs to.<p> * * @return the id of the project which the resource belongs to */ public CmsUUID getProjectId() { CmsUUID projectId = m_resource.getProjectLastModified(); if (!getLock().isUnlocked() && !getLock().isInherited()) { // use lock project ID only if lock is not inherited projectId = getLock().getProjectId(); } return projectId; }
/** * Returns the id of the project which the resource belongs to.<p> * * @return the id of the project which the resource belongs to */ public CmsUUID getProjectId() { CmsUUID projectId = m_resource.getProjectLastModified(); if (!getLock().isUnlocked() && !getLock().isInherited()) { // use lock project ID only if lock is not inherited projectId = getLock().getProjectId(); } return projectId; }
/** * Returns the virtual resource.<p> * * @return the virtual resource */ public CmsResource getResource() { return new CmsResource( m_base.getStructureId(), m_base.getResourceId(), m_rootPath, m_typeId, m_isFolder, m_base.getFlags(), m_base.getProjectLastModified(), m_base.getState(), m_base.getDateCreated(), m_base.getUserCreated(), m_base.getDateLastModified(), m_base.getUserLastModified(), m_base.getDateReleased(), m_base.getDateExpired(), m_base.getSiblingCount(), m_length, m_base.getDateContent(), m_base.getVersion()); }
resource.isFolder(), resource.getFlags() | FLAG_RELATED_RESOURCE, resource.getProjectLastModified(), resource.getState(), resource.getDateCreated(),
resource.isFolder(), resource.getFlags() | FLAG_RELATED_RESOURCE, resource.getProjectLastModified(), resource.getState(), resource.getDateCreated(),
/** * Constructor, creates a new CmsFolder Object from the given CmsResource.<p> * * @param resource the base resource object to create a folder from */ public CmsFolder(CmsResource resource) { this( resource.getStructureId(), resource.getResourceId(), resource.getRootPath(), resource.getTypeId(), resource.getFlags(), resource.getProjectLastModified(), resource.getState(), resource.getDateCreated(), resource.getUserCreated(), resource.getDateLastModified(), resource.getUserLastModified(), resource.getDateReleased(), resource.getDateExpired(), resource.getVersion()); }
/** * Constructor, creates a new file Object from the given resource with * an empty byte array as file content, if the resource does not * implement a file.<p> * * @param resource the base resource object to create a file from */ public CmsFile(CmsResource resource) { this( resource.getStructureId(), resource.getResourceId(), resource.getRootPath(), resource.getTypeId(), resource.getFlags(), resource.getProjectLastModified(), resource.getState(), resource.getDateCreated(), resource.getUserCreated(), resource.getDateLastModified(), resource.getUserLastModified(), resource.getDateReleased(), resource.getDateExpired(), resource.getSiblingCount(), resource.getLength(), resource.getDateContent(), resource.getVersion(), // if the resource already is a file, keep contents that might have been already read resource instanceof CmsFile ? ((CmsFile)resource).getContents() : null); }
/** * Checks if a resource is belongs to the correct project for exporting.<p> * * @param res the resource to check * * @return <code>true</code>, if the resource can be exported, false otherwise */ protected boolean isInExportableProject(CmsResource res) { boolean retValue = true; // the "only modified in current project flag" is checked if (m_parameters.isInProject()) { // resource state is new or changed if ((res.getState() == CmsResource.STATE_CHANGED) || (res.getState() == CmsResource.STATE_NEW)) { // the resource belongs not to the current project, so it must not be exported if (!res.getProjectLastModified().equals(getCms().getRequestContext().getCurrentProject().getUuid())) { retValue = false; } } else { // state is unchanged, so do not export it retValue = false; } } return retValue; }
/** * Checks if a resource is belongs to the correct project for exporting.<p> * * @param res the resource to check * * @return <code>true</code>, if the resource can be exported, false otherwise */ protected boolean isInExportableProject(CmsResource res) { boolean retValue = true; // the "only modified in current project flag" is checked if (m_parameters.isInProject()) { // resource state is new or changed if ((res.getState() == CmsResource.STATE_CHANGED) || (res.getState() == CmsResource.STATE_NEW)) { // the resource belongs not to the current project, so it must not be exported if (!res.getProjectLastModified().equals(getCms().getRequestContext().currentProject().getUuid())) { retValue = false; } } else { // state is unchanged, so do not export it retValue = false; } } return retValue; }
/** * Returns the project state of the given resource.<p> * * <ul> * <li>null: unchanged.</li> * <li>true: locked in current project.</li> * <li>false: not locked in current project.</li> * </ul> * * @return the project state of the given resource */ public CmsResourceProjectState getProjectState() { if (getResource().getState().isUnchanged()) { return STATE_CLEAN; // STATE_CLEAN } else if (getLock().getSystemLock().isPublish()) { return STATE_LOCKED_FOR_PUBLISHING; } else if (getResource().getProjectLastModified().equals(getReferenceProject().getUuid())) { return STATE_MODIFIED_IN_CURRENT_PROJECT; // STATE_MODIFIED_CURRENT_PROJECT } else { return STATE_MODIFIED_IN_OTHER_PROJECT; // STATE_MODIFIED_OTHER_PROJECT } }
/** * Returns the project state of the given resource.<p> * * <ul> * <li>null: unchanged.</li> * <li>true: locked in current project.</li> * <li>false: not locked in current project.</li> * </ul> * * @return the project state of the given resource */ public CmsResourceProjectState getProjectState() { if (getResource().getState().isUnchanged()) { return STATE_CLEAN; // STATE_CLEAN } else if (getLock().getSystemLock().isPublish()) { return STATE_LOCKED_FOR_PUBLISHING; } else if (getResource().getProjectLastModified().equals(getReferenceProject().getUuid())) { return STATE_MODIFIED_IN_CURRENT_PROJECT; // STATE_MODIFIED_CURRENT_PROJECT } else { return STATE_MODIFIED_IN_OTHER_PROJECT; // STATE_MODIFIED_OTHER_PROJECT } }
/** * Returns the id of the project in which the given resource is locked.<p> * * @return the id of the project in which the given resource is locked */ public CmsUUID getLockedInProjectId() { CmsUUID lockedInProject = null; if (getLock().isNullLock() && !getResource().getState().isUnchanged()) { // resource is unlocked and modified lockedInProject = getResource().getProjectLastModified(); } else if (!getResource().getState().isUnchanged()) { // resource is locked and modified lockedInProject = getProjectId(); } else if (!getLock().isNullLock()) { // resource is locked and unchanged lockedInProject = getLock().getProjectId(); } return lockedInProject; }
/** * Constructor, creates a new CmsFolder Object from the given CmsResource.<p> * * @param resource the base resource object to create a folder from */ public CmsFolder(CmsResource resource) { this( resource.getStructureId(), resource.getResourceId(), resource.getRootPath(), resource.getTypeId(), resource.getFlags(), resource.getProjectLastModified(), resource.getState(), resource.getDateCreated(), resource.getUserCreated(), resource.getDateLastModified(), resource.getUserLastModified(), resource.getDateReleased(), resource.getDateExpired(), resource.getVersion()); }
/** * Returns the id of the project in which the given resource is locked.<p> * * @return the id of the project in which the given resource is locked */ public CmsUUID getLockedInProjectId() { CmsUUID lockedInProject = null; if (getLock().isNullLock() && !getResource().getState().isUnchanged()) { // resource is unlocked and modified lockedInProject = getResource().getProjectLastModified(); } else if (!getResource().getState().isUnchanged()) { // resource is locked and modified lockedInProject = getProjectId(); } else if (!getLock().isNullLock()) { // resource is locked and unchanged lockedInProject = getLock().getProjectId(); } return lockedInProject; }
/** * Returns the virtual resource.<p> * * @return the virtual resource */ public CmsResource getResource() { return new CmsResource( m_base.getStructureId(), m_base.getResourceId(), m_rootPath, m_typeId, m_isFolder, m_base.getFlags(), m_base.getProjectLastModified(), m_base.getState(), m_base.getDateCreated(), m_base.getUserCreated(), m_base.getDateLastModified(), m_base.getUserLastModified(), m_base.getDateReleased(), m_base.getDateExpired(), m_base.getSiblingCount(), m_length, m_base.getDateContent(), m_base.getVersion()); }
/** * Creates a new instance.<p> * * @param cms the current CMS context * @param res the resource to wrap */ public CmsJspResourceWrapper(CmsObject cms, CmsResource res) { super( res.getStructureId(), res.getResourceId(), res.getRootPath(), res.getTypeId(), res.isFolder(), res.getFlags(), res.getProjectLastModified(), res.getState(), res.getDateCreated(), res.getUserCreated(), res.getDateLastModified(), res.getUserLastModified(), res.getDateReleased(), res.getDateExpired(), res.getSiblingCount(), res.getLength(), res.getDateContent(), res.getVersion()); m_cms = cms; }
/** * Constructor, creates a new file Object from the given resource with * an empty byte array as file content, if the resource does not * implement a file.<p> * * @param resource the base resource object to create a file from * @param doc the search document */ public CmsSearchResource(CmsResource resource, I_CmsSearchDocument doc) { this( resource.getStructureId(), resource.getResourceId(), resource.getRootPath(), resource.getTypeId(), resource.getFlags(), resource.getProjectLastModified(), resource.getState(), resource.getDateCreated(), resource.getUserCreated(), resource.getDateLastModified(), resource.getUserLastModified(), resource.getDateReleased(), resource.getDateExpired(), resource.getSiblingCount(), resource.getLength(), resource.getDateContent(), resource.getVersion(), doc); }
/** * Constructor, creates a new file Object from the given resource with * an empty byte array as file content, if the resource does not * implement a file.<p> * * @param resource the base resource object to create a file from */ public CmsFile(CmsResource resource) { this( resource.getStructureId(), resource.getResourceId(), resource.getRootPath(), resource.getTypeId(), resource.getFlags(), resource.getProjectLastModified(), resource.getState(), resource.getDateCreated(), resource.getUserCreated(), resource.getDateLastModified(), resource.getUserLastModified(), resource.getDateReleased(), resource.getDateExpired(), resource.getSiblingCount(), resource.getLength(), resource.getDateContent(), resource.getVersion(), // if the resource already is a file, keep contents that might have been already read resource instanceof CmsFile ? ((CmsFile)resource).getContents() : null); }