- Create Web Content action (HTML and plain text) now creates content in the current AVM store
   - TODO: create in the correct sub-folder
 - Refactoring of the modified Create Content Wizard into a new wizard Create Web Content Wizard
   - Integrated XML form templating into the current website AVM path (still needs some testing/fixing up…)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3867 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-09-20 17:59:58 +00:00
parent 9fe7ccf523
commit ae0a118985
12 changed files with 699 additions and 650 deletions

View File

@@ -825,6 +825,8 @@ delete_folder=Delete Folder
delete_avm_folder_info=To remove this folder and its contents from the sandbox, click OK. delete_avm_folder_info=To remove this folder and its contents from the sandbox, click OK.
delete_avm_folder_confirm=Are you sure you want to remove \"{0}\" and its contents from the sandbox? delete_avm_folder_confirm=Are you sure you want to remove \"{0}\" and its contents from the sandbox?
error_delete_folder=Unable to delete Folder due to system error: error_delete_folder=Unable to delete Folder due to system error:
create_web_content_title=Create Web Content Wizard
create_web_content_desc=This wizard helps you to create a new content item for a website.
# New User Wizard messages # New User Wizard messages
new_user_title=New User Wizard new_user_title=New User Wizard

View File

@@ -178,7 +178,7 @@
<!-- Definition of the Create Web Content wizard --> <!-- Definition of the Create Web Content wizard -->
<wizard name="createWebContent" managed-bean="CreateWebContentWizard" <wizard name="createWebContent" managed-bean="CreateWebContentWizard"
title-id="create_content_title" description-id="create_content_desc" title-id="create_web_content_title" description-id="create_web_content_desc"
icon="/images/icons/new_content_large.gif"> icon="/images/icons/new_content_large.gif">
<step name="details" title-id="details" description-id="create_content_step1_desc"> <step name="details" title-id="details" description-id="create_content_step1_desc">
<page path="/jsp/wcm/create-web-content-wizard/details.jsp" <page path="/jsp/wcm/create-web-content-wizard/details.jsp"

View File

@@ -46,8 +46,6 @@ import org.alfresco.web.app.context.UIContextService;
import org.alfresco.web.app.servlet.DownloadContentServlet; import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.templating.OutputUtil;
import org.alfresco.web.templating.TemplatingService;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIActionLink; import org.alfresco.web.ui.common.component.UIActionLink;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@@ -641,14 +639,6 @@ public class CheckinCheckoutBean
// commit the transaction // commit the transaction
tx.commit(); tx.commit();
if (nodeService.getProperty(node.getNodeRef(),
TemplatingService.TT_QNAME) != null)
{
OutputUtil.regenerate(node.getNodeRef(),
this.contentService,
this.nodeService);
}
// clean up and clear action context // clean up and clear action context
clearUpload(); clearUpload();
setDocument(null); setDocument(null);

View File

