fixing up templating codebase from merge. it should all be basically working again now...

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3711 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2006-09-07 00:55:20 +00:00
parent cc6af1a45c
commit 1c79ac48f4
5 changed files with 208 additions and 90 deletions

View File

@@ -233,6 +233,7 @@ remove_user=Remove User
create_space=Create Space create_space=Create Space
add_content=Add Content add_content=Add Content
create_content=Create Content create_content=Create Content
create_xml_content_type=Create XML Content Type
add_multiple_files=Add Multiple Files add_multiple_files=Add Multiple Files
import_directory=Import Directory import_directory=Import Directory
advanced_space_wizard=Advanced Space Wizard advanced_space_wizard=Advanced Space Wizard
@@ -634,6 +635,16 @@ select_type=Select Type
content=Content content=Content
text_content=Plain Text Content text_content=Plain Text Content
html_content=HTML Content html_content=HTML Content
xml_content=XML Content
create_xml_content_type_title=Create XML Content Type Wizard
create_xml_content_type_desc=Create XML Content Type
create_xml_content_type_step1_title=Upload an XML Schema
create_xml_content_type_step1_desc=Upload an XML Schema
create_xml_content_type_step2_title=Edit the XML Schema
create_xml_content_type_step2_desc=This is the generated XForm based on the schema provided.
edit_xml_schema=Edit XML Schema
template_type=Template Type
configure_presentation_templates=Configure Presentation Templates
# Rule and Action Wizard messages # Rule and Action Wizard messages
run_action_title=Run Action Wizard run_action_title=Run Action Wizard

View File

