mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
. WCM UI
- 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:
@@ -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
|
||||||
|
@@ -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"
|
||||||
|
@@ -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);
|
||||||
|
@@ -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,
|
||||||
|
@@ -57,7 +57,6 @@ import org.xml.sax.SAXException;
|
|||||||
*/
|
*/
|
||||||
public class CreateXmlContentTypeWizard extends BaseWizardBean
|
public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||||
{
|
{
|
||||||
|
|
||||||
private final static Log LOGGER =
|
private final static Log LOGGER =
|
||||||
LogFactory.getLog(CreateXmlContentTypeWizard.class);
|
LogFactory.getLog(CreateXmlContentTypeWizard.class);
|
||||||
|
|
||||||
@@ -72,10 +71,18 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
|||||||
throws Exception
|
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 = this.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 =
|
FileInfo fileInfo = this.fileFolderService.create(containerNodeRef,
|
||||||
this.fileFolderService.create(containerNodeRef,
|
|
||||||
this.getSchemaFileName(),
|
this.getSchemaFileName(),
|
||||||
ContentModel.TYPE_CONTENT);
|
ContentModel.TYPE_CONTENT);
|
||||||
final NodeRef schemaFileNodeRef = fileInfo.getNodeRef();
|
final NodeRef schemaFileNodeRef = fileInfo.getNodeRef();
|
||||||
@@ -204,6 +211,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Bean Getters and Setters
|
// Bean Getters and Setters
|
||||||
|
|
||||||
|
@@ -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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -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();
|
||||||
|
|
||||||
|
@@ -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
|
||||||
|
@@ -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;
|
||||||
@@ -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,
|
||||||
|
AVMService avmService)
|
||||||
throws Exception
|
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,
|
||||||
fileNodeRef.toString());
|
outputNodeRef.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)
|
||||||
{
|
{
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
@@ -50,10 +50,8 @@ 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
|
|
||||||
{
|
{
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,7 +59,6 @@ public final class TemplatingService
|
|||||||
*/
|
*/
|
||||||
private static class Configuration
|
private static class Configuration
|
||||||
{
|
{
|
||||||
|
|
||||||
/** indicates whether or not the configuration file has been loaded */
|
/** indicates whether or not the configuration file has been loaded */
|
||||||
public static boolean loaded = false;
|
public static boolean loaded = false;
|
||||||
private static NodeRef configFileNodeRef = null;
|
private static NodeRef configFileNodeRef = null;
|
||||||
|
@@ -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>
|
||||||
|
@@ -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>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user