/** * Checks whether the selected resources have siblings.<p> * * @return whether the selected resources have siblings */ private boolean hasSiblings() { for (CmsResource res : m_context.getResources()) { if (res.getSiblingCount() > 1) { return true; } } return false; }
/** * Returns an integer representation for the link type.<p> * * <ul> * <li><code>0</code>: No sibling * <li><code>1</code>: Sibling * <li><code>2</code>: Labeled sibling * </ul> * * @return an integer representation for the link type */ public int getLinkType() { if (m_resource.getSiblingCount() > 1) { // links are present if (m_resource.isLabeled()) { // there is at least one link in a marked site return 2; } else { // common links are present return 1; } } else { // no links to the resource are in the VFS return 0; } }
/** * Returns additional style sheets for the resource type icon depending on siblings.<p> * * That is, depending on {@link CmsResource#getSiblingCount()} * * Use it with the {@link #getIconPathExplorer} method.<p> * * @return additional style sheets depending on siblings */ public String getStyleSiblings() { StringBuffer style = new StringBuffer(128); if (m_resource.getSiblingCount() > 1) { style.append("background-image:url("); style.append(CmsWorkplace.getSkinUri()); style.append(getIconPathResourceType()); style.append("); background-position: 0px 0px; background-repeat: no-repeat; "); } return style.toString(); }
/** * Returns an integer representation for the link type.<p> * * <ul> * <li><code>0</code>: No sibling * <li><code>1</code>: Sibling * <li><code>2</code>: Labeled sibling * </ul> * * @return an integer representation for the link type */ public int getLinkType() { if (m_resource.getSiblingCount() > 1) { // links are present if (m_resource.isLabeled()) { // there is at least one link in a marked site return 2; } else { // common links are present return 1; } } else { // no links to the resource are in the VFS return 0; } }
/** * Returns additional style sheets for the resource type icon depending on siblings.<p> * * That is, depending on {@link CmsResource#getSiblingCount()} * * Use it with the {@link #getIconPathExplorer} method.<p> * * @return additional style sheets depending on siblings */ public String getStyleSiblings() { StringBuffer style = new StringBuffer(128); if (m_resource.getSiblingCount() > 1) { style.append("background-image:url("); style.append(CmsWorkplace.getSkinUri()); style.append(getIconPathResourceType()); style.append("); background-position: 0px 0px; background-repeat: no-repeat; "); } return style.toString(); }
/** * Returns the resource icon path displayed in the explorer view for the given resource.<p> * * Relative to <code>/system/workplace/resources/</code>.<p> * * If the resource has no sibling it is the same as {@link #getIconPathResourceType()}.<p> * * @return the resource icon path displayed in the explorer view for the given resource * * @see #getStyleSiblings() */ public String getIconPathExplorer() { if (m_resource.getSiblingCount() > 1) { // links are present if (m_resource.isLabeled()) { // there is at least one link in a marked site return "explorer/link_labeled.gif"; } else { // common links are present return "explorer/link.gif"; } } else { return getIconPathResourceType(); } }
/** * Returns the resource icon path displayed in the explorer view for the given resource.<p> * * Relative to <code>/system/workplace/resources/</code>.<p> * * If the resource has no sibling it is the same as {@link #getIconPathResourceType()}.<p> * * @return the resource icon path displayed in the explorer view for the given resource * * @see #getStyleSiblings() */ public String getIconPathExplorer() { if (m_resource.getSiblingCount() > 1) { // links are present if (m_resource.isLabeled()) { // there is at least one link in a marked site return "explorer/link_labeled.gif"; } else { // common links are present return "explorer/link.gif"; } } else { return getIconPathResourceType(); } }
/** * Deletes all relations for the given resource and all its siblings.<p> * * @param dbc the current database context * @param resource the resource to delete the resource for * * @throws CmsException if something goes wrong */ protected void deleteRelationsWithSiblings(CmsDbContext dbc, CmsResource resource) throws CmsException { // get all siblings List siblings; if (resource.getSiblingCount() > 1) { siblings = readSiblings(dbc, resource, CmsResourceFilter.ALL); } else { siblings = new ArrayList(); siblings.add(resource); } // clean the relations in content for all siblings Iterator it = siblings.iterator(); while (it.hasNext()) { CmsResource sibling = (CmsResource)it.next(); // clean the relation information for this sibling m_vfsDriver.deleteRelations( dbc, dbc.currentProject().getUuid(), sibling, CmsRelationFilter.TARGETS.filterDefinedInContent()); } }
/** * Checks if this resource has siblings.<p> * * @return true if this resource has siblings */ public boolean hasSiblings() { try { return getCms().readResource(getParamResource(), CmsResourceFilter.ALL).getSiblingCount() > 1; } catch (CmsException e) { LOG.error(e.getLocalizedMessage(getLocale()), e); return false; } }
/** * Checks if this resource has siblings.<p> * * @return true if this resource has siblings */ public boolean hasSiblings() { try { return getCms().readResource(getParamResource(), CmsResourceFilter.ALL).getSiblingCount() > 1; } catch (CmsException e) { LOG.error(e.getLocalizedMessage(getLocale()), e); return false; } }
/** * Deletes all relations for the given resource and all its siblings.<p> * * @param dbc the current database context * @param resource the resource to delete the resource for * * @throws CmsException if something goes wrong */ protected void deleteRelationsWithSiblings(CmsDbContext dbc, CmsResource resource) throws CmsException { // get all siblings List<CmsResource> siblings; if (resource.getSiblingCount() > 1) { siblings = readSiblings(dbc, resource, CmsResourceFilter.ALL); } else { siblings = new ArrayList<CmsResource>(); siblings.add(resource); } // clean the relations in content for all siblings I_CmsVfsDriver vfsDriver = getVfsDriver(dbc); Iterator<CmsResource> it = siblings.iterator(); while (it.hasNext()) { CmsResource sibling = it.next(); // clean the relation information for this sibling vfsDriver.deleteRelations( dbc, dbc.currentProject().getUuid(), sibling, CmsRelationFilter.TARGETS.filterDefinedInContent()); } }
/** * Creates an object for published VFS resources.<p> * * @param resource an CmsResource object to create a CmsPublishedResource from * @param state the resource state * @param publishTag the publish tag */ public CmsPublishedResource(CmsResource resource, int publishTag, CmsResourceState state) { this( resource.getStructureId(), resource.getResourceId(), publishTag, resource.getRootPath(), resource.getTypeId(), resource.isFolder(), state, resource.getSiblingCount()); }
/** * Creates an object for published VFS resources.<p> * * @param resource an CmsResource object to create a CmsPublishedResource from * @param state the resource state * @param publishTag the publish tag */ public CmsPublishedResource(CmsResource resource, int publishTag, CmsResourceState state) { this( resource.getStructureId(), resource.getResourceId(), publishTag, resource.getRootPath(), resource.getTypeId(), resource.isFolder(), state, resource.getSiblingCount()); }
/** * @see org.opencms.workplace.CmsWorkplace#checkLock(String, CmsLockType) */ @Override public void checkLock(String resource, CmsLockType type) throws CmsException { CmsResource res = getCms().readResource(resource, CmsResourceFilter.ALL); CmsLock lock = getCms().getLock(res); if (!lock.isNullLock()) { setParamModified(Boolean.TRUE.toString()); } // for resources with siblings make sure all sibling have at least a // temporary lock if ((res.getSiblingCount() > 1) && (lock.isInherited())) { super.checkLock(resource, CmsLockType.TEMPORARY); } else { super.checkLock(resource, type); } }
/** * @see org.opencms.workplace.CmsWorkplace#checkLock(String, CmsLockType) */ @Override public void checkLock(String resource, CmsLockType type) throws CmsException { CmsResource res = getCms().readResource(resource, CmsResourceFilter.ALL); CmsLock lock = getCms().getLock(res); if (!lock.isNullLock()) { setParamModified(Boolean.TRUE.toString()); } // for resources with siblings make sure all sibling have at least a // temporary lock if ((res.getSiblingCount() > 1) && (lock.isInherited())) { super.checkLock(resource, CmsLockType.TEMPORARY); } else { super.checkLock(resource, type); } }
if (resource.getState().isUnchanged()) { resource.setState(CmsResource.STATE_CHANGED); } else if (resource.getState().isNew() && (resource.getSiblingCount() > 1)) {
/** * 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()); }
/** * 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); }
/** * 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); }
/** * 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; }