@@ -46,6 +46,8 @@ 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;
@@ -375,8 +377,8 @@ public class CheckinCheckoutBean
*/ */
private Node setupContentDocument(String id) private Node setupContentDocument(String id)
{ {
if (logger.isDebugEnabled()) if (LOGGER.isDebugEnabled())
logger.debug("Setup for action, setting current document to: " + id); LOGGER.debug("Setup for action, setting current document to: " + id);
Node node = null; Node node = null;
@@ -426,14 +428,14 @@ public class CheckinCheckoutBean
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance()); tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
tx.begin(); tx.begin();
if (logger.isDebugEnabled()) if (LOGGER.isDebugEnabled())
logger.debug("Trying to checkout content node Id: " + node.getId()); LOGGER.debug("Trying to checkout content node Id: " + node.getId());
// checkout the node content to create a working copy // checkout the node content to create a working copy
if (logger.isDebugEnabled()) if (LOGGER.isDebugEnabled())
{ {
logger.debug("Checkout copy location: " + getCopyLocation()); LOGGER.debug("Checkout copy location: " + getCopyLocation());
logger.debug("Selected Space Id: " + this.selectedSpaceId); LOGGER.debug("Selected Space Id: " + this.selectedSpaceId);
} }
NodeRef workingCopyRef; NodeRef workingCopyRef;
if (getCopyLocation().equals(COPYLOCATION_OTHER) && this.selectedSpaceId != null) if (getCopyLocation().equals(COPYLOCATION_OTHER) && this.selectedSpaceId != null)
@@ -477,7 +479,7 @@ public class CheckinCheckoutBean
} }
else else
{ {
logger.warn("WARNING: checkoutFile called without a current Document!"); LOGGER.warn("WARNING: checkoutFile called without a current Document!");
} }
return outcome; return outcome;
@@ -508,7 +510,7 @@ public class CheckinCheckoutBean
} }
else else
{ {
logger.warn("WARNING: checkoutFileOK called without a current WorkingDocument!"); LOGGER.warn("WARNING: checkoutFileOK called without a current WorkingDocument!");
} }
return outcome; return outcome;
@@ -533,7 +535,7 @@ public class CheckinCheckoutBean
} }
else else
{ {
logger.warn("WARNING: editFileOK called without a current Document!"); LOGGER.warn("WARNING: editFileOK called without a current Document!");
} }
return outcome; return outcome;
@@ -572,12 +574,18 @@ public class CheckinCheckoutBean
MimetypeMap.MIMETYPE_JAVASCRIPT.equals(mimetype)) MimetypeMap.MIMETYPE_JAVASCRIPT.equals(mimetype))
{ {
// make content available to the editing screen // make content available to the editing screen
setEditorOutput(reader.getContentString()); String contentString = reader.getContentString();
setDocumentContent(contentString);
setEditorOutput(contentString);
// navigate to appropriate screen // navigate to appropriate screen
FacesContext fc = FacesContext.getCurrentInstance(); FacesContext fc = FacesContext.getCurrentInstance();
this.navigator.setupDispatchContext(node); this.navigator.setupDispatchContext(node);
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:editTextInline"); String s = (MimetypeMap.MIMETYPE_XML.equals(mimetype)
? "dialog:editXmlInline"
: "dialog:editTextInline");
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, s);
} }
else else
{ {
@@ -620,8 +628,8 @@ public class CheckinCheckoutBean
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance()); tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
tx.begin(); tx.begin();
if (logger.isDebugEnabled()) if (LOGGER.isDebugEnabled())
logger.debug("Trying to update content node Id: " + node.getId()); LOGGER.debug("Trying to update content node Id: " + node.getId());
// get an updating writer that we can use to modify the content on the current node // get an updating writer that we can use to modify the content on the current node
ContentWriter writer = this.contentService.getWriter(node.getNodeRef(), ContentModel.PROP_CONTENT, true); ContentWriter writer = this.contentService.getWriter(node.getNodeRef(), ContentModel.PROP_CONTENT, true);
@@ -630,6 +638,14 @@ 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);
@@ -648,7 +664,7 @@ public class CheckinCheckoutBean
} }
else else
{ {
logger.warn("WARNING: editInlineOK called without a current Document!"); LOGGER.warn("WARNING: editInlineOK called without a current Document!");
} }
return outcome; return outcome;
@@ -681,7 +697,7 @@ public class CheckinCheckoutBean
} }
else else
{ {
logger.warn("WARNING: undoCheckout called without a current WorkingDocument!"); LOGGER.warn("WARNING: undoCheckout called without a current WorkingDocument!");
} }
return outcome; return outcome;
@@ -730,7 +746,7 @@ public class CheckinCheckoutBean
} }
else else
{ {
logger.warn("WARNING: undoCheckout called without a current WorkingDocument!"); LOGGER.warn("WARNING: undoCheckout called without a current WorkingDocument!");
} }
return outcome; return outcome;
@@ -755,8 +771,8 @@ public class CheckinCheckoutBean
tx = Repository.getUserTransaction(context); tx = Repository.getUserTransaction(context);
tx.begin(); tx.begin();
if (logger.isDebugEnabled()) if (LOGGER.isDebugEnabled())
logger.debug("Trying to checkin content node Id: " + node.getId()); LOGGER.debug("Trying to checkin content node Id: " + node.getId());
// we can either checkin the content from the current working copy node // we can either checkin the content from the current working copy node
// which would have been previously updated by the user // which would have been previously updated by the user
@@ -821,7 +837,7 @@ public class CheckinCheckoutBean
} }
else else
{ {
logger.warn("WARNING: checkinFileOK called without a current Document!"); LOGGER.warn("WARNING: checkinFileOK called without a current Document!");
} }
return outcome; return outcome;
@@ -846,8 +862,8 @@ public class CheckinCheckoutBean
tx = Repository.getUserTransaction(context); tx = Repository.getUserTransaction(context);
tx.begin(); tx.begin();
if (logger.isDebugEnabled()) if (LOGGER.isDebugEnabled())
logger.debug("Trying to update content node Id: " + node.getId()); LOGGER.debug("Trying to update content node Id: " + node.getId());
// get an updating writer that we can use to modify the content on the current node // get an updating writer that we can use to modify the content on the current node
ContentWriter writer = this.contentService.getWriter(node.getNodeRef(), ContentModel.PROP_CONTENT, true); ContentWriter writer = this.contentService.getWriter(node.getNodeRef(), ContentModel.PROP_CONTENT, true);
@@ -877,7 +893,7 @@ public class CheckinCheckoutBean
} }
else else
{ {
logger.warn("WARNING: updateFileOK called without a current Document!"); LOGGER.warn("WARNING: updateFileOK called without a current Document!");
} }
return outcome; return outcome;
@@ -922,7 +938,7 @@ public class CheckinCheckoutBean
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Private data // Private data
private static Log logger = LogFactory.getLog(CheckinCheckoutBean.class); private static final Log LOGGER = LogFactory.getLog(CheckinCheckoutBean.class);
/** I18N messages */ /** I18N messages */
private static final String MSG_ERROR_CHECKIN = "error_checkin"; private static final String MSG_ERROR_CHECKIN = "error_checkin";

