Merged V2.2 to HEAD

10982: Merged V2.1 to V2.2
      10273: Fix for ETWOONE-317: Error from regenerate renditions wizard when templates are updated
   10985: Merged V2.1 to V2.2
      10717: Fix for ETWOONE-14: System Error message appears while clicking 'Manage Task' icon in ...
      10742: Fix for ETWOONE-119: A user created with space characters at the begin and at the end can't login
      10758: Fix for ETWOONE-183: URL addressability of forum spaces and topics
      10760: Fix for ETWOONE-339: URL Addressability to discussions causes display issue
      10761: Fix for ETWOONE-196: Attempt to post to the same forum by two or more users simultaneously leads to error appearance and impossibility to post for some of them
      10772: Fix for ETWOONE-225: Validation.js does not properly handle trailing whitespace
   10986: Added Hibernate src to Eclipse project
   11004: Remove annoying exceptions on shutdown
   11005: Minor javadoc fix
   11012: Fixed ETWOTWO-423: Optionally inject the Open Office document converter instance to the transformer


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11202 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2008-10-06 11:22:26 +00:00
parent c9afa4a3c8
commit 09c1c23776
9 changed files with 317 additions and 14 deletions

View File

@@ -304,6 +304,7 @@ edit_doc_online=Edit online
upload_new_version=Upload new version upload_new_version=Upload new version
checkin_this_file=Check in this file checkin_this_file=Check in this file
cannot_delete_node_has_working_copy=Cannot delete file \"{0}\" as it has an associated working copy. cannot_delete_node_has_working_copy=Cannot delete file \"{0}\" as it has an associated working copy.
unknown=Unknown
# Properties # Properties
username=User Name username=User Name

View File

@@ -35,6 +35,7 @@ import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import javax.faces.component.UIComponent; import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
@@ -280,6 +281,9 @@ public class ForumsBean implements IContextListener
this.viewsConfig.getDefaultSortColumn(PAGE_NAME_FORUMS)); this.viewsConfig.getDefaultSortColumn(PAGE_NAME_FORUMS));
this.forumsRichList.setInitialSortDescending( this.forumsRichList.setInitialSortDescending(
this.viewsConfig.hasDescendingSort(PAGE_NAME_FORUMS)); this.viewsConfig.hasDescendingSort(PAGE_NAME_FORUMS));
// ETWOONE-183 & ETWOONE-339. For URL addressability of forums spaces
this.forumsRichList.setRefreshOnBind(true);
} }
} }
@@ -337,6 +341,9 @@ public class ForumsBean implements IContextListener
this.viewsConfig.getDefaultSortColumn(PAGE_NAME_TOPIC)); this.viewsConfig.getDefaultSortColumn(PAGE_NAME_TOPIC));
this.topicRichList.setInitialSortDescending( this.topicRichList.setInitialSortDescending(
this.viewsConfig.hasDescendingSort(PAGE_NAME_TOPIC)); this.viewsConfig.hasDescendingSort(PAGE_NAME_TOPIC));
// ETWOONE-183. For URL addressability of topics:
this.topicRichList.setRefreshOnBind(true);
} }
} }
@@ -394,6 +401,9 @@ public class ForumsBean implements IContextListener
this.viewsConfig.getDefaultSortColumn(PAGE_NAME_FORUM)); this.viewsConfig.getDefaultSortColumn(PAGE_NAME_FORUM));
this.forumRichList.setInitialSortDescending( this.forumRichList.setInitialSortDescending(
this.viewsConfig.hasDescendingSort(PAGE_NAME_FORUM)); this.viewsConfig.hasDescendingSort(PAGE_NAME_FORUM));
// ETWOONE-183 & ETWOONE-339. For URL addressability of forum spaces
this.forumRichList.setRefreshOnBind(true);
} }
} }
@@ -928,6 +938,10 @@ public class ForumsBean implements IContextListener
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy-HH-mm-ss");
name.append(dateFormat.format(new Date())); name.append(dateFormat.format(new Date()));
// add Universal Unique Identifier
// fix bugs ETWOONE-196 and ETWOONE-203
name.append("-" + UUID.randomUUID());
// add the HTML file extension // add the HTML file extension
name.append(".html"); name.append(".html");

View File