@@ -334,7 +334,16 @@ public abstract class BaseContentWizard extends BaseWizardBean
protected void saveContent(File fileContent, String strContent) throws Exception protected void saveContent(File fileContent, String strContent) throws Exception
{ {
// get the node ref of the node that will contain the content // get the node ref of the node that will contain the content
NodeRef containerNodeRef = getContainerNodeRef(); NodeRef containerNodeRef;
String nodeId = this.navigator.getCurrentNodeId();
if (nodeId == null)
{
containerNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
}
else
{
containerNodeRef = new NodeRef(Repository.getStoreRef(), nodeId);
}
FileInfo fileInfo = this.fileFolderService.create( FileInfo fileInfo = this.fileFolderService.create(
containerNodeRef, containerNodeRef,

View File

@@ -57,87 +57,94 @@ import org.xml.sax.SAXException;
*/ */
public class CreateXmlContentTypeWizard extends BaseWizardBean public class CreateXmlContentTypeWizard extends BaseWizardBean
{ {
private final static Log LOGGER =
LogFactory.getLog(CreateXmlContentTypeWizard.class);
private final static Log LOGGER = private String presentationTemplateType;
LogFactory.getLog(CreateXmlContentTypeWizard.class); protected ContentService contentService;
private String presentationTemplateType; // ------------------------------------------------------------------------------
protected ContentService contentService; // Wizard implementation
// ------------------------------------------------------------------------------ @Override
// Wizard implementation protected String finishImpl(FacesContext context, String outcome)
throws Exception
@Override {
protected String finishImpl(FacesContext context, String outcome) // get the node ref of the node that will contain the content
throws Exception NodeRef containerNodeRef;
{ String nodeId = this.navigator.getCurrentNodeId();
// get the node ref of the node that will contain the content if (nodeId == null)
NodeRef containerNodeRef = this.getContainerNodeRef(); {
containerNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
FileInfo fileInfo = }
this.fileFolderService.create(containerNodeRef, else
this.getSchemaFileName(), {
ContentModel.TYPE_CONTENT); containerNodeRef = new NodeRef(Repository.getStoreRef(), nodeId);
final NodeRef schemaFileNodeRef = fileInfo.getNodeRef(); }
if (LOGGER.isDebugEnabled())
LOGGER.debug("Created file node for file: " +
this.getSchemaFileName());
// get a writer for the content and put the file
ContentWriter writer = contentService.getWriter(schemaFileNodeRef,
ContentModel.PROP_CONTENT, true);
// set the mimetype and encoding
writer.setMimetype("text/xml");
writer.setEncoding("UTF-8");
writer.putContent(this.getSchemaFile());
fileInfo = this.fileFolderService.create(containerNodeRef,
this.getPresentationTemplateFileName(),
ContentModel.TYPE_CONTENT);
final NodeRef presentationTemplateFileNodeRef = fileInfo.getNodeRef();
if (LOGGER.isDebugEnabled()) FileInfo fileInfo = this.fileFolderService.create(containerNodeRef,
LOGGER.debug("Created file node for file: " + this.getSchemaFileName(),
this.getPresentationTemplateFileName()); ContentModel.TYPE_CONTENT);
final NodeRef schemaFileNodeRef = fileInfo.getNodeRef();
// get a writer for the content and put the file
writer = contentService.getWriter(presentationTemplateFileNodeRef, if (LOGGER.isDebugEnabled())
ContentModel.PROP_CONTENT, true); LOGGER.debug("Created file node for file: " +
// set the mimetype and encoding this.getSchemaFileName());
writer.setMimetype("text/xml");
writer.setEncoding("UTF-8"); // get a writer for the content and put the file
writer.putContent(this.getPresentationTemplateFile()); ContentWriter writer = contentService.getWriter(schemaFileNodeRef,
ContentModel.PROP_CONTENT, true);
final TemplatingService ts = TemplatingService.getInstance(); // set the mimetype and encoding
final String rootTagName = writer.setMimetype("text/xml");
this.getSchemaFileName().replaceAll("([^\\.])\\..+", "$1"); writer.setEncoding("UTF-8");
final TemplateType tt = ts.newTemplateType(rootTagName, schemaFileNodeRef); writer.putContent(this.getSchemaFile());
if (this.getPresentationTemplateFile() != null)
{ fileInfo = this.fileFolderService.create(containerNodeRef,
tt.addOutputMethod(new XSLTOutputMethod(presentationTemplateFileNodeRef)); this.getPresentationTemplateFileName(),
} ContentModel.TYPE_CONTENT);
ts.registerTemplateType(tt); final NodeRef presentationTemplateFileNodeRef = fileInfo.getNodeRef();
// return the default outcome if (LOGGER.isDebugEnabled())
return outcome; LOGGER.debug("Created file node for file: " +
} this.getPresentationTemplateFileName());
// get a writer for the content and put the file
writer = contentService.getWriter(presentationTemplateFileNodeRef,
ContentModel.PROP_CONTENT, true);
// set the mimetype and encoding
writer.setMimetype("text/xml");
writer.setEncoding("UTF-8");
writer.putContent(this.getPresentationTemplateFile());
final TemplatingService ts = TemplatingService.getInstance();
final String rootTagName =
this.getSchemaFileName().replaceAll("([^\\.])\\..+", "$1");
final TemplateType tt = ts.newTemplateType(rootTagName, schemaFileNodeRef);
if (this.getPresentationTemplateFile() != null)
{
tt.addOutputMethod(new XSLTOutputMethod(presentationTemplateFileNodeRef));
}
ts.registerTemplateType(tt);
// return the default outcome
return outcome;
}
@Override @Override
public void init(Map<String, String> parameters) public void init(Map<String, String> parameters)
{ {
super.init(parameters); super.init(parameters);
this.removeUploadedSchemaFile(); this.removeUploadedSchemaFile();
this.removeUploadedPresentationTemplateFile(); this.removeUploadedPresentationTemplateFile();
} }
@Override @Override
public String cancel() public String cancel()
{ {
this.removeUploadedSchemaFile(); this.removeUploadedSchemaFile();
this.removeUploadedPresentationTemplateFile(); this.removeUploadedPresentationTemplateFile();
return super.cancel(); return super.cancel();
} }
@Override @Override
@@ -153,8 +160,8 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
{ {
case 1: case 1:
{ {
disabled = (this.getSchemaFileName() == null || disabled = (this.getSchemaFileName() == null ||
this.getSchemaFileName().length() == 0); this.getSchemaFileName().length() == 0);
break; break;
} }
} }
@@ -162,26 +169,26 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
return disabled; return disabled;
} }
// @Override // @Override
// protected String doPostCommitProcessing(FacesContext context, String outcome) // protected String doPostCommitProcessing(FacesContext context, String outcome)
// { // {
// // as we were successful, go to the set properties dialog if asked // // as we were successful, go to the set properties dialog if asked
// // to otherwise just return // // to otherwise just return
// if (this.showOtherProperties) // if (this.showOtherProperties)
// { // {
// // we are going to immediately edit the properties so we need // // we are going to immediately edit the properties so we need
// // to setup the BrowseBean context appropriately // // to setup the BrowseBean context appropriately
// this.browseBean.setDocument(new Node(this.createdNode)); // this.browseBean.setDocument(new Node(this.createdNode));
// //
// return getDefaultFinishOutcome() + AlfrescoNavigationHandler.OUTCOME_SEPARATOR + // return getDefaultFinishOutcome() + AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
// "dialog:setContentProperties"; // "dialog:setContentProperties";
// } // }
// else // else
// { // {
// return outcome; // return outcome;
// } // }
// } // }
/** /**
* Action handler called when the user wishes to remove an uploaded file * Action handler called when the user wishes to remove an uploaded file
*/ */
@@ -192,7 +199,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
// refresh the current page // refresh the current page
return null; return null;
} }
/** /**
* Action handler called when the user wishes to remove an uploaded file * Action handler called when the user wishes to remove an uploaded file
*/ */
@@ -204,105 +211,106 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
return null; return null;
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Bean Getters and Setters // Bean Getters and Setters
/** /**
* @return Returns the mime type currenty selected * @return Returns the mime type currenty selected
*/ */
public String getPresentationTemplateType() public String getPresentationTemplateType()
{ {
if (this.getPresentationTemplateFileName() != null) if (this.getPresentationTemplateFileName() != null)
{ {
// String s = this.getPresentationTemplateFileName(); // String s = this.getPresentationTemplateFileName();
// String extension = // String extension =
this.presentationTemplateType = "XSL"; this.presentationTemplateType = "XSL";
} }
return this.presentationTemplateType; return this.presentationTemplateType;
} }
/** /**
* @param presentationTemplateType Sets the currently selected mime type * @param presentationTemplateType Sets the currently selected mime type
*/ */
public void setPresentationTemplateType(String presentationTemplateType) public void setPresentationTemplateType(String presentationTemplateType)
{ {
this.presentationTemplateType = presentationTemplateType; this.presentationTemplateType = presentationTemplateType;
} }
private FileUploadBean getFileUploadBean(final String id)
{
final FacesContext ctx = FacesContext.getCurrentInstance();
final Map sessionMap = ctx.getExternalContext().getSessionMap();
return (FileUploadBean)sessionMap.get(FileUploadBean.getKey(id));
}
private FileUploadBean getFileUploadBean(final String id)
{
final FacesContext ctx = FacesContext.getCurrentInstance();
final Map sessionMap = ctx.getExternalContext().getSessionMap();
return (FileUploadBean)sessionMap.get(FileUploadBean.getKey(id));
}
/** /**
* @return Returns the name of the file * @return Returns the name of the file
*/ */
private String getFileName(final String id) private String getFileName(final String id)
{ {
// try and retrieve the file and filename from the file upload bean // try and retrieve the file and filename from the file upload bean
// representing the file we previously uploaded. // representing the file we previously uploaded.
final FileUploadBean fileBean = this.getFileUploadBean(id); final FileUploadBean fileBean = this.getFileUploadBean(id);
return fileBean == null ? null : fileBean.getFileName(); return fileBean == null ? null : fileBean.getFileName();
} }
/** /**
* @return Returns the schema file or <tt>null</tt> * @return Returns the schema file or <tt>null</tt>
*/ */
private File getFile(final String id) private File getFile(final String id)
{ {
// try and retrieve the file and filename from the file upload bean // try and retrieve the file and filename from the file upload bean
// representing the file we previously uploaded. // representing the file we previously uploaded.
final FileUploadBean fileBean = this.getFileUploadBean(id); final FileUploadBean fileBean = this.getFileUploadBean(id);
return fileBean != null ? fileBean.getFile() : null; return fileBean != null ? fileBean.getFile() : null;
} }
/** /**
* @return Returns the schema file or <tt>null</tt> * @return Returns the schema file or <tt>null</tt>
*/ */
public File getSchemaFile() public File getSchemaFile()
{ {
return this.getFile("schema"); return this.getFile("schema");
} }
/** /**
* @return Returns the schema file or <tt>null</tt> * @return Returns the schema file or <tt>null</tt>
*/ */
public String getSchemaFileName() public String getSchemaFileName()
{ {
// try and retrieve the file and filename from the file upload bean // try and retrieve the file and filename from the file upload bean
// representing the file we previously uploaded. // representing the file we previously uploaded.
return this.getFileName("schema"); return this.getFileName("schema");
} }
/** /**
* @return Returns the schema file or <tt>null</tt> * @return Returns the schema file or <tt>null</tt>
*/ */
public String getPresentationTemplateFileName() public String getPresentationTemplateFileName()
{ {
return this.getFileName("pt"); return this.getFileName("pt");
} }
/** /**
* @return Returns the presentationTemplate file or <tt>null</tt> * @return Returns the presentationTemplate file or <tt>null</tt>
*/ */
public File getPresentationTemplateFile() public File getPresentationTemplateFile()
{ {
return this.getFile("pt"); return this.getFile("pt");
} }
/** /**
* @return Returns a list of mime types to allow the user to select from * @return Returns a list of mime types to allow the user to select from
*/ */
public List<SelectItem> getCreatePresentationTemplateTypes() public List<SelectItem> getCreatePresentationTemplateTypes()
{ {
return (List<SelectItem>)Arrays.asList(new SelectItem[] { return (List<SelectItem>)Arrays.asList(new SelectItem[] {
new SelectItem("freemarker", "FreeMarker"), new SelectItem("freemarker", "FreeMarker"),
new SelectItem("xslt", "XSLT") new SelectItem("xslt", "XSLT")
}); });
} }
/** /**
* @return Returns the summary data for the wizard. * @return Returns the summary data for the wizard.
*/ */
@@ -312,15 +320,15 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
// TODO: show first few lines of content here? // TODO: show first few lines of content here?
return buildSummary(new String[] { return buildSummary(new String[] {
"Schema File", "Schema File",
"Presentation Template Type", "Presentation Template Type",
"Presentation Template" "Presentation Template"
}, },
new String[] { new String[] {
this.getSchemaFileName(), this.getSchemaFileName(),
this.getPresentationTemplateType(), this.getPresentationTemplateType(),
this.getPresentationTemplateFileName() this.getPresentationTemplateFileName()
}); });
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
@@ -328,7 +336,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Service Injection // Service Injection
/** /**
* @param contentService The contentService to set. * @param contentService The contentService to set.
*/ */
@@ -336,21 +344,21 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
{ {
this.contentService = contentService; this.contentService = contentService;
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Helper Methods // Helper Methods
/** /**
*/ */
protected void clearUpload(final String id) protected void clearUpload(final String id)
{ {
// remove the file upload bean from the session // remove the file upload bean from the session
FacesContext ctx = FacesContext.getCurrentInstance(); FacesContext ctx = FacesContext.getCurrentInstance();
FileUploadBean fileBean = (FileUploadBean) FileUploadBean fileBean = (FileUploadBean)
ctx.getExternalContext().getSessionMap(). ctx.getExternalContext().getSessionMap().
get(FileUploadBean.getKey(id)); get(FileUploadBean.getKey(id));
if (fileBean != null) if (fileBean != null)
fileBean.setFile(null); fileBean.setFile(null);
} }
} }

View File

@@ -278,12 +278,4 @@ public abstract class BaseDialogBean implements IDialogBean
FacesContext.getCurrentInstance(), getErrorMessageId()), FacesContext.getCurrentInstance(), getErrorMessageId()),
exception.getMessage()); exception.getMessage());
} }
protected NodeRef getContainerNodeRef()
{
String nodeId = this.navigator.getCurrentNodeId();
return (nodeId == null
? this.nodeService.getRootNode(Repository.getStoreRef())
: new NodeRef(Repository.getStoreRef(), nodeId));
}
} }

