/** * 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()); }
/** * Gets the name to display for the given resource.<p> * * @param cms the CMS context * @param resource a resource * @param parentId the id of the parent of the resource * * @return the name for the given resoure */ protected String getName(CmsObject cms, CmsResource resource, CmsUUID parentId) { return parentId == null ? resource.getRootPath() : resource.getName(); } }
/** * Returns the name of the parent folder of the resource of this navigation element.<p> * * @return the name of the parent folder of the resource of this navigation element */ public String getParentFolderName() { return CmsResource.getParentFolder(m_resource); }
/** * Creates a new virtual resource.<p> * * @param res the resource this virtual resource is based on */ public CmsWrappedResource(CmsResource res) { m_base = res; m_rootPath = res.getRootPath(); m_typeId = res.getTypeId(); m_isFolder = res.isFolder(); m_length = res.getLength(); }
/** * Sets the parent path to read visited resources from using the given resource as parent.<p> * * @param parentResource the resource to use as parent resource */ public void setParentResource(CmsResource parentResource) { if (parentResource.isFile()) { m_parentPath = CmsResource.getFolderPath(parentResource.getRootPath()); } else { m_parentPath = parentResource.getRootPath(); } }
/** * Initializes the information about the resource from which this configuration was read.<p> * * @param configResource the configuration file */ public void setResource(CmsResource configResource) { m_structureId = configResource.getStructureId(); m_rootPath = configResource.getRootPath(); } }
/** * Enumeration class for the mode parameter in the * {@link CmsDriverManager#readChangedResourcesInsideProject(CmsDbContext, CmsUUID, CmsReadChangedProjectResourceMode)} * method.<p> */ private static class CmsReadChangedProjectResourceMode { /** * Default constructor.<p> */ protected CmsReadChangedProjectResourceMode() { // noop } }
/** * 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()); }
/** * @see org.opencms.ade.configuration.I_CmsGlobalConfigurationCache#remove(org.opencms.file.CmsResource) */ public void remove(CmsResource resource) { checkIfUpdateIsNeeded(resource.getStructureId(), resource.getRootPath(), resource.getTypeId()); }
/** * 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()); }
/** * Validates that the length setting of a resource is always correct.<p> * * Files need to have a resource length of >= 0, while folders require * a resource length of -1.<p> * * @param resource the resource to check the length for * @throws CmsDataAccessException if the resource length is not correct */ protected void internalValidateResourceLength(CmsResource resource) throws CmsDataAccessException { if (resource.isFolder() && (resource.getLength() == -1)) { return; } if (resource.isFile() && (resource.getLength() >= 0)) { return; } throw new CmsDataAccessException(Messages.get().container( Messages.ERR_INVALID_RESOURCE_LENGTH_2, new Integer(resource.getLength()), resource.getRootPath())); }
/** * @see org.opencms.ade.configuration.I_CmsGlobalConfigurationCache#update(org.opencms.file.CmsResource) */ public void update(CmsResource resource) { update(resource.getStructureId(), resource.getRootPath(), resource.getTypeId(), resource.getState()); }
/** * @see org.opencms.file.wrapper.A_CmsResourceWrapper#rewriteLink(CmsObject, CmsResource) */ @Override public String rewriteLink(CmsObject cms, CmsResource res) { if (checkTypeId(res.getTypeId())) { return CmsResourceWrapperUtils.addFileExtension(cms, res.getRootPath(), getExtension()); } return null; }
/** * Creates a select option with the resource to select, the resource's name as the display text and no help text * that is potentially the default selection (argument isDefault).<p> * * @param resource the resource of this selection * @param isDefault true, if this option is the default option (preselected) * */ public CmsResourceSelectWidgetOption(CmsResource resource, boolean isDefault) { this(resource, isDefault, resource.getName()); }
/** * Copies state information from the internal CmsResource object to this object.<p> */ protected void updateFromResource() { setCreationDate(m_resource.getDateCreated()); int length = m_resource.getLength(); if (m_resource.isFolder()) { length = 1; } setFileSize(length); setModifyDate(m_resource.getDateLastModified()); setAttributes(m_resource.isFile() ? FileAttribute.Normal : FileAttribute.Directory); }
/** * Returns <code>true</code> if this resource is a temporary file.<p> * * A resource is considered a temporary file it is a file where the * {@link CmsResource#FLAG_TEMPFILE} flag has been set, or if the file name (without parent folders) * starts with the prefix char <code>'~'</code> (tilde).<p> * * @return <code>true</code> if the given resource name is a temporary file * * @see #isTemporaryFileName(String) */ public boolean isTemporaryFile() { return isFile() && (((getFlags() & CmsResource.FLAG_TEMPFILE) > 0) || isTemporaryFileName(getName())); }
/** * Returns <code>true</code> if the given resource is a temporary file.<p> * * A resource is considered a temporary file it is a file where the * {@link CmsResource#FLAG_TEMPFILE} flag has been set, or if the file name (without parent folders) * starts with the prefix char <code>'~'</code> (tilde).<p> * * @param resource the resource name to check * * @return <code>true</code> if the given resource name is a temporary file * * @see #getTemporaryFileName(String) * @see #isTemporaryFileName(String) */ public static boolean isTemporaryFile(CmsResource resource) { return (resource != null) && ((resource.isFile() && (((resource.getFlags() & CmsResource.FLAG_TEMPFILE) > 0) || (isTemporaryFileName(resource.getName()))))); }
/** * Gets the name of the parent folder of the requested file.<p> * * @return the name of the parent folder of the requested file */ public String getFolderUri() { return CmsResource.getFolderPath(m_uri); }
/** * Displays the start resource by opening all nodes in the tree leading to it.<p> * * @param startResource the resource which should be shown in the tree */ public void showStartResource(CmsResource startResource) { openPath(startResource.getRootPath()); }
/** * @see org.opencms.search.fields.CmsSearchFieldConfiguration#appendDates(org.opencms.search.I_CmsSearchDocument, org.opencms.file.CmsObject, org.opencms.file.CmsResource, org.opencms.search.extractors.I_CmsExtractionResult, java.util.List, java.util.List) */ @Override protected I_CmsSearchDocument appendDates( I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) { document.addDateField(CmsSearchField.FIELD_DATE_CREATED, resource.getDateCreated(), false); document.addDateField(CmsSearchField.FIELD_DATE_LASTMODIFIED, resource.getDateLastModified(), false); document.addDateField(CmsSearchField.FIELD_DATE_CONTENT, resource.getDateContent(), false); document.addDateField(CmsSearchField.FIELD_DATE_RELEASED, resource.getDateReleased(), false); document.addDateField(CmsSearchField.FIELD_DATE_EXPIRED, resource.getDateExpired(), false); return document; }