/** * @see org.opencms.workplace.list.A_CmsListResourceCollector#setAdditionalColumns(org.opencms.workplace.list.CmsListItem, org.opencms.workplace.explorer.CmsResourceUtil) */ @Override protected void setAdditionalColumns(CmsListItem item, CmsResourceUtil resUtil) { item.set( CmsLockedResourcesList.LIST_COLUMN_IS_RELATED, Boolean.valueOf((resUtil.getResource().getFlags() & FLAG_RELATED_RESOURCE) == FLAG_RELATED_RESOURCE)); } }
/** * @see org.opencms.workplace.list.A_CmsListResourceCollector#setAdditionalColumns(org.opencms.workplace.list.CmsListItem, org.opencms.workplace.explorer.CmsResourceUtil) */ @Override protected void setAdditionalColumns(CmsListItem item, CmsResourceUtil resUtil) { item.set( CmsLockedResourcesList.LIST_COLUMN_IS_RELATED, Boolean.valueOf((resUtil.getResource().getFlags() & FLAG_RELATED_RESOURCE) == FLAG_RELATED_RESOURCE)); } }
/** * 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()))))); }
/** * 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 CmsResource#isTemporaryFileName(String) */ public static boolean isTemporaryFile(CmsResource resource) { return (resource != null) && ((resource.isFile() && (((resource.getFlags() & CmsResource.FLAG_TEMPFILE) > 0) || (CmsResource.isTemporaryFileName(resource.getName()))))); }
resource = getCms().readResource(getParamResource(), CmsResourceFilter.ALL); int flags = resource.getFlags();
/** * 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()); }
/** * Returns the organizational unit represented by the given resource.<p> * * @param dbc the current db context * @param resource the resource that represents an organizational unit * * @return the organizational unit represented by the given resource * * @throws CmsException if something goes wrong */ protected CmsOrganizationalUnit internalCreateOrgUnitFromResource(CmsDbContext dbc, CmsResource resource) throws CmsException { if (!resource.getRootPath().startsWith(ORGUNIT_BASE_FOLDER)) { throw new CmsDataAccessException(Messages.get().container( Messages.ERR_READ_ORGUNIT_1, resource.getRootPath())); } // get the data String name = resource.getRootPath().substring(ORGUNIT_BASE_FOLDER.length()); if ((name.length() > 0) && !name.endsWith(CmsOrganizationalUnit.SEPARATOR)) { name += CmsOrganizationalUnit.SEPARATOR; } String description = m_driverManager.readPropertyObject(dbc, resource, ORGUNIT_PROPERTY_DESCRIPTION, false).getStructureValue(); int flags = (resource.getFlags() & ~CmsResource.FLAG_INTERNAL); // remove the internal flag String projectId = m_driverManager.readPropertyObject(dbc, resource, ORGUNIT_PROPERTY_PROJECTID, false).getStructureValue(); // create the object return new CmsOrganizationalUnit(resource.getStructureId(), name, description, flags, (projectId == null ? null : new CmsUUID(projectId))); }
/** * Performs the Security and Export Change.<p> * * @throws JspException if including a JSP sub element is not successful */ public void actionChangeSecureExport() throws JspException { // save initialized instance of this class in request attribute for included sub-elements getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this); String filename = getParamResource(); try { // lock resource if auto lock is enabled checkLock(getParamResource()); // write the properties writeProperty(CmsPropertyDefinition.PROPERTY_EXPORT, getParamExport()); writeProperty(CmsPropertyDefinition.PROPERTY_EXPORTNAME, getParamExportname()); writeProperty(CmsPropertyDefinition.PROPERTY_SECURE, getParamSecure()); // change the flag of the resource so that it is internal CmsResource resource = getCms().readResource(filename, CmsResourceFilter.IGNORE_EXPIRATION); if (resource.isInternal() && !Boolean.valueOf(getParamIntern()).booleanValue()) { getCms().chflags(filename, resource.getFlags() & (~CmsResource.FLAG_INTERNAL)); } else if (!resource.isInternal() && Boolean.valueOf(getParamIntern()).booleanValue()) { getCms().chflags(filename, resource.getFlags() | CmsResource.FLAG_INTERNAL); } actionCloseDialog(); } catch (Throwable e) { // error during change of secure settings, show error dialog includeErrorpage(this, e); } }
/** * Performs the Security and Export Change.<p> * * @throws JspException if including a JSP sub element is not successful */ public void actionChangeSecureExport() throws JspException { // save initialized instance of this class in request attribute for included sub-elements getJsp().getRequest().setAttribute(SESSION_WORKPLACE_CLASS, this); String filename = getParamResource(); try { // lock resource if auto lock is enabled checkLock(getParamResource()); // write the properties writeProperty(CmsPropertyDefinition.PROPERTY_EXPORT, getParamExport()); writeProperty(CmsPropertyDefinition.PROPERTY_EXPORTNAME, getParamExportname()); writeProperty(CmsPropertyDefinition.PROPERTY_SECURE, getParamSecure()); // change the flag of the resource so that it is internal CmsResource resource = getCms().readResource(filename, CmsResourceFilter.IGNORE_EXPIRATION); if (resource.isInternal() && !Boolean.valueOf(getParamIntern()).booleanValue()) { getCms().chflags(filename, resource.getFlags() & (~CmsResource.FLAG_INTERNAL)); } else if (!resource.isInternal() && Boolean.valueOf(getParamIntern()).booleanValue()) { getCms().chflags(filename, resource.getFlags() | CmsResource.FLAG_INTERNAL); } actionCloseDialog(); } catch (Throwable e) { // error during change of secure settings, show error dialog includeErrorpage(this, e); } }
/** * 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()); }
/** * 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 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); }
/** * @see org.opencms.file.types.I_CmsResourceType#createResource(org.opencms.file.CmsObject, CmsSecurityManager, java.lang.String, byte[], List) */ public CmsResource createResource( CmsObject cms, CmsSecurityManager securityManager, String resourcename, byte[] content, List properties) throws CmsException { // initialize a macro resolver with the current user OpenCms context CmsMacroResolver resolver = getMacroResolver(cms, resourcename); // add the predefined property values from the XML configuration to the resource List newProperties = processDefaultProperties(properties, resolver); CmsResource result = securityManager.createResource( cms.getRequestContext(), cms.getRequestContext().addSiteRoot(resourcename), getTypeId(), content, newProperties); if ((m_internal != null) && m_internal.booleanValue()) { securityManager.chflags(cms.getRequestContext(), result, result.getFlags() ^ CmsResource.FLAG_INTERNAL); } // process the (optional) copy resources from the configuration processCopyResources(cms, resourcename, resolver); // create the relations for the new resource createRelations(cms, securityManager, cms.getRequestContext().addSiteRoot(resourcename)); // return the created resource return result; }
/** * @see org.opencms.file.types.I_CmsResourceType#createResource(org.opencms.file.CmsObject, CmsSecurityManager, java.lang.String, byte[], List) */ public CmsResource createResource( CmsObject cms, CmsSecurityManager securityManager, String resourcename, byte[] content, List<CmsProperty> properties) throws CmsException { // initialize a macro resolver with the current user OpenCms context CmsMacroResolver resolver = getMacroResolver(cms, resourcename); // add the predefined property values from the XML configuration to the resource List<CmsProperty> newProperties = processDefaultProperties(properties, resolver); CmsResource result = securityManager.createResource( cms.getRequestContext(), cms.getRequestContext().addSiteRoot(resourcename), getTypeId(), content, newProperties); if ((m_internal != null) && m_internal.booleanValue()) { securityManager.chflags(cms.getRequestContext(), result, result.getFlags() ^ CmsResource.FLAG_INTERNAL); } // process the (optional) copy resources from the configuration processCopyResources(cms, resourcename, resolver); // create the relations for the new resource createRelations(cms, securityManager, cms.getRequestContext().addSiteRoot(resourcename)); // return the created resource return result; }
/** * 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 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); }