View File

@@ -1,6 +1,23 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean.content; package org.alfresco.web.bean.content;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@@ -18,9 +35,17 @@ import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
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.*;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.ContentWriter;
import java.io.OutputStreamWriter;
import org.alfresco.web.app.servlet.FacesHelper;
/** /**
* Bean implementation for the "Create Content Wizard" dialog * Bean implementation for the "Create Content Wizard" dialog
* *
@@ -29,10 +54,12 @@ import org.apache.commons.logging.LogFactory;
public class CreateContentWizard extends BaseContentWizard public class CreateContentWizard extends BaseContentWizard
{ {
protected String content = null; protected String content = null;
protected String templateTypeName;
protected List<SelectItem> createMimeTypes; protected List<SelectItem> createMimeTypes;
private static Log logger = LogFactory.getLog(CreateContentWizard.class); private static final Log LOGGER =
LogFactory.getLog(CreateContentWizard.class);
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Wizard implementation // Wizard implementation
@@ -41,7 +68,25 @@ public class CreateContentWizard extends BaseContentWizard
protected String finishImpl(FacesContext context, String outcome) protected String finishImpl(FacesContext context, String outcome)
throws Exception throws Exception
{ {
LOGGER.debug("saving file content to " + this.fileName);
saveContent(null, this.content); saveContent(null, this.content);
if (this.templateTypeName != null)
{
LOGGER.debug("generating template output for " + this.templateTypeName);
this.nodeService.setProperty(this.createdNode,
TemplatingService.TT_QNAME,
this.templateTypeName);
TemplatingService ts = TemplatingService.getInstance();
TemplateType tt = this.getTemplateType();
OutputUtil.generate(this.createdNode,
ts.parseXML(this.content),
tt,
this.fileName,
this.getContainerNodeRef(),
this.fileFolderService,
this.contentService,
this.nodeService);
}
// return the default outcome // return the default outcome
return outcome; return outcome;
@@ -54,6 +99,7 @@ public class CreateContentWizard extends BaseContentWizard
this.content = null; this.content = null;
this.inlineEdit = true; this.inlineEdit = true;
this.templateTypeName = null;
this.mimeType = MimetypeMap.MIMETYPE_HTML; this.mimeType = MimetypeMap.MIMETYPE_HTML;
} }
@@ -117,6 +163,20 @@ public class CreateContentWizard extends BaseContentWizard
this.content = content; this.content = content;
} }
public List<SelectItem> getCreateTemplateTypes()
{
Collection<TemplateType> ttl = TemplatingService.getInstance().getTemplateTypes();
List<SelectItem> sil = new ArrayList<SelectItem>(ttl.size());
for (TemplateType tt : ttl)
{
sil.add(new SelectItem(tt.getName(), tt.getName()));
}
QuickSort sorter = new QuickSort(sil, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
return sil;
}
/** /**
* @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
*/ */
@@ -153,12 +213,12 @@ public class CreateContentWizard extends BaseContentWizard
} }
else else
{ {
logger.warn("Could not find 'create-mime-types' configuration element"); LOGGER.warn("Could not find 'create-mime-types' configuration element");
} }
} }
else else
{ {
logger.warn("Could not find 'Content Wizards' configuration section"); LOGGER.warn("Could not find 'Content Wizards' configuration section");
} }
} }
@@ -166,6 +226,25 @@ public class CreateContentWizard extends BaseContentWizard
return this.createMimeTypes; return this.createMimeTypes;
} }
public String getTemplateTypeName()
{
return this.templateTypeName;
}
public TemplateType getTemplateType()
{
final TemplatingService ts = TemplatingService.getInstance();
return ts.getTemplateType(this.getTemplateTypeName());
}
/**
* @param templateType Sets the currently selected template type
*/
public void setTemplateTypeName(final String templateTypeName)
{
this.templateTypeName = templateTypeName;
}
/** /**
* @return Returns the summary data for the wizard. * @return Returns the summary data for the wizard.
*/ */

