/** * Gets the CSS style name for the given resource state.<p> * * @param state the resource state * @return the CSS style name */ public static String getStateStyle(CmsResourceState state) { String stateStyle = ""; if (state != null) { if (state.isDeleted()) { stateStyle = OpenCmsTheme.STATE_DELETED; } else if (state.isNew()) { stateStyle = OpenCmsTheme.STATE_NEW; } else if (state.isChanged()) { stateStyle = OpenCmsTheme.STATE_CHANGED; } } return stateStyle; }
/** * Adds a given published resource to the provided search index update data.<p> * * This method decides if the resource has to be included in the "update" or "delete" list.<p> * * @param pubRes the published resource to add * @param updateData the search index update data to add the resource to */ protected void addResourceToUpdateData(CmsPublishedResource pubRes, CmsSearchIndexUpdateData updateData) { if (pubRes.getState().isDeleted()) { // deleted resource just needs to be removed updateData.addResourceToDelete(pubRes); } else if (pubRes.getState().isNew() || pubRes.getState().isChanged() || pubRes.getState().isUnchanged()) { updateData.addResourceToUpdate(pubRes); } }
/** * Reads all resources of a project that match a given state from the VFS.<p> * * * @param projectId the id of the project to read the file resources for * @param state the resource state to match * * @return all <code>{@link CmsResource}</code>s of a project that match a given criteria from the VFS * * @throws CmsException if something goes wrong * * @deprecated use {@link #readProjectView(CmsUUID, CmsResourceState)} instead */ public List readProjectView(int projectId, int state) throws CmsException { return readProjectView(m_securityManager.getProjectId(m_context, projectId), CmsResourceState.valueOf(state)); }
/** * Gets all structure ids for which published resources of both states 'new' and 'deleted' exist in the given list.<p> * * @param publishedResources a list of published resources * * @return the set of structure ids that satisfy the condition above */ private Set<CmsUUID> getIdsOfPublishResourcesWhichAreBothNewAndDeleted( List<CmsPublishedResource> publishedResources) { Set<CmsUUID> result = new HashSet<CmsUUID>(); Set<CmsUUID> deletedSet = new HashSet<CmsUUID>(); for (CmsPublishedResource pubRes : publishedResources) { if (pubRes.getState().isNew()) { result.add(pubRes.getStructureId()); } if (pubRes.getState().isDeleted()) { deletedSet.add(pubRes.getStructureId()); } } result.retainAll(deletedSet); return result; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#getVisibility(org.opencms.file.CmsObject, CmsResourceUtil[]) */ @Override public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].getResource().getState().isDeleted()) { return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE; } else if (resourceUtil[0].getResource().getState().isNew() || (resourceUtil[0].getResource().isFile() && resourceUtil[0].getResource().getState().isUnchanged())) { return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE.addMessageKey(Messages.GUI_CONTEXTMENU_TITLE_INACTIVE_NEW_UNCHANGED_0); } try { if (!resourceUtil[0].isEditable() || !cms.hasPermissions( resourceUtil[0].getResource(), CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.ALL)) { return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE.addMessageKey(Messages.GUI_CONTEXTMENU_TITLE_INACTIVE_PERM_WRITE_0); } } catch (CmsException e) { // error checking permissions, disable entry completely return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE; } return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE; }
String parentFolderName = CmsResource.getParentFolder(resource.getRootPath()); CmsFolder parentFolder = m_driverManager.getVfsDriver().readFolder(dbc, projectId, parentFolderName); if (parentFolder.getState().isDeleted()) { throw new CmsDbEntryNotFoundException(Messages.get().container( Messages.ERR_PARENT_FOLDER_DELETED_1, resourcePath, true); if (existingResource.getState().isDeleted()) { stmt.setString(2, resource.getResourceId().toString()); stmt.setString(3, resourcePath); stmt.setInt(4, newState.getState()); stmt.setLong(5, resource.getDateReleased()); stmt.setLong(6, resource.getDateExpired()); stmt.setLong(6, dateModified); stmt.setString(7, resource.getUserLastModified().toString()); stmt.setInt(8, newState.getState()); stmt.setInt(9, resource.getLength()); stmt.setLong(10, dateContent); if ((content != null) || !resource.getState().isKeep()) { CmsUUID projLastMod = projectId; CmsResourceState state = CmsResource.STATE_CHANGED; stmt.setLong(3, dateModified); stmt.setString(4, resource.getUserLastModified().toString()); stmt.setInt(5, state.getState());
/** * Check if deleted resources should be filtered.<p> * * @return true if deleted resources should be included, false otherwise */ public boolean includeDeleted() { return (m_filterState == IGNORED) || ((m_filterState == REQUIRED) && m_state.isDeleted()) || ((m_filterState == EXCLUDED) && !m_state.isDeleted()); }
/** * Checks if the resource is unchanged *and* should be removed.<p> * * @param item the resource to check * @return true if the resource is unchanged and should be removed */ private boolean isUnchangedAndShouldBeRemoved(CmsResource item) { if (item.getState().isUnchanged()) { return !m_keepOriginalUnchangedResources || !m_originalResources.contains(item); } return false; }
/** * @see java.lang.Object#toString() */ @Override public String toString() { return String.valueOf(getState()); } }
if (!resource.getState().isUnchanged() && !resource.getState().isKeep()) {
/** * Checks if all the resource states from a list of resources are 'new'.<p> * * @param projectResources the resources to check * @return true if all the resources from the input list have the state 'new' */ private boolean hasOnlyNewResources(List<CmsResource> projectResources) { boolean hasOnlyNewResources = true; for (CmsResource projectRes : projectResources) { if (!projectRes.getState().isNew()) { hasOnlyNewResources = false; break; } } return hasOnlyNewResources; }
/** * Internal method to get the moved folders from the publish list.<p> * * @param cms the current CMS context * @return the list of moved folders from the publish list * @throws CmsException if something goes wrong */ protected List<CmsResource> getMovedFolders(CmsObject cms) throws CmsException { CmsProject onlineProject = cms.readProject(CmsProject.ONLINE_PROJECT_ID); List<CmsResource> movedFolders = new ArrayList<CmsResource>(); for (CmsResource folder : m_folderList) { if (folder.getState().isChanged()) { CmsProject oldProject = cms.getRequestContext().getCurrentProject(); boolean isMoved = false; try { cms.getRequestContext().setCurrentProject(onlineProject); CmsResource onlineResource = cms.readResource(folder.getStructureId()); isMoved = !onlineResource.getRootPath().equals(folder.getRootPath()); } catch (CmsVfsResourceNotFoundException e) { // resource not found online, this means it doesn't matter whether it has been moved } finally { cms.getRequestContext().setCurrentProject(oldProject); } if (isMoved) { movedFolders.add(folder); } } } return movedFolders; }
/** * Returns if this is {@link CmsResource#STATE_KEEP}.<p> * * @return if this is {@link CmsResource#STATE_KEEP} */ public boolean isKeep() { return (equals(CmsResource.STATE_KEEP)); }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#getVisibility(org.opencms.file.CmsObject, CmsResourceUtil[]) */ @Override public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].getStateAbbreviation() == CmsResourceState.STATE_DELETED.getAbbreviation()) { return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE; } return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE; }
/** * @see org.opencms.workplace.explorer.menu.I_CmsMenuItemRule#getVisibility(org.opencms.file.CmsObject, CmsResourceUtil[]) */ @Override public CmsMenuItemVisibilityMode getVisibility(CmsObject cms, CmsResourceUtil[] resourceUtil) { if (resourceUtil[0].getResource().getState().isDeleted()) { return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE; } else if (resourceUtil[0].getResource().getState().isNew() || (resourceUtil[0].getResource().isFile() && resourceUtil[0].getResource().getState().isUnchanged())) { return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE.addMessageKey( Messages.GUI_CONTEXTMENU_TITLE_INACTIVE_NEW_UNCHANGED_0); } try { if (!resourceUtil[0].isEditable() || !cms.hasPermissions( resourceUtil[0].getResource(), CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.ALL)) { return CmsMenuItemVisibilityMode.VISIBILITY_INACTIVE.addMessageKey( Messages.GUI_CONTEXTMENU_TITLE_INACTIVE_PERM_WRITE_0); } } catch (CmsException e) { // error checking permissions, disable entry completely return CmsMenuItemVisibilityMode.VISIBILITY_INVISIBLE; } return CmsMenuItemVisibilityMode.VISIBILITY_ACTIVE; }
String parentFolderName = CmsResource.getParentFolder(resource.getRootPath()); CmsFolder parentFolder = m_driverManager.getVfsDriver(dbc).readFolder(dbc, projectId, parentFolderName); if (parentFolder.getState().isDeleted()) { throw new CmsDbEntryNotFoundException( Messages.get().container(Messages.ERR_PARENT_FOLDER_DELETED_1, resource.getRootPath())); resourcePath, true); if (existingResource.getState().isDeleted()) { stmt.setString(2, resource.getResourceId().toString()); stmt.setString(3, resourcePath); stmt.setInt(4, newState.getState()); stmt.setLong(5, resource.getDateReleased()); stmt.setLong(6, resource.getDateExpired()); stmt.setLong(6, dateModified); stmt.setString(7, resource.getUserLastModified().toString()); stmt.setInt(8, newState.getState()); stmt.setInt(9, resource.getLength()); stmt.setLong(10, dateContent); if ((content != null) || !resource.getState().isKeep()) { CmsUUID projLastMod = projectId; CmsResourceState state = CmsResource.STATE_CHANGED; stmt.setLong(3, dateModified); stmt.setString(4, resource.getUserLastModified().toString()); stmt.setInt(5, state.getState());
/** * Returns the resource state including move operation information.<p> * * @return the resource state including move operation information */ public CmsResourceState getMovedState() { if (!m_isMoved) { return getState(); } else if (getState().isDeleted()) { return STATE_MOVED_SOURCE; } else if (getState().isNew()) { return STATE_MOVED_DESTINATION; } else { // should never happen return getState(); } }
/** * Check if deleted resources should be filtered.<p> * * @return true if deleted resources should be included, false otherwise */ public boolean includeDeleted() { return (m_filterState == IGNORED) || ((m_filterState == REQUIRED) && m_state.isDeleted()) || ((m_filterState == EXCLUDED) && !m_state.isDeleted()); }