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,6 +273,12 @@ public abstract class AbstractItemSelector extends UIInput
NodeService service = getNodeService(context); NodeService service = getNodeService(context);
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(context, true);
tx.begin();
if (isDisabled()) if (isDisabled())
{ {
// render a read-only view of the selected category (if any) // render a read-only view of the selected category (if any)
@@ -339,12 +346,6 @@ public abstract class AbstractItemSelector extends UIInput
case MODE_CONFIRM_SELECTION: case MODE_CONFIRM_SELECTION:
case MODE_CANCEL_SELECTION: case MODE_CANCEL_SELECTION:
{ {
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(context, true);
tx.begin();
NodeRef submittedValue = (NodeRef)getSubmittedValue(); NodeRef submittedValue = (NodeRef)getSubmittedValue();
if (submittedValue != null) if (submittedValue != null)
{ {
@@ -449,14 +450,6 @@ public abstract class AbstractItemSelector extends UIInput
.append(label) .append(label)
.append("</a></span>"); .append("</a></span>");
tx.commit();
}
catch (Throwable err)
{
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
Utils.addErrorMessage(err.getMessage(), err);
}
break; break;
} }
@@ -519,12 +512,6 @@ public abstract class AbstractItemSelector extends UIInput
childRefs = getRootChildren(context); 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
@@ -584,14 +571,6 @@ public abstract class AbstractItemSelector extends UIInput
buf.append("</table>"); buf.append("</table>");
tx.commit();
}
catch (Throwable err)
{
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
throw new RuntimeException(err);
}
break; break;
} }
} }
@@ -611,6 +590,14 @@ public abstract class AbstractItemSelector extends UIInput
context.getResponseWriter().write(buf.toString()); context.getResponseWriter().write(buf.toString());
} }
// commit the transaction
tx.commit();
}
catch (Throwable err)
{
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
} }
@@ -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.");