View File

@@ -28,11 +28,14 @@ import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.DownloadContentServlet; import org.alfresco.web.app.servlet.DownloadContentServlet;
import org.alfresco.web.bean.CheckinCheckoutBean; import org.alfresco.web.bean.CheckinCheckoutBean;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.templating.OutputUtil;
import org.alfresco.web.templating.TemplatingService;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
/** /**
@@ -55,6 +58,9 @@ public class AVMEditBean
/** The ContentService bean reference */ /** The ContentService bean reference */
protected ContentService contentService; protected ContentService contentService;
/** The NodeService bean reference */
protected NodeService nodeService;
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Bean property getters and setters // Bean property getters and setters
@@ -83,6 +89,14 @@ public class AVMEditBean
this.contentService = contentService; this.contentService = contentService;
} }
/**
* @param nodeService The nodeService to set.
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/** /**
* @return Returns the current AVM node context. * @return Returns the current AVM node context.
*/ */
@@ -250,14 +264,13 @@ public class AVMEditBean
// commit the transaction // commit the transaction
tx.commit(); tx.commit();
// TODO: generate template content // TODO: regenerate template content
/*if (nodeService.getProperty(node.getNodeRef(), if (nodeService.getProperty(avmRef, TemplatingService.TT_QNAME) != null)
TemplatingService.TT_QNAME) != null)
{ {
OutputUtil.regenerate(node.getNodeRef(), OutputUtil.regenerate(avmRef,
this.contentService, this.contentService,
this.nodeService); this.nodeService);
}*/ }
resetState(); resetState();