@@ -39,9 +39,13 @@ 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.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.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.workflow.WorkflowDefinition; import org.alfresco.service.cmr.workflow.WorkflowDefinition;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.forms.Form; import org.alfresco.web.forms.Form;
import org.alfresco.web.forms.RenderingEngineTemplate; import org.alfresco.web.forms.RenderingEngineTemplate;
import org.alfresco.web.forms.xforms.SchemaUtil; import org.alfresco.web.forms.xforms.SchemaUtil;
@@ -53,6 +57,11 @@ import org.apache.commons.logging.LogFactory;
* Backing bean for the Edit Form wizard. * Backing bean for the Edit Form wizard.
* *
* @author Ariel Backenroth * @author Ariel Backenroth
* @author Arseny Kovalchuk (Bug Fixer)
*
* Methods removeRenderingEngineTemplateFromWebProjects, addRenderingEngineTemplateToWebProjects, searchRenderingEngineTemplateInWebProject
* are added to fix an issue reported in https://issues.alfresco.com/jira/browse/ETWOONE-317
*
*/ */
public class EditFormWizard public class EditFormWizard
extends CreateFormWizard extends CreateFormWizard
@@ -91,8 +100,10 @@ public class EditFormWizard
this.getNodeService().getProperty(formNodeRef, WCMAppModel.PROP_XML_SCHEMA); this.getNodeService().getProperty(formNodeRef, WCMAppModel.PROP_XML_SCHEMA);
if (schemaNodeRef == null) if (schemaNodeRef == null)
{ {
if (LOGGER.isDebugEnabled())
LOGGER.debug(WCMAppModel.PROP_XML_SCHEMA + " not set on " + formNodeRef + LOGGER.debug(WCMAppModel.PROP_XML_SCHEMA + " not set on " + formNodeRef +
", checking " + WCMAppModel.PROP_XML_SCHEMA_OLD); ", checking " + WCMAppModel.PROP_XML_SCHEMA_OLD);
schemaNodeRef = (NodeRef) schemaNodeRef = (NodeRef)
getNodeService().getProperty(formNodeRef, WCMAppModel.PROP_XML_SCHEMA_OLD); getNodeService().getProperty(formNodeRef, WCMAppModel.PROP_XML_SCHEMA_OLD);
if (schemaNodeRef != null) if (schemaNodeRef != null)
@@ -175,8 +186,10 @@ public class EditFormWizard
if (wd != null && workflowRefs.size() == 0) if (wd != null && workflowRefs.size() == 0)
{ {
if (LOGGER.isDebugEnabled())
LOGGER.debug("adding workflow definition " + wd.getName() + LOGGER.debug("adding workflow definition " + wd.getName() +
" to form " + this.getFormName()); " to form " + this.getFormName());
final Map<QName, Serializable> props = new HashMap<QName, Serializable>(1, 1.0f); final Map<QName, Serializable> props = new HashMap<QName, Serializable>(1, 1.0f);
props.put(WCMAppModel.PROP_WORKFLOW_NAME, wd.getName()); props.put(WCMAppModel.PROP_WORKFLOW_NAME, wd.getName());
this.getNodeService().createNode(formNodeRef, this.getNodeService().createNode(formNodeRef,
@@ -187,15 +200,19 @@ public class EditFormWizard
} }
else if (wd != null && workflowRefs.size() == 1) else if (wd != null && workflowRefs.size() == 1)
{ {
if (LOGGER.isDebugEnabled())
LOGGER.debug("setting workflow definition " + wd.getName() + LOGGER.debug("setting workflow definition " + wd.getName() +
" to form " + this.getFormName()); " to form " + this.getFormName());
this.getNodeService().setProperty(workflowRefs.get(0).getChildRef(), this.getNodeService().setProperty(workflowRefs.get(0).getChildRef(),
WCMAppModel.PROP_WORKFLOW_NAME, WCMAppModel.PROP_WORKFLOW_NAME,
wd.getName()); wd.getName());
} }
else if (wd == null && workflowRefs.size() == 1) else if (wd == null && workflowRefs.size() == 1)
{ {
if (LOGGER.isDebugEnabled())
LOGGER.debug("removing workflow definitions from form " + this.getFormName()); LOGGER.debug("removing workflow definitions from form " + this.getFormName());
this.getNodeService().removeChild(formNodeRef, workflowRefs.get(0).getChildRef()); this.getNodeService().removeChild(formNodeRef, workflowRefs.get(0).getChildRef());
} }
@@ -222,24 +239,148 @@ public class EditFormWizard
{ {
for (final RenderingEngineTemplateData retd : this.removedRenderingEngineTemplates) for (final RenderingEngineTemplateData retd : this.removedRenderingEngineTemplates)
{ {
if (LOGGER.isDebugEnabled())
LOGGER.debug("removing rendering engine template " + retd); LOGGER.debug("removing rendering engine template " + retd);
assert retd != null; assert retd != null;
assert retd.getNodeRef() != null; assert retd.getNodeRef() != null;
this.getNodeService().removeChild(formNodeRef, retd.getNodeRef()); this.getNodeService().removeChild(formNodeRef, retd.getNodeRef());
} this.removeRenderingEngineTemplateFromWebProjects(formNodeRef, retd);
}
}
}
for (final RenderingEngineTemplateData retd : this.renderingEngineTemplates) for (final RenderingEngineTemplateData retd : this.renderingEngineTemplates)
{ {
if (retd.getFile() != null) if (retd.getFile() != null)
{ {
this.saveRenderingEngineTemplate(retd, formNodeRef); this.saveRenderingEngineTemplate(retd, formNodeRef);
this.addRenderingEngineTemplateToWebProjects(formNodeRef, retd);
} }
} }
return outcome; return outcome;
} }
/** /**
* Removes an associated Rendering Engine Template from all web forms in all web projects.
*
* @param formNodeRef Form nodeRef
* @param retd Rendering engine template to remove from web projects
*/
private void removeRenderingEngineTemplateFromWebProjects(NodeRef formNodeRef, RenderingEngineTemplateData retd)
{
List<WebProject> webProjects = getFormsService().getAssociatedWebProjects(getFormsService().getForm(formNodeRef));
for (WebProject wp: webProjects)
{
ResultSet results = searchRenderingEngineTemplateInWebProject(wp, retd.getName());
for (int i=0; i<results.length(); i++)
{
NodeRef webformTemplateNodeRef = results.getNodeRef(i);
NodeRef webformNodeRef = getNodeService().getPrimaryParent(webformTemplateNodeRef).getParentRef();
getNodeService().removeChild(webformNodeRef, webformTemplateNodeRef);
if (LOGGER.isDebugEnabled())
LOGGER.debug(webformNodeRef);
}
}
}
/**
* Adds or updates an associated Rendering Engine Template from all web forms in all web projects.
*
* @param formNodeRef
* @param retd Rendering engine template to remove from web projects
*/
private void addRenderingEngineTemplateToWebProjects(NodeRef formNodeRef, RenderingEngineTemplateData retd)
{
Form form = getFormsService().getForm(formNodeRef);
List<WebProject> webProjects = getFormsService().getAssociatedWebProjects(form);
Map<QName, Serializable> props = new HashMap<QName, Serializable>(4, 1.0f);
for (WebProject wp: webProjects)
{
ResultSet results = searchRenderingEngineTemplateInWebProject(wp, retd.getName());
int resultsCount = results.length();
if (resultsCount>0)
{
//update
for (int i=0; i<resultsCount; i++)
{
NodeRef webformTemplateNodeRef = results.getNodeRef(i);
if (retd.getOutputPathPatternForRendition() != null)
{
props.clear();
props.put(WCMAppModel.PROP_OUTPUT_PATH_PATTERN, retd.getOutputPathPatternForRendition());
getNodeService().addAspect(webformTemplateNodeRef, WCMAppModel.ASPECT_OUTPUT_PATH_PATTERN, props);
}
}
}
else
{
//just add
String query = "+TYPE:\"" + WCMAppModel.TYPE_WEBFORM + "\"" +
" +@" + Repository.escapeQName(WCMAppModel.PROP_FORMNAME) + ":\"" + form.getName() + "\"";
if (LOGGER.isDebugEnabled())
LOGGER.debug("Search web forms query: " + query);
ResultSet webforms = getSearchService().query(wp.getNodeRef().getStoreRef(), SearchService.LANGUAGE_LUCENE, query);
props.clear();
props.put(WCMAppModel.PROP_BASE_RENDERING_ENGINE_TEMPLATE_NAME,
retd.getName());
for (int i=0; i<webforms.length(); i++)
{
if (LOGGER.isDebugEnabled())
LOGGER.debug("WebForm NodeRef: " + webforms.getNodeRef(i));
NodeRef templateRef = getNodeService().createNode(webforms.getNodeRef(i),
WCMAppModel.ASSOC_WEBFORMTEMPLATE,
WCMAppModel.ASSOC_WEBFORMTEMPLATE,
WCMAppModel.TYPE_WEBFORMTEMPLATE,
props).getChildRef();
if (retd.getOutputPathPatternForRendition() != null)
{
props.clear();
props.put(WCMAppModel.PROP_OUTPUT_PATH_PATTERN, retd.getOutputPathPatternForRendition());
getNodeService().addAspect(templateRef, WCMAppModel.ASPECT_OUTPUT_PATH_PATTERN, props);
}
}
}
}
}
/**
* Searches an specific Web Form Template with appropriate name in the Web Project.
*
* @param wp The WebProject to search
* @param name The name of Rendering Engine Template to search
* @return Search result
*/
private ResultSet searchRenderingEngineTemplateInWebProject(WebProject wp, String name)
{
ResultSet result = null;
StringBuilder query = new StringBuilder(256);
query.append("+TYPE:\"").append(WCMAppModel.TYPE_WEBFORMTEMPLATE).append("\" ");
query.append("+@").append(Repository.escapeQName(WCMAppModel.PROP_BASE_RENDERING_ENGINE_TEMPLATE_NAME)).append(":\"").append(name).append("\" ");
// Search not found anything in this StoreRef!
// It looks like a wrong search in RegenerateRenditionsWizard.
//
//StoreRef storeRef = AVMNodeConverter.ToStoreRef(wp.getStagingStore());
StoreRef storeRef = wp.getNodeRef().getStoreRef();
result = getSearchService().query(storeRef, SearchService.LANGUAGE_LUCENE, query.toString());
if (LOGGER.isDebugEnabled())
{
LOGGER.debug(">>>Web Project: " + wp);
LOGGER.debug(">>>StoreRef: " + storeRef);
LOGGER.debug(">>>Search query: " + query.toString());
LOGGER.debug(">>>Search results: " + result.length());
}
return result;
}
/**
* Action handler called when the Remove button is pressed to remove a * Action handler called when the Remove button is pressed to remove a
* rendering engine * rendering engine
*/ */

View File

@@ -161,6 +161,9 @@ public class WebProject implements Serializable
nodeService.getProperty(car.getChildRef(), WCMAppModel.PROP_OUTPUT_PATH_PATTERN); nodeService.getProperty(car.getChildRef(), WCMAppModel.PROP_OUTPUT_PATH_PATTERN);
final RenderingEngineTemplateImpl ret = (RenderingEngineTemplateImpl) final RenderingEngineTemplateImpl ret = (RenderingEngineTemplateImpl)
allRets.get(renderingEngineTemplateName); allRets.get(renderingEngineTemplateName);
if (ret != null)
{
result.put(ret.getName(), result.put(ret.getName(),
new RenderingEngineTemplateImpl(ret.getNodeRef(), new RenderingEngineTemplateImpl(ret.getNodeRef(),
ret.getRenditionPropertiesNodeRef(), ret.getRenditionPropertiesNodeRef(),
@@ -174,6 +177,7 @@ public class WebProject implements Serializable
return outputPathPattern; return outputPathPattern;
} }
}); });
}
} }
return result; return result;