View File

@@ -64,6 +64,7 @@ public final class TemplatingService
/** 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;
/** /**
* locate the configuration file. currently it is stored as * locate the configuration file. currently it is stored as
@@ -73,6 +74,8 @@ public final class TemplatingService
* <tt>TemplateTypes</tt> serialized using object serialization. * <tt>TemplateTypes</tt> serialized using object serialization.
*/ */
private static NodeRef getConfigFile() private static NodeRef getConfigFile()
{
if (configFileNodeRef == null)
{ {
final TemplatingService ts = TemplatingService.INSTANCE; final TemplatingService ts = TemplatingService.INSTANCE;
LOGGER.debug("loading config file"); LOGGER.debug("loading config file");
@@ -86,28 +89,22 @@ public final class TemplatingService
throw new RuntimeException("expected one result for " + xpath); throw new RuntimeException("expected one result for " + xpath);
NodeRef dataDictionaryNodeRef = results.get(0); NodeRef dataDictionaryNodeRef = results.get(0);
LOGGER.debug("loaded data dictionary " + dataDictionaryNodeRef); LOGGER.debug("loaded data dictionary " + dataDictionaryNodeRef);
NodeRef configFileNodeRef = null;
try try
{ {
configFileNodeRef = ts.fileFolderService.create(dataDictionaryNodeRef, Configuration.configFileNodeRef =
ts.fileFolderService.create(dataDictionaryNodeRef,
"templating_configuration.xml", "templating_configuration.xml",
ContentModel.TYPE_CONTENT).getNodeRef(); ContentModel.TYPE_CONTENT).getNodeRef();
} }
catch (FileExistsException fee) catch (FileExistsException fee)
{ {
List<FileInfo> l = ts.fileFolderService.search(dataDictionaryNodeRef, Configuration.configFileNodeRef =
"templating_configuration.xml", ts.fileFolderService.searchSimple(dataDictionaryNodeRef, "templating_configuration.xml");
true,
false,
false);
if (l.size() != 1)
{
throw new RuntimeException("expected one templating_configuration.xml in " + dataDictionaryNodeRef);
}
configFileNodeRef= l.get(0).getNodeRef();
} }
LOGGER.debug("loaded config file " + configFileNodeRef); LOGGER.debug("loaded config file " + configFileNodeRef);
return configFileNodeRef; assert Configuration.configFileNodeRef != null : "unable to load templating_configuration.xml";
}
return Configuration.configFileNodeRef;
} }
/** /**
@@ -119,9 +116,14 @@ public final class TemplatingService
final TemplatingService ts = TemplatingService.INSTANCE; final TemplatingService ts = TemplatingService.INSTANCE;
final NodeRef configFileNodeRef = getConfigFile(); final NodeRef configFileNodeRef = getConfigFile();
FacesContext fc = FacesContext.getCurrentInstance(); FacesContext fc = FacesContext.getCurrentInstance();
final InputStream contentIn = final ContentReader contentReader = ts.contentService.getReader(configFileNodeRef,
ts.contentService.getReader(configFileNodeRef, ContentModel.TYPE_CONTENT);
ContentModel.TYPE_CONTENT).getContentInputStream(); if (contentReader == null)
LOGGER.debug("templating_config.xml is empty");
else
{
LOGGER.debug("parsing templating_config.xml");
final InputStream contentIn = contentReader.getContentInputStream();
final ObjectInputStream in = new ObjectInputStream(contentIn); final ObjectInputStream in = new ObjectInputStream(contentIn);
try try
{ {
@@ -144,6 +146,7 @@ public final class TemplatingService
{ {
TemplatingService.LOGGER.error(cnfe); TemplatingService.LOGGER.error(cnfe);
} }
}
loaded = true; loaded = true;
} }

View File

@@ -2331,4 +2331,13 @@
</managed-property> </managed-property>
</managed-bean> </managed-bean>
<managed-bean>
<description>
Bean that returns information on a node
</description>
<managed-bean-name>XFormsBean</managed-bean-name>
<managed-bean-class>org.alfresco.web.bean.ajax.XFormsBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config> </faces-config>