Merged V2.0 to HEAD

5448: (From V1.4)
      5281 (V1.4): Patches not executed in read-only mode
      5284 (V1.4): Integrity messages
      5308 (V1.4): Category selector performance
      5331 (V1.4): Category performance
      5402 (V1.4): AR-1315
      5410 (V1.4): 
      5417 (V1.4): Upgrade script performance
      5435 (V1.4): Lucene test text encoding


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5482 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-04-11 23:24:00 +00:00
parent 0a79a3db57
commit 1e854c1087

View File

@@ -52,6 +52,7 @@ 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.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.WebResources; import org.alfresco.web.ui.common.WebResources;
import org.springframework.web.jsf.FacesContextUtils;
/** /**
* Abstract component to allow the selection of a hierarchical item * Abstract component to allow the selection of a hierarchical item
@@ -272,79 +273,79 @@ public abstract class AbstractItemSelector extends UIInput
NodeService service = getNodeService(context); NodeService service = getNodeService(context);
if (isDisabled()) UserTransaction tx = null;
try
{ {
// render a read-only view of the selected category (if any) tx = Repository.getUserTransaction(context, true);
ResponseWriter out = context.getResponseWriter(); tx.begin();
// see if there is a current value for the category if (isDisabled())
NodeRef nodeRef = (NodeRef)getSubmittedValue();
if (nodeRef == null)
{ {
Object val = getValue(); // render a read-only view of the selected category (if any)
if (val instanceof NodeRef) ResponseWriter out = context.getResponseWriter();
// see if there is a current value for the category
NodeRef nodeRef = (NodeRef)getSubmittedValue();
if (nodeRef == null)
{ {
nodeRef = (NodeRef)val; Object val = getValue();
} if (val instanceof NodeRef)
else if (val instanceof String && ((String)val).length() != 0)
{
nodeRef = new NodeRef((String)val);
}
else if (val instanceof List)
{
// build a comma separated list of node names
List nodes = (List)val;
StringBuilder buffer = new StringBuilder();
for (Object obj : nodes)
{ {
if (buffer.length() != 0) nodeRef = (NodeRef)val;
{
buffer.append(", ");
}
if (obj instanceof NodeRef)
{
buffer.append(Repository.getNameForNode(service, (NodeRef)obj));
}
else
{
buffer.append(obj.toString());
}
} }
else if (val instanceof String && ((String)val).length() != 0)
// write out to response {
out.write(buffer.toString()); nodeRef = new NodeRef((String)val);
}
else if (val instanceof List)
{
// build a comma separated list of node names
List nodes = (List)val;
StringBuilder buffer = new StringBuilder();
for (Object obj : nodes)
{
if (buffer.length() != 0)
{
buffer.append(", ");
}
if (obj instanceof NodeRef)
{
buffer.append(Repository.getNameForNode(service, (NodeRef)obj));
}
else
{
buffer.append(obj.toString());
}
}
// write out to response
out.write(buffer.toString());
}
}
// if there is a value show it's name
if (nodeRef != null)
{
out.write(Repository.getNameForNode(service, nodeRef));
} }
} }
else
// if there is a value show it's name
if (nodeRef != null)
{ {
out.write(Repository.getNameForNode(service, nodeRef)); // render an editable control for selecting items
} String clientId = getClientId(context);
}
else StringBuilder buf = new StringBuilder(512);
{ Map attrs = this.getAttributes();
// render an editable control for selecting items boolean showValueInHiddenField = false;
String clientId = getClientId(context); NodeRef value = null;
StringBuilder buf = new StringBuilder(512); switch (this.mode)
Map attrs = this.getAttributes();
boolean showValueInHiddenField = false;
NodeRef value = null;
switch (this.mode)
{
case MODE_BEFORE_SELECTION:
case MODE_CONFIRM_SELECTION:
case MODE_CANCEL_SELECTION:
{ {
UserTransaction tx = null; case MODE_BEFORE_SELECTION:
try case MODE_CONFIRM_SELECTION:
case MODE_CANCEL_SELECTION:
{ {
tx = Repository.getUserTransaction(context, true);
tx.begin();
NodeRef submittedValue = (NodeRef)getSubmittedValue(); NodeRef submittedValue = (NodeRef)getSubmittedValue();
if (submittedValue != null) if (submittedValue != null)
{ {
@@ -448,90 +449,76 @@ public abstract class AbstractItemSelector extends UIInput
buf.append(">") buf.append(">")
.append(label) .append(label)
.append("</a></span>"); .append("</a></span>");
break;
}
case MODE_DRILLDOWN_SELECTION:
case MODE_INITIAL_SELECTION:
{
// show the picker list
// get the children of the node ref to show
buf.append("<table border=0 cellspacing=1 cellpadding=1");
if (attrs.get("style") != null)
{
buf.append(" style=\"")
.append(attrs.get("style"))
.append('"');
}
if (attrs.get("styleClass") != null)
{
buf.append(" class=")
.append(attrs.get("styleClass"));
}
buf.append(">");
tx.commit(); // if we are setting up the initial selection we need to get the
} // parent id of the initial selection so the user can actually see
catch (Throwable err) // the item when the list is rendered
{ if (this.mode == MODE_INITIAL_SELECTION)
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {} {
Utils.addErrorMessage(err.getMessage(), err); this.navigationId = getParentNodeId(context);
} }
break;
}
case MODE_DRILLDOWN_SELECTION:
case MODE_INITIAL_SELECTION:
{
// show the picker list
// get the children of the node ref to show
buf.append("<table border=0 cellspacing=1 cellpadding=1");
if (attrs.get("style") != null)
{
buf.append(" style=\"")
.append(attrs.get("style"))
.append('"');
}
if (attrs.get("styleClass") != null)
{
buf.append(" class=")
.append(attrs.get("styleClass"));
}
buf.append(">");
// if we are setting up the initial selection we need to get the
// parent id of the initial selection so the user can actually see
// the item when the list is rendered
if (this.mode == MODE_INITIAL_SELECTION)
{
this.navigationId = getParentNodeId(context);
}
// render "Go Up" link if not at the root level
if (this.navigationId != null)
{
// get the id of the parent node of the current navigation node,
// null indicates we are at the root level
String id = getParentNodeId(context);
buf.append("<tr><td></td><td>"); // render "Go Up" link if not at the root level
if (this.navigationId != null)
{
// get the id of the parent node of the current navigation node,
// null indicates we are at the root level
String id = getParentNodeId(context);
buf.append("<tr><td></td><td>");
String upImage = Utils.buildImageTag(context, WebResources.IMAGE_GO_UP, null, "absmiddle");
// render a link to the parent node
renderNodeLink(context, id, Application.getMessage(context, MSG_GO_UP), upImage, buf);
buf.append("</td></tr>");
}
String upImage = Utils.buildImageTag(context, WebResources.IMAGE_GO_UP, null, "absmiddle"); String okButtonId = clientId + OK_BUTTON;
boolean okButtonEnabled = false;
// render a link to the parent node // display the children of the specified navigation node ID
renderNodeLink(context, id, Application.getMessage(context, MSG_GO_UP), upImage, buf); Collection<NodeRef> childRefs;
buf.append("</td></tr>"); if (this.navigationId != null)
} {
// get a list of children for the current navigation node
String okButtonId = clientId + OK_BUTTON; childRefs = getChildrenForNode(context);
boolean okButtonEnabled = false; }
else
// display the children of the specified navigation node ID {
Collection<NodeRef> childRefs; // no node set - special case to show the initial root items
if (this.navigationId != null) childRefs = getRootChildren(context);
{ }
// get a list of children for the current navigation node
childRefs = getChildrenForNode(context);
}
else
{
// no node set - special case to show the initial root items
childRefs = getRootChildren(context);
}
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(context, true);
tx.begin();
for (NodeRef childRef : childRefs) for (NodeRef childRef : childRefs)
{ {
// render each child found // render each child found
String childId = childRef.getId(); String childId = childRef.getId();
buf.append("<tr><td><input type='radio' name='") buf.append("<tr><td><input type='radio' name='")
.append(clientId).append(OPTION).append("' value='") .append(clientId).append(OPTION).append("' value='")
.append(childId).append("'"); .append(childId).append("'");
if (childId.equals(this.initialSelectionId)) if (childId.equals(this.initialSelectionId))
{ {
buf.append(" checked"); buf.append(" checked");
@@ -584,32 +571,32 @@ public abstract class AbstractItemSelector extends UIInput
buf.append("</table>"); buf.append("</table>");
tx.commit(); break;
} }
catch (Throwable err)
{
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
throw new RuntimeException(err);
}
break;
} }
// output a hidden field containing the currently selected NodeRef so that JavaScript
// can be used to check the state of the component
buf.append("<input type='hidden' name='");
buf.append(clientId);
buf.append("_selected' id='");
buf.append(clientId);
buf.append("_selected' value='");
if (showValueInHiddenField)
{
buf.append(value);
}
buf.append("'/>");
context.getResponseWriter().write(buf.toString());
} }
// output a hidden field containing the currently selected NodeRef so that JavaScript // commit the transaction
// can be used to check the state of the component tx.commit();
buf.append("<input type='hidden' name='"); }
buf.append(clientId); catch (Throwable err)
buf.append("_selected' id='"); {
buf.append(clientId); try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
buf.append("_selected' value='");
if (showValueInHiddenField)
{
buf.append(value);
}
buf.append("'/>");
context.getResponseWriter().write(buf.toString());
} }
} }
@@ -804,7 +791,8 @@ public abstract class AbstractItemSelector extends UIInput
*/ */
protected static NodeService getNodeService(FacesContext context) protected static NodeService getNodeService(FacesContext context)
{ {
NodeService service = Repository.getServiceRegistry(context).getNodeService(); NodeService service = (NodeService)FacesContextUtils.getRequiredWebApplicationContext(
context).getBean("nodeService");
if (service == null) if (service == null)
{ {
throw new IllegalStateException("Unable to obtain NodeService bean reference."); throw new IllegalStateException("Unable to obtain NodeService bean reference.");