View File

@@ -814,6 +814,11 @@ public class NewUserWizard extends AbstractWizardBean
*/ */
public void setUserName(String userName) public void setUserName(String userName)
{ {
if (userName != null)
{
userName = userName.trim();
}
this.userName = userName; this.userName = userName;
} }

View File

@@ -196,8 +196,24 @@ import org.xml.sax.SAXException;
// regenerate existing renditions // regenerate existing renditions
boolean renditionLockedBefore = false; boolean renditionLockedBefore = false;
String path = null; String path = null;
for (final Rendition r : this.getRenditions()) for (final Rendition r : this.getRenditions())
{ {
// Try to skip renditions without rendering engine template.
if (r instanceof RenditionImpl)
{
RenditionImpl rImpl = (RenditionImpl)r;
RenderingEngineTemplate ret = rImpl.getRenderingEngineTemplate();
if ((ret != null) && (ret instanceof RenderingEngineTemplateImpl))
{
RenderingEngineTemplateImpl retImpl = (RenderingEngineTemplateImpl) ret;
if (!retImpl.isExists())
{
continue;
}
}
}
final RenderingEngineTemplate ret = r.getRenderingEngineTemplate(); final RenderingEngineTemplate ret = r.getRenderingEngineTemplate();
if (ret == null || !allRets.contains(ret)) if (ret == null || !allRets.contains(ret))
{ {

View File

@@ -600,5 +600,11 @@ public class RenderingEngineTemplateImpl
return this.getClass().getName() + "{name : " + this.getName() + "}"; return this.getClass().getName() + "{name : " + this.getName() + "}";
} }
public boolean isExists()
{
final NodeService nodeService = this.getServiceRegistry().getNodeService();
return nodeService.exists(this.nodeRef);
}
} }