View File

@@ -16,8 +16,15 @@
*/ */
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.Serializable;
import java.io.StringReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@@ -29,11 +36,20 @@ import javax.faces.model.SelectItem;
import org.alfresco.config.Config; import org.alfresco.config.Config;
import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigService; import org.alfresco.config.ConfigService;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.content.BaseContentWizard; import org.alfresco.web.bean.content.BaseContentWizard;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.data.IDataContainer; import org.alfresco.web.data.IDataContainer;
import org.alfresco.web.data.QuickSort; import org.alfresco.web.data.QuickSort;
import org.alfresco.web.templating.OutputUtil; import org.alfresco.web.templating.OutputUtil;
@@ -47,11 +63,35 @@ import org.apache.commons.logging.LogFactory;
*/ */
public class CreateWebContentWizard extends BaseContentWizard public class CreateWebContentWizard extends BaseContentWizard
{ {
private static final Log logger = LogFactory.getLog(CreateWebContentWizard.class);
protected String content = null; protected String content = null;
protected String templateTypeName; protected String templateTypeName;
protected List<SelectItem> createMimeTypes; protected List<SelectItem> createMimeTypes;
protected String createdPath = null;
private static final Log logger = LogFactory.getLog(CreateWebContentWizard.class); /** AVM service bean reference */
protected AVMService avmService;
/** AVM Browse Bean reference */
protected AVMBrowseBean avmBrowseBean;
/**
* @param avmService The AVMService to set.
*/
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
/**
* @param avmBrowseBean The AVMBrowseBean to set.
*/
public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean)
{
this.avmBrowseBean = avmBrowseBean;
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
@@ -63,28 +103,69 @@ public class CreateWebContentWizard extends BaseContentWizard
{ {
logger.debug("saving file content to " + this.fileName); logger.debug("saving file content to " + this.fileName);
saveContent(null, this.content); saveContent(null, this.content);
if (this.templateTypeName != null)
if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.templateTypeName != null)
{ {
logger.debug("generating template output for " + this.templateTypeName); logger.debug("generating template output for " + this.templateTypeName);
this.nodeService.setProperty(this.createdNode, this.nodeService.setProperty(AVMNodeConverter.ToNodeRef(-1, this.createdPath),
TemplatingService.TT_QNAME, TemplatingService.TT_QNAME,
this.templateTypeName); this.templateTypeName);
TemplatingService ts = TemplatingService.getInstance(); TemplatingService ts = TemplatingService.getInstance();
TemplateType tt = this.getTemplateType(); TemplateType tt = this.getTemplateType();
OutputUtil.generate(this.createdNode, OutputUtil.generate(this.createdPath.substring(0, this.createdPath.lastIndexOf('/')),
ts.parseXML(this.content), ts.parseXML(this.content),
tt, tt,
this.fileName, this.fileName,
this.getContainerNodeRef(),
this.fileFolderService,
this.contentService, this.contentService,
this.nodeService); this.nodeService,
this.avmService);
} }
// return the default outcome // return the default outcome
return outcome; return outcome;
} }
// ------------------------------------------------------------------------------
// Helper methods
/**
* Save the specified content using the currently set wizard attributes
*
* @param fileContent File content to save
* @param strContent String content to save
*/
protected void saveContent(File fileContent, String strContent) throws Exception
{
// get the parent path of the location to save the content
String path;
AVMNode avmNode = this.avmBrowseBean.getAvmNode();
if (avmNode == null)
{
// create in root of current website
Node websiteNode = this.navigator.getCurrentNode();
String storeRoot = (String)websiteNode.getProperties().get(ContentModel.PROP_AVMSTORE);
path = AVMConstants.buildAVMStoreRootPath(AVMConstants.buildAVMStagingStoreName(storeRoot));
}
else
{
// create in current folder path
path = avmNode.getPath();
}
// put the content of the file into the AVM store
if (fileContent != null)
{
avmService.createFile(path, this.fileName, new BufferedInputStream(new FileInputStream(fileContent)));
}
else
{
avmService.createFile(path, this.fileName, new ByteArrayInputStream((strContent == null ? "" : strContent).getBytes()));
}
// remember the created path
this.createdPath = path + '/' + this.fileName;
}
@Override @Override
public void init(Map<String, String> parameters) public void init(Map<String, String> parameters)
{ {
@@ -117,25 +198,6 @@ public class CreateWebContentWizard extends BaseContentWizard
return disabled; return disabled;
} }
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
// as we were successful, go to the set properties dialog if asked
// to otherwise just return
if (this.showOtherProperties)
{
// we are going to immediately edit the properties so we need
// to setup the BrowseBean context appropriately
this.browseBean.setDocument(new Node(this.createdNode));
return getDefaultFinishOutcome() + AlfrescoNavigationHandler.OUTCOME_SEPARATOR +
"dialog:setContentProperties";
}
else
{
return outcome;
}
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Bean Getters and Setters // Bean Getters and Setters

View File

@@ -16,15 +16,13 @@
*/ */
package org.alfresco.web.templating; package org.alfresco.web.templating;
import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMContext; import org.alfresco.repo.avm.AVMContext;
import org.alfresco.service.cmr.avm.AVMExistsException; import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService; import org.alfresco.service.cmr.repository.ContentService;
@@ -53,7 +51,7 @@ public class OutputUtil
private static String getAVMParentPath(NodeRef nodeRef, private static String getAVMParentPath(NodeRef nodeRef,
NodeService nodeService) NodeService nodeService)
throws Exception throws Exception
{ {
ChildAssociationRef caf = nodeService.getPrimaryParent(nodeRef); ChildAssociationRef caf = nodeService.getPrimaryParent(nodeRef);
final String parentName = (String) final String parentName = (String)
@@ -72,80 +70,47 @@ public class OutputUtil
} }
} }
public static void generate(NodeRef createdNode, public static void generate(String parentPath,
Document xml, Document xml,
TemplateType tt, TemplateType tt,
String fileName, String fileName,
NodeRef containerNodeRef,
FileFolderService fileFolderService,
ContentService contentService, ContentService contentService,
NodeService nodeService) NodeService nodeService,
throws Exception AVMService avmService)
throws Exception
{ {
try try
{ {
// get the node ref of the node that will contain the content // get the node ref of the node that will contain the content
String generatedFileName = stripExtension(fileName) + ".shtml"; String generatedFileName = stripExtension(fileName) + ".shtml";
FileInfo fileInfo =
fileFolderService.create(containerNodeRef, OutputStream fileOut = avmService.createFile(parentPath, generatedFileName);
generatedFileName,
ContentModel.TYPE_CONTENT); String fullAvmPath = parentPath + '/' + generatedFileName;
NodeRef fileNodeRef = fileInfo.getNodeRef();
if (LOGGER.isDebugEnabled()) if (LOGGER.isDebugEnabled())
LOGGER.debug("Created file node for file: " + LOGGER.debug("Created file node for file: " +
generatedFileName); fullAvmPath);
// get a writer for the content and put the file
ContentWriter writer = contentService.getWriter(fileNodeRef,
ContentModel.PROP_CONTENT, true);
// set the mimetype and encoding
writer.setMimetype("text/html");
writer.setEncoding("UTF-8");
TemplateOutputMethod tom = tt.getOutputMethods().get(0); TemplateOutputMethod tom = tt.getOutputMethods().get(0);
OutputStreamWriter out = OutputStreamWriter out = new OutputStreamWriter(fileOut);
new OutputStreamWriter(writer.getContentOutputStream());
tom.generate(xml, tt, out); tom.generate(xml, tt, out);
out.close(); out.close();
nodeService.setProperty(fileNodeRef,
NodeRef outputNodeRef = AVMNodeConverter.ToNodeRef(-1, fullAvmPath);
nodeService.setProperty(outputNodeRef,
TemplatingService.TT_QNAME, TemplatingService.TT_QNAME,
tt.getName()); tt.getName());
LOGGER.debug("generated " + generatedFileName + " using " + tom); LOGGER.debug("generated " + generatedFileName + " using " + tom);
if (createdNode != null) NodeRef createdNodeRef = AVMNodeConverter.ToNodeRef(-1, parentPath + '/' + fileName);
{ nodeService.setProperty(createdNodeRef,
nodeService.setProperty(createdNode, TemplatingService.TT_GENERATED_OUTPUT_QNAME,
TemplatingService.TT_GENERATED_OUTPUT_QNAME, outputNodeRef.toString());
fileNodeRef.toString());
}
AVMService avmService = (AVMService)AVMContext.fgInstance.fAppContext.getBean("avmService"); // TODO: should this output go anywhere in the AVM world now we are writing directly?
final String parentAVMPath = getAVMParentPath(createdNode, nodeService); /*try
try
{
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, generatedFileName));
}
catch (AVMExistsException e)
{
out = new OutputStreamWriter(avmService.getFileOutputStream(parentAVMPath + "/" + generatedFileName));
}
LOGGER.debug("generating " + generatedFileName + " to avm");
tom.generate(xml, tt, out);
out.close();
try
{
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, generatedFileName));
}
catch (AVMExistsException e)
{
out = new OutputStreamWriter(avmService.getFileOutputStream(parentAVMPath + "/" + generatedFileName));
}
LOGGER.debug("generating " + generatedFileName + " to avm");
tom.generate(xml, tt, out);
out.close();
try
{ {
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, fileName)); out = new OutputStreamWriter(avmService.createFile(parentAVMPath, fileName));
} }
@@ -156,7 +121,7 @@ public class OutputUtil
LOGGER.debug("writing xml " + fileName + " to avm"); LOGGER.debug("writing xml " + fileName + " to avm");
final TemplatingService ts = TemplatingService.getInstance(); final TemplatingService ts = TemplatingService.getInstance();
ts.writeXML(xml, out); ts.writeXML(xml, out);
out.close(); out.close();*/
} }
catch (Exception e) catch (Exception e)
{ {
@@ -169,7 +134,7 @@ public class OutputUtil
public static void regenerate(final NodeRef nodeRef, public static void regenerate(final NodeRef nodeRef,
final ContentService contentService, final ContentService contentService,
final NodeService nodeService) final NodeService nodeService)
throws Exception throws Exception
{ {
try try
{ {
@@ -203,14 +168,14 @@ public class OutputUtil
writer.setEncoding("UTF-8"); writer.setEncoding("UTF-8");
// put a loop to generate all output methods // put a loop to generate all output methods
TemplateOutputMethod tom = tt.getOutputMethods().get(0); TemplateOutputMethod tom = tt.getOutputMethods().get(0);
OutputStreamWriter out = OutputStreamWriter out = new OutputStreamWriter(writer.getContentOutputStream());
new OutputStreamWriter(writer.getContentOutputStream());
tom.generate(xml, tt, out); tom.generate(xml, tt, out);
out.close(); out.close();
LOGGER.debug("generated " + fileName + " using " + tom); LOGGER.debug("generated " + fileName + " using " + tom);
AVMService avmService = (AVMService)AVMContext.fgInstance.fAppContext.getBean("avmService"); // TODO: do we need these now - as the NodeRef's above are now AVM NodeRefs...?
/*AVMService avmService = (AVMService)AVMContext.fgInstance.fAppContext.getBean("avmService");
final String parentAVMPath = getAVMParentPath(nodeRef, nodeService); final String parentAVMPath = getAVMParentPath(nodeRef, nodeService);
try try
{ {
@@ -222,9 +187,9 @@ public class OutputUtil
} }
LOGGER.debug("generating " + generatedFileName + " to avm"); LOGGER.debug("generating " + generatedFileName + " to avm");
tom.generate(xml, tt, out); tom.generate(xml, tt, out);
out.close(); out.close();*/
try /*try
{ {
out = new OutputStreamWriter(avmService.createFile(parentAVMPath, fileName)); out = new OutputStreamWriter(avmService.createFile(parentAVMPath, fileName));
} }
@@ -234,7 +199,7 @@ public class OutputUtil
} }
LOGGER.debug("writing xml " + fileName + " to avm"); LOGGER.debug("writing xml " + fileName + " to avm");
ts.writeXML(xml, out); ts.writeXML(xml, out);
out.close(); out.close();*/
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -50,345 +50,342 @@ import org.alfresco.web.bean.repository.Repository;
/** /**
* Provides management of template types. * Provides management of template types.
*/ */
public final class TemplatingService public final class TemplatingService implements Serializable
implements Serializable
{ {
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/**
/** * Encapsulation of configuration file management.
* Encapsulation of configuration file management. */
*/ private static class Configuration
private static class Configuration {
{ /** indicates whether or not the configuration file has been loaded */
public static boolean loaded = false;
/** indicates whether or not the configuration file has been loaded */ private static NodeRef configFileNodeRef = null;
public static boolean loaded = false;
private static NodeRef configFileNodeRef = null; /**
* locate the configuration file. currently it is stored as
/** * <tt>templating_config.xml</tt> at the root of the data dictionary.
* locate the configuration file. currently it is stored as *
* <tt>templating_config.xml</tt> at the root of the data dictionary. * @return the configuration file, which is currently all the
* * <tt>TemplateTypes</tt> serialized using object serialization.
* @return the configuration file, which is currently all the */
* <tt>TemplateTypes</tt> serialized using object serialization. private static NodeRef getConfigFile()
*/ {
private static NodeRef getConfigFile() if (configFileNodeRef == null)
{ {
if (configFileNodeRef == null) final TemplatingService ts = TemplatingService.INSTANCE;
{ LOGGER.debug("loading config file");
final TemplatingService ts = TemplatingService.INSTANCE; // get the template from the special Email Templates folder
LOGGER.debug("loading config file"); FacesContext fc = FacesContext.getCurrentInstance();
// get the template from the special Email Templates folder String xpath = (Application.getRootPath(fc) + "/" +
FacesContext fc = FacesContext.getCurrentInstance(); Application.getGlossaryFolderName(fc));
String xpath = (Application.getRootPath(fc) + "/" + NodeRef rootNodeRef = ts.nodeService.getRootNode(Repository.getStoreRef());
Application.getGlossaryFolderName(fc)); List<NodeRef> results = ts.searchService.selectNodes(rootNodeRef, xpath, null, ts.namespaceService, false);
NodeRef rootNodeRef = ts.nodeService.getRootNode(Repository.getStoreRef()); if (results.size() != 1)
List<NodeRef> results = ts.searchService.selectNodes(rootNodeRef, xpath, null, ts.namespaceService, false); throw new RuntimeException("expected one result for " + xpath);
if (results.size() != 1) NodeRef dataDictionaryNodeRef = results.get(0);
throw new RuntimeException("expected one result for " + xpath); LOGGER.debug("loaded data dictionary " + dataDictionaryNodeRef);
NodeRef dataDictionaryNodeRef = results.get(0); try
LOGGER.debug("loaded data dictionary " + dataDictionaryNodeRef); {
try Configuration.configFileNodeRef =
{ ts.fileFolderService.create(dataDictionaryNodeRef,
Configuration.configFileNodeRef = "templating_configuration.xml",
ts.fileFolderService.create(dataDictionaryNodeRef, ContentModel.TYPE_CONTENT).getNodeRef();
"templating_configuration.xml", }
ContentModel.TYPE_CONTENT).getNodeRef(); catch (FileExistsException fee)
} {
catch (FileExistsException fee) Configuration.configFileNodeRef =
{ ts.fileFolderService.searchSimple(dataDictionaryNodeRef, "templating_configuration.xml");
Configuration.configFileNodeRef = }
ts.fileFolderService.searchSimple(dataDictionaryNodeRef, "templating_configuration.xml"); LOGGER.debug("loaded config file " + configFileNodeRef);
} assert Configuration.configFileNodeRef != null : "unable to load templating_configuration.xml";
LOGGER.debug("loaded config file " + configFileNodeRef); }
assert Configuration.configFileNodeRef != null : "unable to load templating_configuration.xml"; return Configuration.configFileNodeRef;
} }
return Configuration.configFileNodeRef;
} /**
* Load the configuration file into the templating service.
/** */
* Load the configuration file into the templating service. public static void load()
*/ throws IOException
public static void load() {
throws IOException final TemplatingService ts = TemplatingService.INSTANCE;
{ final NodeRef configFileNodeRef = getConfigFile();
final TemplatingService ts = TemplatingService.INSTANCE; FacesContext fc = FacesContext.getCurrentInstance();
final NodeRef configFileNodeRef = getConfigFile(); final ContentReader contentReader = ts.contentService.getReader(configFileNodeRef,
FacesContext fc = FacesContext.getCurrentInstance(); ContentModel.TYPE_CONTENT);
final ContentReader contentReader = ts.contentService.getReader(configFileNodeRef, if (contentReader == null)
ContentModel.TYPE_CONTENT); LOGGER.debug("templating_config.xml is empty");
if (contentReader == null) else
LOGGER.debug("templating_config.xml is empty"); {
else LOGGER.debug("parsing templating_config.xml");
{ final InputStream contentIn = contentReader.getContentInputStream();
LOGGER.debug("parsing templating_config.xml"); final ObjectInputStream in = new ObjectInputStream(contentIn);
final InputStream contentIn = contentReader.getContentInputStream(); try
final ObjectInputStream in = new ObjectInputStream(contentIn); {
try while (true)
{ {
while (true) try
{ {
try final TemplateType tt = (TemplateType)in.readObject();
{ TemplatingService.INSTANCE.registerTemplateType(tt);
final TemplateType tt = (TemplateType)in.readObject(); }
TemplatingService.INSTANCE.registerTemplateType(tt); catch (EOFException eof)
} {
catch (EOFException eof) break;
{ }
break;
} }
in.close();
} }
in.close(); catch (ClassNotFoundException cnfe)
} {
catch (ClassNotFoundException cnfe) TemplatingService.LOGGER.error(cnfe);
{ }
TemplatingService.LOGGER.error(cnfe); }
} loaded = true;
} }
loaded = true;
} /**
* Save the current state of the templating service to the configuration file.
/** */
* Save the current state of the templating service to the configuration file. public static void save()
*/ throws IOException
public static void save() {
throws IOException final TemplatingService ts = TemplatingService.INSTANCE;
{ FacesContext fc = FacesContext.getCurrentInstance();
final TemplatingService ts = TemplatingService.INSTANCE; final NodeRef configFileNodeRef = getConfigFile();
FacesContext fc = FacesContext.getCurrentInstance(); final OutputStream contentOut = ts.contentService.getWriter(configFileNodeRef, ContentModel.TYPE_CONTENT, true).getContentOutputStream();
final NodeRef configFileNodeRef = getConfigFile(); final ObjectOutputStream out = new ObjectOutputStream(contentOut);
final OutputStream contentOut = ts.contentService.getWriter(configFileNodeRef, ContentModel.TYPE_CONTENT, true).getContentOutputStream(); for (TemplateType tt : TemplatingService.INSTANCE.getTemplateTypes())
final ObjectOutputStream out = new ObjectOutputStream(contentOut); {
for (TemplateType tt : TemplatingService.INSTANCE.getTemplateTypes()) out.writeObject(tt);
{ }
out.writeObject(tt); out.close();
} }
out.close(); }
}
} ////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////// /**
* temporary location of the property on nodes that are xml files created
/** * by templating.
* temporary location of the property on nodes that are xml files created */
* by templating. public static final org.alfresco.service.namespace.QName TT_QNAME =
*/ org.alfresco.service.namespace.QName.createQName(org.alfresco.service.namespace.NamespaceService.CONTENT_MODEL_1_0_URI, "tt");
public static final org.alfresco.service.namespace.QName TT_QNAME =
org.alfresco.service.namespace.QName.createQName(org.alfresco.service.namespace.NamespaceService.CONTENT_MODEL_1_0_URI, "tt"); /**
* temporary location of the property on nodes generated from xml assets.
/** */
* temporary location of the property on nodes generated from xml assets. public static final org.alfresco.service.namespace.QName TT_GENERATED_OUTPUT_QNAME =
*/ org.alfresco.service.namespace.QName.createQName(org.alfresco.service.namespace.NamespaceService.CONTENT_MODEL_1_0_URI, "tt_generated_output");
public static final org.alfresco.service.namespace.QName TT_GENERATED_OUTPUT_QNAME =
org.alfresco.service.namespace.QName.createQName(org.alfresco.service.namespace.NamespaceService.CONTENT_MODEL_1_0_URI, "tt_generated_output"); private static final Log LOGGER = LogFactory.getLog(TemplatingService.class);
private static final Log LOGGER = LogFactory.getLog(TemplatingService.class); /** the single instance initialized using spring */
private static TemplatingService INSTANCE;
/** the single instance initialized using spring */
private static TemplatingService INSTANCE; /** internal storage of template types, keyed by the template name */
private HashMap<String, TemplateType> templateTypes =
/** internal storage of template types, keyed by the template name */ new HashMap<String, TemplateType>();
private HashMap<String, TemplateType> templateTypes =
new HashMap<String, TemplateType>(); private final ContentService contentService;
private final NodeService nodeService;
private final ContentService contentService; private final FileFolderService fileFolderService;
private final NodeService nodeService; private final DictionaryService dictionaryService;
private final FileFolderService fileFolderService; private final NamespaceService namespaceService;
private final DictionaryService dictionaryService; private final SearchService searchService;
private final NamespaceService namespaceService;
private final SearchService searchService; /** instantiated using spring */
public TemplatingService(final ContentService contentService,
/** instantiated using spring */ final NodeService nodeService,
public TemplatingService(final ContentService contentService, final FileFolderService fileFolderService,
final NodeService nodeService, final DictionaryService dictionaryService,
final FileFolderService fileFolderService, final NamespaceService namespaceService,
final DictionaryService dictionaryService, final SearchService searchService)
final NamespaceService namespaceService, {
final SearchService searchService) this.contentService = contentService;
{ this.nodeService = nodeService;
this.contentService = contentService; this.fileFolderService = fileFolderService;
this.nodeService = nodeService; this.dictionaryService = dictionaryService;
this.fileFolderService = fileFolderService; this.namespaceService = namespaceService;
this.dictionaryService = dictionaryService; this.searchService = searchService;
this.namespaceService = namespaceService; if (INSTANCE == null)
this.searchService = searchService; INSTANCE = this;
if (INSTANCE == null) }
INSTANCE = this;
} /** Provides the templating service instance, loads config if necessary */
public static TemplatingService getInstance()
/** Provides the templating service instance, loads config if necessary */ {
public static TemplatingService getInstance() if (!Configuration.loaded)
{ {
if (!Configuration.loaded) LOGGER.debug("loading configuration");
{ try
LOGGER.debug("loading configuration"); {
try Configuration.load();
{ }
Configuration.load(); catch (Throwable t)
} {
catch (Throwable t) LOGGER.error(t);
{ t.printStackTrace();
LOGGER.error(t); }
t.printStackTrace(); }
}
} return TemplatingService.INSTANCE;
}
return TemplatingService.INSTANCE;
} /** returns all registered template types */
public Collection<TemplateType> getTemplateTypes()
/** returns all registered template types */ {
public Collection<TemplateType> getTemplateTypes() return this.templateTypes.values();
{ }
return this.templateTypes.values();
} /** return the template type by name or <tt>null</tt> if not found */
public TemplateType getTemplateType(final String name)
/** return the template type by name or <tt>null</tt> if not found */ {
public TemplateType getTemplateType(final String name) return this.templateTypes.get(name);
{ }
return this.templateTypes.get(name);
} /** registers a template type. if one exists with the same name, it is replaced */
public void registerTemplateType(final TemplateType tt)
/** registers a template type. if one exists with the same name, it is replaced */ {
public void registerTemplateType(final TemplateType tt) this.templateTypes.put(tt.getName(), tt);
{ try
this.templateTypes.put(tt.getName(), tt); {
try Configuration.save();
{ }
Configuration.save(); catch (IOException ioe)
} {
catch (IOException ioe) LOGGER.error(ioe);
{ }
LOGGER.error(ioe); }
}
} /**
* instantiate a template type. for now this will always generate the
/** * xforms implementation, but will at some point be configurable such that
* instantiate a template type. for now this will always generate the * the template type implementation can be configured for the system,
* xforms implementation, but will at some point be configurable such that * or specified in the gui.
* the template type implementation can be configured for the system, */
* or specified in the gui. public TemplateType newTemplateType(final String name,
*/ final NodeRef schemaNodeRef)
public TemplateType newTemplateType(final String name, {
final NodeRef schemaNodeRef) return new TemplateTypeImpl(name, schemaNodeRef);
{ }
return new TemplateTypeImpl(name, schemaNodeRef);
} /** utility function for creating a document */
public Document newDocument()
/** utility function for creating a document */ {
public Document newDocument() try
{ {
try final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
{ dbf.setNamespaceAware(true);
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false);
dbf.setNamespaceAware(true); final DocumentBuilder db = dbf.newDocumentBuilder();
dbf.setValidating(false); return db.newDocument();
final DocumentBuilder db = dbf.newDocumentBuilder(); }
return db.newDocument(); catch (ParserConfigurationException pce)
} {
catch (ParserConfigurationException pce) assert false : pce;
{ LOGGER.error(pce);
assert false : pce; return null;
LOGGER.error(pce); }
return null; // catch (SAXException saxe)
} // {
// catch (SAXException saxe) // LOGGER.error(saxe);
// { // }
// LOGGER.error(saxe); // catch (IOException ioe)
// } // {
// catch (IOException ioe) // LOGGER.error(ioe);
// { // }
// LOGGER.error(ioe); }
// }
} /** utility function for serializing a node */
public void writeXML(final Node n, final Writer output)
/** utility function for serializing a node */ {
public void writeXML(final Node n, final Writer output) try
{ {
try final TransformerFactory tf = TransformerFactory.newInstance();
{ final Transformer t = tf.newTransformer();
final TransformerFactory tf = TransformerFactory.newInstance(); t.setOutputProperty(OutputKeys.INDENT, "yes");
final Transformer t = tf.newTransformer();
t.setOutputProperty(OutputKeys.INDENT, "yes"); if (LOGGER.isDebugEnabled())
{
if (LOGGER.isDebugEnabled()) LOGGER.debug("writing out a document for " +
{ (n instanceof Document
LOGGER.debug("writing out a document for " + ? ((Document)n).getDocumentElement()
(n instanceof Document : n).getNodeName() +
? ((Document)n).getDocumentElement() " to " + output);
: n).getNodeName() + final StringWriter sw = new StringWriter();
" to " + output); t.transform(new DOMSource(n), new StreamResult(sw));
final StringWriter sw = new StringWriter(); LOGGER.debug(sw.toString());
t.transform(new DOMSource(n), new StreamResult(sw)); }
LOGGER.debug(sw.toString()); t.transform(new DOMSource(n), new StreamResult(output));
} }
t.transform(new DOMSource(n), new StreamResult(output)); catch (TransformerException te)
} {
catch (TransformerException te) te.printStackTrace();
{ assert false : te.getMessage();
te.printStackTrace(); }
assert false : te.getMessage(); }
}
} /** utility function for serializing a node */
public void writeXML(final Node n, final File output)
/** utility function for serializing a node */ throws IOException
public void writeXML(final Node n, final File output) {
throws IOException this.writeXML(n, new FileWriter(output));
{ }
this.writeXML(n, new FileWriter(output));
} /** utility function for serializing a node */
public String writeXMLToString(final Node n)
/** utility function for serializing a node */ {
public String writeXMLToString(final Node n) final StringWriter result = new StringWriter();
{ this.writeXML(n, result);
final StringWriter result = new StringWriter(); return result.toString();
this.writeXML(n, result); }
return result.toString();
} /** utility function for parsing xml */
public Document parseXML(final String source)
/** utility function for parsing xml */ throws ParserConfigurationException,
public Document parseXML(final String source) SAXException,
throws ParserConfigurationException, IOException
SAXException, {
IOException return this.parseXML(new ByteArrayInputStream(source.getBytes()));
{ }
return this.parseXML(new ByteArrayInputStream(source.getBytes()));
} /** utility function for parsing xml */
public Document parseXML(final NodeRef nodeRef)
/** utility function for parsing xml */ throws ParserConfigurationException,
public Document parseXML(final NodeRef nodeRef) SAXException,
throws ParserConfigurationException, IOException
SAXException, {
IOException final ContentReader contentReader =
{ this.contentService.getReader(nodeRef, ContentModel.TYPE_CONTENT);
final ContentReader contentReader = final InputStream in = contentReader.getContentInputStream();
this.contentService.getReader(nodeRef, ContentModel.TYPE_CONTENT); return this.parseXML(in);
final InputStream in = contentReader.getContentInputStream(); }
return this.parseXML(in);
} /** utility function for parsing xml */
public Document parseXML(final File source)
/** utility function for parsing xml */ throws ParserConfigurationException,
public Document parseXML(final File source) SAXException,
throws ParserConfigurationException, IOException
SAXException, {
IOException return this.parseXML(new FileInputStream(source));
{ }
return this.parseXML(new FileInputStream(source));
} /** utility function for parsing xml */
public Document parseXML(final InputStream source)
/** utility function for parsing xml */ throws ParserConfigurationException,
public Document parseXML(final InputStream source) SAXException,
throws ParserConfigurationException, IOException
SAXException, {
IOException final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
{ dbf.setNamespaceAware(true);
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false);
dbf.setNamespaceAware(true); final DocumentBuilder db = dbf.newDocumentBuilder();
dbf.setValidating(false); final Document result = db.parse(source);
final DocumentBuilder db = dbf.newDocumentBuilder(); source.close();
final Document result = db.parse(source); return result;
source.close(); }
return result;
}
} }

View File

@@ -569,6 +569,14 @@
<property-name>dictionaryService</property-name> <property-name>dictionaryService</property-name>
<value>#{DictionaryService}</value> <value>#{DictionaryService}</value>
</managed-property> </managed-property>
<managed-property>
<property-name>avmService</property-name>
<value>#{AVMService}</value>
</managed-property>
<managed-property>
<property-name>avmBrowseBean</property-name>
<value>#{AVMBrowseBean}</value>
</managed-property>
</managed-bean> </managed-bean>
<managed-bean> <managed-bean>

View File

@@ -74,6 +74,9 @@
<div class="mainSubText"><h:outputText value="#{msg.sandbox_info}" id="msg3" /></div> <div class="mainSubText"><h:outputText value="#{msg.sandbox_info}" id="msg3" /></div>
<div class="mainSubText"><h:outputText value="#{NavigationBean.nodeProperties.description}" id="msg4" /></div> <div class="mainSubText"><h:outputText value="#{NavigationBean.nodeProperties.description}" id="msg4" /></div>
</td> </td>
<td align=right>
<a:actionLink value="#{msg.sandbox_create}" image="/images/icons/new_content.gif" actionListener="#{AVMBrowseBean.setupSandboxAction}" action="wizard:createWebContent" />
</td>
</tr> </tr>
</table> </table>