mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- fix for tinymce usage where rather than collect all changes before unload, capture the onblur event and set the value then.
- use fle type image rather than rendering template icon in create web content summary screen - save content before executing finish or next in create web content wizard - makes error handling more proper - add output path pattern to summary screen for create form wizard - handle chiba-state-changed event properly git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4514 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -56,6 +56,7 @@ import org.alfresco.web.forms.FormProcessor;
|
|||||||
import org.alfresco.web.forms.FormsService;
|
import org.alfresco.web.forms.FormsService;
|
||||||
import org.alfresco.web.forms.Rendition;
|
import org.alfresco.web.forms.Rendition;
|
||||||
import org.alfresco.web.forms.RenditionImpl;
|
import org.alfresco.web.forms.RenditionImpl;
|
||||||
|
import org.alfresco.web.ui.common.Utils;
|
||||||
import org.alfresco.web.ui.wcm.component.UIUserSandboxes;
|
import org.alfresco.web.ui.wcm.component.UIUserSandboxes;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -66,7 +67,7 @@ import org.w3c.dom.Document;
|
|||||||
*/
|
*/
|
||||||
public class CreateWebContentWizard extends BaseContentWizard
|
public class CreateWebContentWizard extends BaseContentWizard
|
||||||
{
|
{
|
||||||
private static final Log logger = LogFactory.getLog(CreateWebContentWizard.class);
|
private static final Log LOGGER = LogFactory.getLog(CreateWebContentWizard.class);
|
||||||
|
|
||||||
protected String content = null;
|
protected String content = null;
|
||||||
protected String formName;
|
protected String formName;
|
||||||
@@ -154,6 +155,56 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String next()
|
||||||
|
{
|
||||||
|
final int step = Application.getWizardManager().getCurrentStep();
|
||||||
|
if (step == 3)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.saveContent();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Application.getWizardManager().getState().setCurrentStep(step - 1);
|
||||||
|
Utils.addErrorMessage(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String back()
|
||||||
|
{
|
||||||
|
final int step = Application.getWizardManager().getCurrentStep();
|
||||||
|
if (step == 2)
|
||||||
|
{
|
||||||
|
LOGGER.debug("clearing form instance data");
|
||||||
|
this.formInstanceData = null;
|
||||||
|
this.renditions = null;
|
||||||
|
}
|
||||||
|
return super.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String finish()
|
||||||
|
{
|
||||||
|
if (this.formInstanceData == null || this.renditions == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.saveContent();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Utils.addErrorMessage(e.getMessage(), e);
|
||||||
|
return super.getErrorOutcome(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.finish();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String finishImpl(final FacesContext context, final String outcome)
|
protected String finishImpl(final FacesContext context, final String outcome)
|
||||||
throws Exception
|
throws Exception
|
||||||
@@ -278,13 +329,9 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
|
|
||||||
boolean disabled = false;
|
boolean disabled = false;
|
||||||
int step = Application.getWizardManager().getCurrentStep();
|
int step = Application.getWizardManager().getCurrentStep();
|
||||||
switch(step)
|
if (step == 1)
|
||||||
{
|
{
|
||||||
case 1:
|
disabled = (this.fileName == null || this.fileName.length() == 0);
|
||||||
{
|
|
||||||
disabled = (this.fileName == null || this.fileName.length() == 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return disabled;
|
return disabled;
|
||||||
@@ -292,25 +339,20 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the specified content using the currently set wizard attributes
|
* Save the specified content using the currently set wizard attributes
|
||||||
*
|
|
||||||
* @param fileContent File content to save
|
|
||||||
* @param strContent String content to save
|
|
||||||
*/
|
*/
|
||||||
@Override
|
protected void saveContent()
|
||||||
protected void saveContent(File fileContent, String strContent) throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
final FormsService fs = FormsService.getInstance();
|
final FormsService fs = FormsService.getInstance();
|
||||||
if (logger.isDebugEnabled())
|
if (LOGGER.isDebugEnabled())
|
||||||
logger.debug("saving file content to " + this.fileName);
|
LOGGER.debug("saving file content to " + this.fileName);
|
||||||
// get the parent path of the location to save the content
|
// get the parent path of the location to save the content
|
||||||
String path = this.avmBrowseBean.getCurrentPath();
|
String path = this.avmBrowseBean.getCurrentPath();
|
||||||
path = path.replaceFirst(AVMConstants.STORE_MAIN, AVMConstants.STORE_PREVIEW);
|
path = path.replaceFirst(AVMConstants.STORE_MAIN, AVMConstants.STORE_PREVIEW);
|
||||||
if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null)
|
if (MimetypeMap.MIMETYPE_XML.equals(this.mimeType) && this.formName != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
final Document formInstanceData = (fileContent != null
|
final Document formInstanceData = fs.parseXML(this.content);
|
||||||
? fs.parseXML(fileContent)
|
|
||||||
: fs.parseXML(strContent));
|
|
||||||
|
|
||||||
path = this.getForm().getOutputPathForFormInstanceData(path, this.fileName, formInstanceData);
|
path = this.getForm().getOutputPathForFormInstanceData(path, this.fileName, formInstanceData);
|
||||||
final String[] sb = AVMNodeConverter.SplitBase(path);
|
final String[] sb = AVMNodeConverter.SplitBase(path);
|
||||||
@@ -319,28 +361,23 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (LOGGER.isDebugEnabled())
|
||||||
logger.debug("reseting layer " + path.split(":")[0] + ":/" + AVMConstants.DIR_APPBASE);
|
LOGGER.debug("reseting layer " + path.split(":")[0] + ":/" + AVMConstants.DIR_APPBASE);
|
||||||
|
|
||||||
this.avmSyncService.resetLayer(path.split(":")[0] + ":/" + AVMConstants.DIR_APPBASE);
|
this.avmSyncService.resetLayer(path.split(":")[0] + ":/" + AVMConstants.DIR_APPBASE);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (LOGGER.isDebugEnabled())
|
||||||
logger.debug("creating all directories in path " + path);
|
LOGGER.debug("creating all directories in path " + path);
|
||||||
|
|
||||||
fs.makeAllDirectories(path);
|
fs.makeAllDirectories(path);
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (LOGGER.isDebugEnabled())
|
||||||
logger.debug("creating file " + this.fileName + " in " + path);
|
LOGGER.debug("creating file " + this.fileName + " in " + path);
|
||||||
|
|
||||||
// put the content of the file into the AVM store
|
// put the content of the file into the AVM store
|
||||||
if (fileContent != null)
|
avmService.createFile(path,
|
||||||
{
|
this.fileName,
|
||||||
avmService.createFile(path, this.fileName, new BufferedInputStream(new FileInputStream(fileContent)));
|
new ByteArrayInputStream((this.content == null ? "" : this.content).getBytes()));
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
avmService.createFile(path, this.fileName, new ByteArrayInputStream((strContent == null ? "" : strContent).getBytes()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// remember the created path
|
// remember the created path
|
||||||
this.createdPath = path + '/' + this.fileName;
|
this.createdPath = path + '/' + this.fileName;
|
||||||
@@ -424,10 +461,18 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
// add the configured create mime types to the list
|
// add the configured create mime types to the list
|
||||||
ConfigService svc = Application.getConfigService(context);
|
ConfigService svc = Application.getConfigService(context);
|
||||||
Config wizardCfg = svc.getConfig("Content Wizards");
|
Config wizardCfg = svc.getConfig("Content Wizards");
|
||||||
if (wizardCfg != null)
|
if (wizardCfg == null)
|
||||||
|
{
|
||||||
|
LOGGER.warn("Could not find 'Content Wizards' configuration section");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
ConfigElement typesCfg = wizardCfg.getConfigElement("create-mime-types");
|
ConfigElement typesCfg = wizardCfg.getConfigElement("create-mime-types");
|
||||||
if (typesCfg != null)
|
if (typesCfg == null)
|
||||||
|
{
|
||||||
|
LOGGER.warn("Could not find 'create-mime-types' configuration element");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
for (ConfigElement child : typesCfg.getChildren())
|
for (ConfigElement child : typesCfg.getChildren())
|
||||||
{
|
{
|
||||||
@@ -443,16 +488,7 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
|
||||||
sorter.sort();
|
sorter.sort();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.warn("Could not find 'create-mime-types' configuration element");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.warn("Could not find 'Content Wizards' configuration section");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.createMimeTypes;
|
return this.createMimeTypes;
|
||||||
@@ -509,12 +545,7 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FormInstanceData getFormInstanceData()
|
public FormInstanceData getFormInstanceData()
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
if (this.formInstanceData == null)
|
|
||||||
{
|
|
||||||
this.saveContent(null, this.content);
|
|
||||||
}
|
|
||||||
return this.formInstanceData;
|
return this.formInstanceData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -543,24 +574,6 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
return this.startWorkflow;
|
return this.startWorkflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the summary data for the wizard.
|
|
||||||
*/
|
|
||||||
public String getSummary()
|
|
||||||
{
|
|
||||||
|
|
||||||
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
|
|
||||||
|
|
||||||
// TODO: show first few lines of content here?
|
|
||||||
return buildSummary(
|
|
||||||
new String[] {bundle.getString("file_name"),
|
|
||||||
bundle.getString("content_type"),
|
|
||||||
bundle.getString("Location")},
|
|
||||||
new String[] {this.fileName, getSummaryObjectType(),
|
|
||||||
getSummaryMimeType(this.mimeType)});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Action event handlers
|
// Action event handlers
|
||||||
|
|
||||||
|
@@ -44,4 +44,7 @@ public interface Rendition
|
|||||||
|
|
||||||
/** the url to the asset */
|
/** the url to the asset */
|
||||||
public String getUrl();
|
public String getUrl();
|
||||||
|
|
||||||
|
/** the file type image for the rendition */
|
||||||
|
public String getFileTypeImage();
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,7 @@ import org.alfresco.service.cmr.repository.TemplateService;
|
|||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.web.bean.repository.Repository;
|
import org.alfresco.web.bean.repository.Repository;
|
||||||
import org.alfresco.web.bean.wcm.AVMConstants;
|
import org.alfresco.web.bean.wcm.AVMConstants;
|
||||||
|
import org.alfresco.web.ui.common.Utils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
@@ -105,6 +106,11 @@ public class RenditionImpl
|
|||||||
return AVMConstants.buildAVMAssetUrl(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond());
|
return AVMConstants.buildAVMAssetUrl(AVMNodeConverter.ToAVMVersionPath(this.nodeRef).getSecond());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFileTypeImage()
|
||||||
|
{
|
||||||
|
return Utils.getFileTypeImage(this.getName(), false);
|
||||||
|
}
|
||||||
|
|
||||||
private ServiceRegistry getServiceRegistry()
|
private ServiceRegistry getServiceRegistry()
|
||||||
{
|
{
|
||||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
<jsp:attribute name="description">
|
<jsp:attribute name="description">
|
||||||
<div>${WizardManager.bean.formDescription}</div>
|
<div>${WizardManager.bean.formDescription}</div>
|
||||||
<div>${msg.schema_root_element_name}: ${WizardManager.bean.schemaRootElementName}</div>
|
<div>${msg.schema_root_element_name}: ${WizardManager.bean.schemaRootElementName}</div>
|
||||||
|
<div>${msg.schema_root_element_name}: ${WizardManager.bean.outputPathPatternForFormInstanceData}</div>
|
||||||
</jsp:attribute>
|
</jsp:attribute>
|
||||||
</a:listItem>
|
</a:listItem>
|
||||||
</a:selectList>
|
</a:selectList>
|
||||||
|
@@ -53,7 +53,7 @@
|
|||||||
<c:forEach items="${WizardManager.bean.renditions}" var="rendition">
|
<c:forEach items="${WizardManager.bean.renditions}" var="rendition">
|
||||||
<a:listItem label="${rendition.name}"
|
<a:listItem label="${rendition.name}"
|
||||||
value="${rendition.name}"
|
value="${rendition.name}"
|
||||||
image="/images/icons/template_large.gif">
|
image="${rendition.fileTypeImage}">
|
||||||
<jsp:attribute name="description">
|
<jsp:attribute name="description">
|
||||||
<span style="float:right">
|
<span style="float:right">
|
||||||
<a:actionLink value="${rendition.name}"
|
<a:actionLink value="${rendition.name}"
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user