View File

@@ -32,6 +32,7 @@ import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter; import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding; import javax.faces.el.ValueBinding;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.workflow.WorkflowInstance; import org.alfresco.service.cmr.workflow.WorkflowInstance;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
@@ -120,11 +121,21 @@ public class UIWorkflowSummary extends SelfRenderingComponent
out.write("</td></tr><tr><td>"); out.write("</td></tr><tr><td>");
out.write(bundle.getString("initiated_by")); out.write(bundle.getString("initiated_by"));
out.write(":</td><td>"); out.write(":</td><td>");
NodeService nodeService = getNodeService(context);
if (wi.initiator != null) if (wi.initiator != null)
{
if (nodeService.exists(wi.initiator))
{ {
out.write(Utils.encode(User.getFullName(Repository.getServiceRegistry( out.write(Utils.encode(User.getFullName(Repository.getServiceRegistry(
context).getNodeService(), wi.initiator))); context).getNodeService(), wi.initiator)));
} }
else
{
out.write("&lt;");
out.write(bundle.getString("unknown"));
out.write("&gt;");
}
}
out.write("</td></tr><tr><td>"); out.write("</td></tr><tr><td>");
out.write(bundle.getString("started_on")); out.write(bundle.getString("started_on"));
out.write(":</td><td>"); out.write(":</td><td>");
@@ -189,4 +200,9 @@ public class UIWorkflowSummary extends SelfRenderingComponent
{ {
this.value = value; this.value = value;
} }
private NodeService getNodeService(FacesContext fc)
{
return Repository.getServiceRegistry(fc).getNodeService();
}
} }

