/** * Creates a new container page element bean.<p> * * @param file the element's file * @param formatterId the formatter's structure id, could be <code>null</code> * @param individualSettings the element settings as a map of name/value pairs * @param inMemoryOnly the in memory flag * @param editorHash the editor hash to use * @param createNew <code>true</code> if a new element should be created replacing the given one on first edit of a container-page **/ public CmsContainerElementBean( CmsFile file, CmsUUID formatterId, Map<String, String> individualSettings, boolean inMemoryOnly, String editorHash, boolean createNew) { this(file.getStructureId(), formatterId, individualSettings, createNew); m_inMemoryOnly = inMemoryOnly; m_editorHash = editorHash; m_resource = file; }
/** * @see java.lang.Object#hashCode() */ @Override public int hashCode() { if (m_contentValue == null) { return 0; } if (m_hashCode == 0) { StringBuffer result = new StringBuffer(64); result.append(m_contentValue.getDocument().getFile().getStructureId().toString()); result.append('/'); result.append(m_contentValue.getLocale()); result.append('/'); result.append(m_contentValue.getPath()); m_hashCode = result.toString().hashCode(); } return m_hashCode; }
/** * @see java.lang.Object#hashCode() */ @Override public int hashCode() { if (m_contentValue == null) { return 0; } if (m_hashCode == 0) { StringBuffer result = new StringBuffer(64); result.append(m_contentValue.getDocument().getFile().getStructureId().toString()); result.append('/'); result.append(m_contentValue.getLocale()); result.append('/'); result.append(m_contentValue.getPath()); m_hashCode = result.toString().hashCode(); } return m_hashCode; }
/** * Returns the structure ID of the current resource, that is the ID of * the resource obtained by {@link #getFile()}.<p> * * Usage example on a JSP with the JSTL:<pre> * <cms:contentload ... > * <cms:contentaccess var="content" /> * Site path of the resource: "${content.id}"; * </cms:contentload></pre> * * @return the structure ID of the current resource * * @see CmsResource#getStructureId() */ public CmsUUID getId() { return getRawContent().getFile().getStructureId(); }
/** * Returns the XML content document.<p> * * @param file the resource file * @param fromCache <code>true</code> to use the cached document * * @return the content document * * @throws CmsXmlException if reading the XML fails */ private CmsXmlContent getContentDocument(CmsFile file, boolean fromCache) throws CmsXmlException { CmsXmlContent content = null; if (fromCache) { content = getSessionCache().getCacheXmlContent(file.getStructureId()); } if (content == null) { content = CmsXmlContentFactory.unmarshal(getCmsObject(), file); getSessionCache().setCacheXmlContent(file.getStructureId(), content); } return content; }
/** * Returns the RDF annotations required for in line editing.<p> * * @param document the parent XML document * @param contentLocale the content locale * @param elementPath the element xpath to get the RDF annotation for * * @return the RDFA */ public static String getRdfaAttributes(I_CmsXmlDocument document, Locale contentLocale, String elementPath) { I_CmsXmlSchemaType schemaType = document.getContentDefinition().getSchemaType(elementPath); if (schemaType != null) { String path = ""; if (elementPath.contains("/")) { path += "/" + removePathIndexes(elementPath.substring(0, elementPath.lastIndexOf("/")) + ":"); } path += getTypeUri(schemaType.getContentDefinition()) + "/" + elementPath; return String.format( RDFA_ATTRIBUTES, CmsContentDefinition.uuidToEntityId(document.getFile().getStructureId(), contentLocale.toString()), path); } else { return ""; } }
/** * @see org.apache.commons.collections.Transformer#transform(java.lang.Object) */ public Object transform(Object input) { String result; if (CmsJspContentAccessValueWrapper.isDirectEditEnabled(getCmsObject())) { result = createImageDndAttr( getRawContent().getFile().getStructureId(), String.valueOf(input), String.valueOf(getLocale())); } else { result = ""; } return result; } }
/** * Returns the entity id to the given content value.<p> * * @param contentValue the content value * * @return the entity id */ public static String getEntityId(I_CmsXmlContentValue contentValue) { String result = CmsContentDefinition.uuidToEntityId( contentValue.getDocument().getFile().getStructureId(), contentValue.getLocale().toString()); String valuePath = contentValue.getPath(); if (valuePath.contains("/")) { result += "/" + valuePath.substring(0, valuePath.lastIndexOf("/")); } if (contentValue.isChoiceOption()) { result += "/" + CmsType.CHOICE_ATTRIBUTE_NAME + "_" + contentValue.getName() + "[" + contentValue.getXmlIndex() + "]"; } return result; }
/** * @see org.opencms.file.wrapper.A_CmsResourceWrapper#writeFile(org.opencms.file.CmsObject, org.opencms.file.CmsFile) */ @Override public CmsFile writeFile(CmsObject cms, CmsFile resource) throws CmsException { CmsResource res = getResource(cms, resource.getStructureId()); if (res != null) { CmsResourceWrapperUtils.writePropertyFile( cms, cms.getRequestContext().removeSiteRoot(res.getRootPath()), resource.getContents()); return resource; } return null; }
CmsFile file = m_cms.readFile(resource); rewriteContent(file, relations); m_rewrittenContent.add(file.getStructureId());
/** * @see org.opencms.file.wrapper.A_CmsResourceWrapper#writeFile(org.opencms.file.CmsObject, org.opencms.file.CmsFile) */ @Override public CmsFile writeFile(CmsObject cms, CmsFile resource) throws CmsException { CmsResource res = cms.readResource(resource.getStructureId()); // CmsResource res = getResource( // cms, // cms.getRequestContext().removeSiteRoot(resource.getRootPath()), // CmsResourceFilter.ALL); if (res != null) { CmsResourceWrapperUtils.writePropertyFile( cms, cms.getRequestContext().removeSiteRoot(res.getRootPath()), resource.getContents()); return resource; } return null; }
public CmsFile writeFile(CmsObject cms, CmsFile resource) throws CmsException { CmsResource xmlPage = cms.readResource(resource.getStructureId());
/** * Returns the RDF annotations required for in line editing.<p> * * @param parentValue the parent XML content value * @param childNames the child attribute names separated by '|' * * @return the RDFA */ public static String getRdfaAttributes(I_CmsXmlContentValue parentValue, String childNames) { String id = CmsContentDefinition.uuidToEntityId( parentValue.getDocument().getFile().getStructureId(), parentValue.getLocale().toString()) + "/" + parentValue.getPath(); String path = ""; String[] children = childNames.split("\\|"); for (int i = 0; i < children.length; i++) { I_CmsXmlSchemaType schemaType = parentValue.getContentDefinition().getSchemaType( parentValue.getName() + "/" + children[i]); if (schemaType != null) { if (i > 0) { path += " "; } String typePath = parentValue.getPath(); path += "/" + removePathIndexes(typePath) + ":"; path += getTypeUri(schemaType.getContentDefinition()) + "/" + children[i]; } } return String.format(RDFA_ATTRIBUTES, id, path); }
/** * Returns the annotation that enables image drag and drop for this content value.<p> * * Use to insert the annotation attributes into a HTML tag.<p> * * Only makes sense in case this node actually contains the path to an image.<p> * * Example using EL: <span ${value.Image.imageDndAttr}> ... </span> will result in * <span data-imagednd="..."> ... </span><p> * * @return the annotation that enables image drag and drop for this content value */ public String getImageDndAttr() { String result = ""; CmsObject cms = obtainCmsObject(); if ((cms != null) && (m_contentValue != null) && isDirectEditEnabled(cms) && (m_contentValue.getDocument().getFile() != null)) { result = CmsJspContentAccessBean.createImageDndAttr( m_contentValue.getDocument().getFile().getStructureId(), m_contentValue.getPath(), String.valueOf(m_contentValue.getLocale())); } return result; }
public CmsFile writeFile(CmsObject cms, CmsFile resource) throws CmsException { CmsResource xmlPage = cms.readResource(resource.getStructureId());
/** * Stores the given group container in the cache.<p> * * @param cms the cms context * @param xmlGroupContainer the group container to cache * @param keepEncoding if the encoding was kept while unmarshalling */ private static void setCache(CmsObject cms, CmsXmlGroupContainer xmlGroupContainer, boolean keepEncoding) { if (xmlGroupContainer.getFile() instanceof I_CmsHistoryResource) { return; } boolean online = cms.getRequestContext().getCurrentProject().isOnlineProject(); getCache().setCacheGroupContainer( getCache().getCacheKey(xmlGroupContainer.getFile().getStructureId(), keepEncoding), xmlGroupContainer, online); }
/** * Stores the given container page in the cache.<p> * * @param cms the cms context * @param xmlCntPage the container page to cache * @param keepEncoding if the encoding was kept while unmarshalling */ private static void setCache(CmsObject cms, CmsXmlContainerPage xmlCntPage, boolean keepEncoding) { if (xmlCntPage.getFile() instanceof I_CmsHistoryResource) { return; } boolean online = cms.getRequestContext().getCurrentProject().isOnlineProject(); getCache().setCacheContainerPage( getCache().getCacheKey(xmlCntPage.getFile().getStructureId(), keepEncoding), xmlCntPage, online); } }
/** * Returns the virtual resource as a file.<p> * * @return the virtual resource as a file */ public CmsFile getFile() { if (m_base instanceof CmsFile) { CmsFile file = (CmsFile)m_base; return new CmsFile( file.getStructureId(), file.getResourceId(), m_rootPath, m_typeId, file.getFlags(), file.getProjectLastModified(), file.getState(), file.getDateCreated(), file.getUserCreated(), file.getDateLastModified(), file.getUserLastModified(), file.getDateReleased(), file.getDateExpired(), file.getSiblingCount(), file.getLength(), file.getDateContent(), file.getVersion(), file.getContents()); } return new CmsFile(getResource()); }
getStructureId(), getResourceId(), getRootPath(),
/** * Returns the virtual resource as a file.<p> * * @return the virtual resource as a file */ public CmsFile getFile() { if (m_base instanceof CmsFile) { CmsFile file = (CmsFile)m_base; return new CmsFile( file.getStructureId(), file.getResourceId(), m_rootPath, m_typeId, file.getFlags(), file.getProjectLastModified(), file.getState(), file.getDateCreated(), file.getUserCreated(), file.getDateLastModified(), file.getUserLastModified(), file.getDateReleased(), file.getDateExpired(), file.getSiblingCount(), file.getLength(), file.getDateContent(), file.getVersion(), file.getContents()); } return new CmsFile(getResource()); }