View File

@@ -98,7 +98,7 @@ function validateRegex(control, expression, requiresMatch, matchMessage, noMatch
{ {
var result = true; var result = true;
var pattern = new RegExp(unescape(expression)); var pattern = new RegExp(decode(expression));
var matches = pattern.test(control.value); var matches = pattern.test(control.value);
if (matches != requiresMatch) if (matches != requiresMatch)
@@ -136,3 +136,103 @@ function validateName(control, message, showMessage)
return result; return result;
} }
/**
* Decodes the given string
*
* @param str The string to decode
* @return The decoded string
*/
function decode(str)
{
var s0, i, j, s, ss, u, n, f;
s0 = ""; // decoded str
for (i = 0; i < str.length; i++)
{
// scan the source str
s = str.charAt(i);
if (s == "+")
{
// "+" should be changed to SP
s0 += " ";
}
else
{
if (s != "%")
{
// add an unescaped char
s0 += s;
}
else
{
// escape sequence decoding
u = 0; // unicode of the character
f = 1; // escape flag, zero means end of this sequence
while (true)
{
ss = ""; // local str to parse as int
for (j = 0; j < 2; j++ )
{
// get two maximum hex characters for parse
sss = str.charAt(++i);
if (((sss >= "0") && (sss <= "9")) || ((sss >= "a") && (sss <= "f")) || ((sss >= "A") && (sss <= "F")))
{
ss += sss; // if hex, add the hex character
}
else
{
// not a hex char., exit the loop
--i;
break;
}
}
// parse the hex str as byte
n = parseInt(ss, 16);
// single byte format
if (n <= 0x7f) { u = n; f = 1; }
// double byte format
if ((n >= 0xc0) && (n <= 0xdf)) { u = n & 0x1f; f = 2; }
// triple byte format
if ((n >= 0xe0) && (n <= 0xef)) { u = n & 0x0f; f = 3; }
// quaternary byte format (extended)
if ((n >= 0xf0) && (n <= 0xf7)) { u = n & 0x07; f = 4; }
// not a first, shift and add 6 lower bits
if ((n >= 0x80) && (n <= 0xbf)) { u = (u << 6) + (n & 0x3f); --f; }
// end of the utf byte sequence
if (f <= 1) { break; }
if (str.charAt(i + 1) == "%")
{
// test for the next shift byte
i++ ;
}
else
{
// abnormal, format error
break;
}
}
// add the escaped character
s0 += String.fromCharCode(u);
}
}
}
return s0;
}