mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Some transaction retrying for Web Client
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5911 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -46,10 +46,11 @@ import javax.faces.render.RenderKitFactory;
|
|||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.transaction.UserTransaction;
|
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
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;
|
||||||
|
|
||||||
@@ -88,7 +89,6 @@ public class InvokeCommand extends BaseAjaxCommand
|
|||||||
final HttpServletResponse response)
|
final HttpServletResponse response)
|
||||||
throws ServletException, IOException
|
throws ServletException, IOException
|
||||||
{
|
{
|
||||||
UserTransaction tx = null;
|
|
||||||
ResponseWriter writer = null;
|
ResponseWriter writer = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -153,20 +153,21 @@ public class InvokeCommand extends BaseAjaxCommand
|
|||||||
facesContext);
|
facesContext);
|
||||||
|
|
||||||
// setup the transaction
|
// setup the transaction
|
||||||
tx = Repository.getUserTransaction(facesContext);
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
final Object beanFinal = bean;
|
||||||
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
// invoke the method
|
// invoke the method
|
||||||
method.invoke(bean);
|
method.invoke(beanFinal);
|
||||||
|
return null;
|
||||||
// commit
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) { tx.rollback(); } } catch (Exception ex) { }
|
|
||||||
|
|
||||||
if (err instanceof EvaluationException)
|
if (err instanceof EvaluationException)
|
||||||
{
|
{
|
||||||
final Throwable cause = ((EvaluationException)err).getCause();
|
final Throwable cause = ((EvaluationException)err).getCause();
|
||||||
|
@@ -39,12 +39,13 @@ import javax.faces.event.ActionEvent;
|
|||||||
import javax.faces.model.DataModel;
|
import javax.faces.model.DataModel;
|
||||||
import javax.faces.model.ListDataModel;
|
import javax.faces.model.ListDataModel;
|
||||||
import javax.faces.model.SelectItem;
|
import javax.faces.model.SelectItem;
|
||||||
import javax.transaction.UserTransaction;
|
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.cache.ExpiringValueCache;
|
import org.alfresco.repo.cache.ExpiringValueCache;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
@@ -984,24 +985,26 @@ public class AdvancedSearchBean
|
|||||||
searchesRef = getUserSearchesRef();
|
searchesRef = getUserSearchesRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchContext search = this.navigator.getSearchContext();
|
final SearchContext search = this.navigator.getSearchContext();
|
||||||
if (searchesRef != null && search != null)
|
if (searchesRef != null && search != null)
|
||||||
{
|
{
|
||||||
UserTransaction tx = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FacesContext context = FacesContext.getCurrentInstance();
|
final FacesContext context = FacesContext.getCurrentInstance();
|
||||||
tx = Repository.getUserTransaction(context);
|
final NodeRef searchesRefFinal = searchesRef;
|
||||||
tx.begin();
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
// create new content node as the saved search object
|
// create new content node as the saved search object
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2, 1.0f);
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2, 1.0f);
|
||||||
props.put(ContentModel.PROP_NAME, this.searchName);
|
props.put(ContentModel.PROP_NAME, searchName);
|
||||||
props.put(ContentModel.PROP_DESCRIPTION, this.searchDescription);
|
props.put(ContentModel.PROP_DESCRIPTION, searchDescription);
|
||||||
ChildAssociationRef childRef = this.nodeService.createNode(
|
ChildAssociationRef childRef = nodeService.createNode(
|
||||||
searchesRef,
|
searchesRefFinal,
|
||||||
ContentModel.ASSOC_CONTAINS,
|
ContentModel.ASSOC_CONTAINS,
|
||||||
QName.createQName(NamespaceService.ALFRESCO_URI, QName.createValidLocalName(this.searchName)),
|
QName.createQName(NamespaceService.ALFRESCO_URI, QName.createValidLocalName(searchName)),
|
||||||
ContentModel.TYPE_CONTENT,
|
ContentModel.TYPE_CONTENT,
|
||||||
props);
|
props);
|
||||||
|
|
||||||
@@ -1014,15 +1017,16 @@ public class AdvancedSearchBean
|
|||||||
|
|
||||||
// output an XML serialized version of the SearchContext object
|
// output an XML serialized version of the SearchContext object
|
||||||
writer.putContent(search.toXML());
|
writer.putContent(search.toXML());
|
||||||
|
return null;
|
||||||
tx.commit();
|
}
|
||||||
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
this.cachedSavedSearches.clear();
|
this.cachedSavedSearches.clear();
|
||||||
this.savedSearch = null;
|
this.savedSearch = null;
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_SAVE_SEARCH), e.getMessage()), e);
|
FacesContext.getCurrentInstance(), MSG_ERROR_SAVE_SEARCH), e.getMessage()), e);
|
||||||
outcome = null;
|
outcome = null;
|
||||||
@@ -1039,25 +1043,26 @@ public class AdvancedSearchBean
|
|||||||
{
|
{
|
||||||
String outcome = OUTCOME_BROWSE;
|
String outcome = OUTCOME_BROWSE;
|
||||||
|
|
||||||
SearchContext search = this.navigator.getSearchContext();
|
final SearchContext search = this.navigator.getSearchContext();
|
||||||
if (search != null)
|
if (search != null)
|
||||||
{
|
{
|
||||||
UserTransaction tx = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FacesContext context = FacesContext.getCurrentInstance();
|
final FacesContext context = FacesContext.getCurrentInstance();
|
||||||
tx = Repository.getUserTransaction(context);
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
// handle Edit e.g. Overwrite of existing search
|
// handle Edit e.g. Overwrite of existing search
|
||||||
// detect if was previously selected saved search (e.g. NodeRef not null)
|
// detect if was previously selected saved search (e.g. NodeRef not null)
|
||||||
NodeRef searchRef = new NodeRef(Repository.getStoreRef(), this.savedSearch);
|
NodeRef searchRef = new NodeRef(Repository.getStoreRef(), savedSearch);
|
||||||
if (this.nodeService.exists(searchRef))
|
if (nodeService.exists(searchRef))
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> props = this.nodeService.getProperties(searchRef);
|
Map<QName, Serializable> props = nodeService.getProperties(searchRef);
|
||||||
props.put(ContentModel.PROP_NAME, this.searchName);
|
props.put(ContentModel.PROP_NAME, searchName);
|
||||||
props.put(ContentModel.PROP_DESCRIPTION, this.searchDescription);
|
props.put(ContentModel.PROP_DESCRIPTION, searchDescription);
|
||||||
this.nodeService.setProperties(searchRef, props);
|
nodeService.setProperties(searchRef, props);
|
||||||
|
|
||||||
ContentService contentService = Repository.getServiceRegistry(context).getContentService();
|
ContentService contentService = Repository.getServiceRegistry(context).getContentService();
|
||||||
ContentWriter writer = contentService.getWriter(searchRef, ContentModel.PROP_CONTENT, true);
|
ContentWriter writer = contentService.getWriter(searchRef, ContentModel.PROP_CONTENT, true);
|
||||||
@@ -1068,16 +1073,17 @@ public class AdvancedSearchBean
|
|||||||
|
|
||||||
// output an XML serialized version of the SearchContext object
|
// output an XML serialized version of the SearchContext object
|
||||||
writer.putContent(search.toXML());
|
writer.putContent(search.toXML());
|
||||||
|
|
||||||
tx.commit();
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
this.cachedSavedSearches.clear();
|
this.cachedSavedSearches.clear();
|
||||||
this.savedSearch = null;
|
this.savedSearch = null;
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_SAVE_SEARCH), e.getMessage()), e);
|
FacesContext.getCurrentInstance(), MSG_ERROR_SAVE_SEARCH), e.getMessage()), e);
|
||||||
outcome = null;
|
outcome = null;
|
||||||
|
@@ -32,11 +32,12 @@ import java.util.Map;
|
|||||||
import javax.faces.application.FacesMessage;
|
import javax.faces.application.FacesMessage;
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
import javax.faces.event.ActionEvent;
|
import javax.faces.event.ActionEvent;
|
||||||
import javax.transaction.UserTransaction;
|
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ApplicationModel;
|
import org.alfresco.model.ApplicationModel;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.repository.CopyService;
|
import org.alfresco.service.cmr.repository.CopyService;
|
||||||
import org.alfresco.service.cmr.repository.FileTypeImageSize;
|
import org.alfresco.service.cmr.repository.FileTypeImageSize;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -371,26 +372,26 @@ public abstract class BaseDetailsBean
|
|||||||
{
|
{
|
||||||
String outcome = "cancel";
|
String outcome = "cancel";
|
||||||
|
|
||||||
UserTransaction tx = null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
// firstly retrieve all the properties for the current node
|
// firstly retrieve all the properties for the current node
|
||||||
Map<QName, Serializable> updateProps = this.nodeService.getProperties(
|
Map<QName, Serializable> updateProps = nodeService.getProperties(
|
||||||
getNode().getNodeRef());
|
getNode().getNodeRef());
|
||||||
|
|
||||||
// update the simple workflow properties
|
// update the simple workflow properties
|
||||||
|
|
||||||
// set the approve step name
|
// set the approve step name
|
||||||
updateProps.put(ApplicationModel.PROP_APPROVE_STEP,
|
updateProps.put(ApplicationModel.PROP_APPROVE_STEP,
|
||||||
this.workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_STEP_NAME));
|
workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_STEP_NAME));
|
||||||
|
|
||||||
// specify whether the approve step will copy or move the content
|
// specify whether the approve step will copy or move the content
|
||||||
boolean approveMove = true;
|
boolean approveMove = true;
|
||||||
String approveAction = (String)this.workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_ACTION);
|
String approveAction = (String)workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_ACTION);
|
||||||
if (approveAction != null && approveAction.equals("copy"))
|
if (approveAction != null && approveAction.equals("copy"))
|
||||||
{
|
{
|
||||||
approveMove = false;
|
approveMove = false;
|
||||||
@@ -399,11 +400,11 @@ public abstract class BaseDetailsBean
|
|||||||
|
|
||||||
// create node ref representation of the destination folder
|
// create node ref representation of the destination folder
|
||||||
updateProps.put(ApplicationModel.PROP_APPROVE_FOLDER,
|
updateProps.put(ApplicationModel.PROP_APPROVE_FOLDER,
|
||||||
this.workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_FOLDER));
|
workflowProperties.get(SimpleWorkflowHandler.PROP_APPROVE_FOLDER));
|
||||||
|
|
||||||
// determine whether there should be a reject step
|
// determine whether there should be a reject step
|
||||||
boolean requireReject = true;
|
boolean requireReject = true;
|
||||||
String rejectStepPresent = (String)this.workflowProperties.get(
|
String rejectStepPresent = (String)workflowProperties.get(
|
||||||
SimpleWorkflowHandler.PROP_REJECT_STEP_PRESENT);
|
SimpleWorkflowHandler.PROP_REJECT_STEP_PRESENT);
|
||||||
if (rejectStepPresent != null && rejectStepPresent.equals("no"))
|
if (rejectStepPresent != null && rejectStepPresent.equals("no"))
|
||||||
{
|
{
|
||||||
@@ -414,11 +415,11 @@ public abstract class BaseDetailsBean
|
|||||||
{
|
{
|
||||||
// set the reject step name
|
// set the reject step name
|
||||||
updateProps.put(ApplicationModel.PROP_REJECT_STEP,
|
updateProps.put(ApplicationModel.PROP_REJECT_STEP,
|
||||||
this.workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_STEP_NAME));
|
workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_STEP_NAME));
|
||||||
|
|
||||||
// specify whether the reject step will copy or move the content
|
// specify whether the reject step will copy or move the content
|
||||||
boolean rejectMove = true;
|
boolean rejectMove = true;
|
||||||
String rejectAction = (String)this.workflowProperties.get(
|
String rejectAction = (String)workflowProperties.get(
|
||||||
SimpleWorkflowHandler.PROP_REJECT_ACTION);
|
SimpleWorkflowHandler.PROP_REJECT_ACTION);
|
||||||
if (rejectAction != null && rejectAction.equals("copy"))
|
if (rejectAction != null && rejectAction.equals("copy"))
|
||||||
{
|
{
|
||||||
@@ -428,7 +429,7 @@ public abstract class BaseDetailsBean
|
|||||||
|
|
||||||
// create node ref representation of the destination folder
|
// create node ref representation of the destination folder
|
||||||
updateProps.put(ApplicationModel.PROP_REJECT_FOLDER,
|
updateProps.put(ApplicationModel.PROP_REJECT_FOLDER,
|
||||||
this.workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_FOLDER));
|
workflowProperties.get(SimpleWorkflowHandler.PROP_REJECT_FOLDER));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -440,10 +441,11 @@ public abstract class BaseDetailsBean
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set the properties on the node
|
// set the properties on the node
|
||||||
this.nodeService.setProperties(getNode().getNodeRef(), updateProps);
|
nodeService.setProperties(getNode().getNodeRef(), updateProps);
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
// reset the state of the current document so it reflects the changes just made
|
// reset the state of the current document so it reflects the changes just made
|
||||||
getNode().reset();
|
getNode().reset();
|
||||||
@@ -452,7 +454,6 @@ public abstract class BaseDetailsBean
|
|||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE_SIMPLEWORKFLOW), e.getMessage()), e);
|
FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE_SIMPLEWORKFLOW), e.getMessage()), e);
|
||||||
}
|
}
|
||||||
@@ -493,19 +494,21 @@ public abstract class BaseDetailsBean
|
|||||||
throw new AlfrescoRuntimeException("approve called without an id");
|
throw new AlfrescoRuntimeException("approve called without an id");
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeRef docNodeRef = new NodeRef(Repository.getStoreRef(), id);
|
final NodeRef docNodeRef = new NodeRef(Repository.getStoreRef(), id);
|
||||||
|
|
||||||
UserTransaction tx = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
// call the service to perform the approve
|
// call the service to perform the approve
|
||||||
WorkflowUtil.approve(docNodeRef, this.nodeService, this.copyService);
|
WorkflowUtil.approve(docNodeRef, nodeService, copyService);
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
// if this was called via the document details dialog we need to reset the document node
|
// if this was called via the document details dialog we need to reset the document node
|
||||||
if (getNode() != null)
|
if (getNode() != null)
|
||||||
@@ -518,8 +521,6 @@ public abstract class BaseDetailsBean
|
|||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_WORKFLOW_APPROVE), e.getMessage()), e);
|
FacesContext.getCurrentInstance(), MSG_ERROR_WORKFLOW_APPROVE), e.getMessage()), e);
|
||||||
}
|
}
|
||||||
@@ -558,19 +559,21 @@ public abstract class BaseDetailsBean
|
|||||||
throw new AlfrescoRuntimeException("reject called without an id");
|
throw new AlfrescoRuntimeException("reject called without an id");
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeRef docNodeRef = new NodeRef(Repository.getStoreRef(), id);
|
final NodeRef docNodeRef = new NodeRef(Repository.getStoreRef(), id);
|
||||||
|
|
||||||
UserTransaction tx = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
// call the service to perform the reject
|
// call the service to perform the reject
|
||||||
WorkflowUtil.reject(docNodeRef, this.nodeService, this.copyService);
|
WorkflowUtil.reject(docNodeRef, nodeService, copyService);
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
// if this was called via the document details dialog we need to reset the document node
|
// if this was called via the document details dialog we need to reset the document node
|
||||||
if (getNode() != null)
|
if (getNode() != null)
|
||||||
@@ -584,7 +587,6 @@ public abstract class BaseDetailsBean
|
|||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
// rollback the transaction
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_WORKFLOW_REJECT), e.getMessage()), e);
|
FacesContext.getCurrentInstance(), MSG_ERROR_WORKFLOW_REJECT), e.getMessage()), e);
|
||||||
}
|
}
|
||||||
@@ -649,18 +651,18 @@ public abstract class BaseDetailsBean
|
|||||||
/**
|
/**
|
||||||
* Action Handler to take Ownership of the current Space
|
* Action Handler to take Ownership of the current Space
|
||||||
*/
|
*/
|
||||||
public void takeOwnership(ActionEvent event)
|
public void takeOwnership(final ActionEvent event)
|
||||||
{
|
{
|
||||||
FacesContext fc = FacesContext.getCurrentInstance();
|
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||||
|
|
||||||
UserTransaction tx = null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tx = Repository.getUserTransaction(fc);
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
this.ownableService.takeOwnership(getNode().getNodeRef());
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
|
ownableService.takeOwnership(getNode().getNodeRef());
|
||||||
|
|
||||||
String msg = Application.getMessage(fc, MSG_SUCCESS_OWNERSHIP);
|
String msg = Application.getMessage(fc, MSG_SUCCESS_OWNERSHIP);
|
||||||
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
|
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
|
||||||
@@ -668,14 +670,13 @@ public abstract class BaseDetailsBean
|
|||||||
fc.addMessage(formId + ':' + getPropertiesPanelId(), facesMsg);
|
fc.addMessage(formId + ':' + getPropertiesPanelId(), facesMsg);
|
||||||
|
|
||||||
getNode().reset();
|
getNode().reset();
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
fc, Repository.ERROR_GENERIC), e.getMessage()), e);
|
fc, Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||||
}
|
}
|
||||||
|
@@ -38,6 +38,8 @@ import javax.faces.event.ActionEvent;
|
|||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -447,36 +449,36 @@ public class CategoriesBean implements IContextListener
|
|||||||
{
|
{
|
||||||
String outcome = DEFAULT_OUTCOME;
|
String outcome = DEFAULT_OUTCOME;
|
||||||
|
|
||||||
UserTransaction tx = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FacesContext context = FacesContext.getCurrentInstance();
|
FacesContext context = FacesContext.getCurrentInstance();
|
||||||
tx = Repository.getUserTransaction(context);
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(context);
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
// create category using categoryservice
|
// create category using categoryservice
|
||||||
NodeRef ref;
|
NodeRef ref;
|
||||||
if (categoryRef == null)
|
if (categoryRef == null)
|
||||||
{
|
{
|
||||||
ref = this.categoryService.createRootCategory(Repository.getStoreRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, this.name);
|
ref = categoryService.createRootCategory(Repository.getStoreRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ref = this.categoryService.createCategory(categoryRef, this.name);
|
ref = categoryService.createCategory(categoryRef, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply the titled aspect - for description
|
// apply the titled aspect - for description
|
||||||
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(1, 1.0f);
|
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(1, 1.0f);
|
||||||
titledProps.put(ContentModel.PROP_DESCRIPTION, this.description);
|
titledProps.put(ContentModel.PROP_DESCRIPTION, description);
|
||||||
this.nodeService.addAspect(ref, ContentModel.ASPECT_TITLED, titledProps);
|
nodeService.addAspect(ref, ContentModel.ASPECT_TITLED, titledProps);
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
|
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
|
||||||
outcome = null;
|
outcome = null;
|
||||||
@@ -492,31 +494,33 @@ public class CategoriesBean implements IContextListener
|
|||||||
{
|
{
|
||||||
String outcome = DEFAULT_OUTCOME;
|
String outcome = DEFAULT_OUTCOME;
|
||||||
|
|
||||||
UserTransaction tx = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FacesContext context = FacesContext.getCurrentInstance();
|
FacesContext context = FacesContext.getCurrentInstance();
|
||||||
tx = Repository.getUserTransaction(context);
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(context);
|
||||||
tx.begin();
|
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>()
|
||||||
|
{
|
||||||
|
public NodeRef execute() throws Throwable
|
||||||
|
{
|
||||||
// update the category node
|
// update the category node
|
||||||
NodeRef nodeRef = getActionCategory().getNodeRef();
|
NodeRef nodeRef = getActionCategory().getNodeRef();
|
||||||
this.nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, this.name);
|
nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, name);
|
||||||
|
|
||||||
// apply the titled aspect - for description
|
// apply the titled aspect - for description
|
||||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TITLED) == false)
|
if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TITLED) == false)
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(1, 1.0f);
|
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(1, 1.0f);
|
||||||
titledProps.put(ContentModel.PROP_DESCRIPTION, this.description);
|
titledProps.put(ContentModel.PROP_DESCRIPTION, description);
|
||||||
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, titledProps);
|
nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, titledProps);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, this.description);
|
nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, description);
|
||||||
}
|
}
|
||||||
|
return nodeRef;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
NodeRef nodeRef = txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
// edit the node in the breadcrumb if required
|
// edit the node in the breadcrumb if required
|
||||||
List<IBreadcrumbHandler> location = getLocation();
|
List<IBreadcrumbHandler> location = getLocation();
|
||||||
@@ -533,8 +537,6 @@ public class CategoriesBean implements IContextListener
|
|||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
|
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
|
||||||
outcome = null;
|
outcome = null;
|
||||||
@@ -552,27 +554,28 @@ public class CategoriesBean implements IContextListener
|
|||||||
|
|
||||||
if (getActionCategory() != null)
|
if (getActionCategory() != null)
|
||||||
{
|
{
|
||||||
UserTransaction tx = null;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FacesContext context = FacesContext.getCurrentInstance();
|
FacesContext context = FacesContext.getCurrentInstance();
|
||||||
tx = Repository.getUserTransaction(context);
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(context);
|
||||||
tx.begin();
|
RetryingTransactionCallback<NodeRef> callback = new RetryingTransactionCallback<NodeRef>()
|
||||||
|
{
|
||||||
|
public NodeRef execute() throws Throwable
|
||||||
|
{
|
||||||
// delete the category node using the nodeservice
|
// delete the category node using the nodeservice
|
||||||
NodeRef categoryNodeRef = getActionCategory().getNodeRef();
|
NodeRef categoryNodeRef = getActionCategory().getNodeRef();
|
||||||
this.categoryService.deleteCategory(categoryNodeRef);
|
categoryService.deleteCategory(categoryNodeRef);
|
||||||
|
|
||||||
// if there are other items in the repository using this category
|
// if there are other items in the repository using this category
|
||||||
// all the associations to the category should be removed too
|
// all the associations to the category should be removed too
|
||||||
if (this.members != null && this.members.size() > 0)
|
if (members != null && members.size() > 0)
|
||||||
{
|
{
|
||||||
for (ChildAssociationRef childRef : this.members)
|
for (ChildAssociationRef childRef : members)
|
||||||
{
|
{
|
||||||
List<NodeRef> list = new ArrayList<NodeRef>(this.members.size());
|
List<NodeRef> list = new ArrayList<NodeRef>(members.size());
|
||||||
|
|
||||||
NodeRef member = childRef.getChildRef();
|
NodeRef member = childRef.getChildRef();
|
||||||
Collection<NodeRef> categories = (Collection<NodeRef>)this.nodeService.
|
Collection<NodeRef> categories = (Collection<NodeRef>)nodeService.
|
||||||
getProperty(member, ContentModel.PROP_CATEGORIES);
|
getProperty(member, ContentModel.PROP_CATEGORIES);
|
||||||
|
|
||||||
for (NodeRef category : categories)
|
for (NodeRef category : categories)
|
||||||
@@ -584,12 +587,13 @@ public class CategoriesBean implements IContextListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// persist the list back to the repository
|
// persist the list back to the repository
|
||||||
this.nodeService.setProperty(member, ContentModel.PROP_CATEGORIES, (Serializable)list);
|
nodeService.setProperty(member, ContentModel.PROP_CATEGORIES, (Serializable)list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return categoryNodeRef;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
NodeRef categoryNodeRef = txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
// remove this node from the breadcrumb if required
|
// remove this node from the breadcrumb if required
|
||||||
List<IBreadcrumbHandler> location = getLocation();
|
List<IBreadcrumbHandler> location = getLocation();
|
||||||
@@ -613,8 +617,6 @@ public class CategoriesBean implements IContextListener
|
|||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
|
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err);
|
||||||
outcome = null;
|
outcome = null;
|
||||||
@@ -715,6 +717,7 @@ public class CategoriesBean implements IContextListener
|
|||||||
/**
|
/**
|
||||||
* @see org.alfresco.web.ui.common.component.IBreadcrumbHandler#navigationOutcome(org.alfresco.web.ui.common.component.UIBreadcrumb)
|
* @see org.alfresco.web.ui.common.component.IBreadcrumbHandler#navigationOutcome(org.alfresco.web.ui.common.component.UIBreadcrumb)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public String navigationOutcome(UIBreadcrumb breadcrumb)
|
public String navigationOutcome(UIBreadcrumb breadcrumb)
|
||||||
{
|
{
|
||||||
// All category breadcrumb elements relate to a Categiry Node Id
|
// All category breadcrumb elements relate to a Categiry Node Id
|
||||||
|
@@ -30,11 +30,12 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
import javax.faces.event.ActionEvent;
|
import javax.faces.event.ActionEvent;
|
||||||
import javax.transaction.UserTransaction;
|
|
||||||
|
|
||||||
import org.alfresco.model.ApplicationModel;
|
import org.alfresco.model.ApplicationModel;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.repo.version.VersionModel;
|
import org.alfresco.repo.version.VersionModel;
|
||||||
import org.alfresco.repo.workflow.WorkflowModel;
|
import org.alfresco.repo.workflow.WorkflowModel;
|
||||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||||
@@ -453,16 +454,16 @@ public class CheckinCheckoutBean
|
|||||||
String outcome = null;
|
String outcome = null;
|
||||||
boolean checkoutSuccessful = false;
|
boolean checkoutSuccessful = false;
|
||||||
|
|
||||||
UserTransaction tx = null;
|
final Node node = getDocument();
|
||||||
|
|
||||||
Node node = getDocument();
|
|
||||||
if (node != null)
|
if (node != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
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());
|
||||||
|
|
||||||
@@ -470,39 +471,39 @@ public class CheckinCheckoutBean
|
|||||||
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: " + selectedSpaceId);
|
||||||
}
|
}
|
||||||
NodeRef workingCopyRef = null;
|
NodeRef workingCopyRef = null;
|
||||||
if (getCopyLocation().equals(COPYLOCATION_OTHER) && this.selectedSpaceId != null)
|
if (getCopyLocation().equals(COPYLOCATION_OTHER) && selectedSpaceId != null)
|
||||||
{
|
{
|
||||||
// checkout to a arbituary parent Space
|
// checkout to a arbituary parent Space
|
||||||
NodeRef destRef = this.selectedSpaceId;
|
NodeRef destRef = selectedSpaceId;
|
||||||
|
|
||||||
ChildAssociationRef childAssocRef = this.nodeService.getPrimaryParent(destRef);
|
ChildAssociationRef childAssocRef = nodeService.getPrimaryParent(destRef);
|
||||||
workingCopyRef = this.versionOperationsService.checkout(node.getNodeRef(),
|
workingCopyRef = versionOperationsService.checkout(node.getNodeRef(),
|
||||||
destRef, ContentModel.ASSOC_CONTAINS, childAssocRef.getQName());
|
destRef, ContentModel.ASSOC_CONTAINS, childAssocRef.getQName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// checkout the content to the current space
|
// checkout the content to the current space
|
||||||
workingCopyRef = this.versionOperationsService.checkout(node.getNodeRef());
|
workingCopyRef = versionOperationsService.checkout(node.getNodeRef());
|
||||||
|
|
||||||
// if this is a workflow action and there is a task id present we need
|
// if this is a workflow action and there is a task id present we need
|
||||||
// to also link the working copy to the workflow package so it appears
|
// to also link the working copy to the workflow package so it appears
|
||||||
// in the resources panel in the manage task dialog
|
// in the resources panel in the manage task dialog
|
||||||
if (this.isWorkflowAction && this.workflowTaskId != null &&
|
if (isWorkflowAction && workflowTaskId != null &&
|
||||||
(this.workflowTaskId.equals("null") == false))
|
(workflowTaskId.equals("null") == false))
|
||||||
{
|
{
|
||||||
WorkflowTask task = this.workflowService.getTaskById(this.workflowTaskId);
|
WorkflowTask task = workflowService.getTaskById(workflowTaskId);
|
||||||
if (task != null)
|
if (task != null)
|
||||||
{
|
{
|
||||||
NodeRef workflowPackage = (NodeRef)task.properties.get(WorkflowModel.ASSOC_PACKAGE);
|
NodeRef workflowPackage = (NodeRef)task.properties.get(WorkflowModel.ASSOC_PACKAGE);
|
||||||
if (workflowPackage != null)
|
if (workflowPackage != null)
|
||||||
{
|
{
|
||||||
this.nodeService.addChild(workflowPackage, workingCopyRef,
|
nodeService.addChild(workflowPackage, workingCopyRef,
|
||||||
ContentModel.ASSOC_CONTAINS, QName.createQName(
|
ContentModel.ASSOC_CONTAINS, QName.createQName(
|
||||||
NamespaceService.CONTENT_MODEL_1_0_URI,
|
NamespaceService.CONTENT_MODEL_1_0_URI,
|
||||||
QName.createValidLocalName((String)this.nodeService.getProperty(
|
QName.createValidLocalName((String)nodeService.getProperty(
|
||||||
workingCopyRef, ContentModel.PROP_NAME))));
|
workingCopyRef, ContentModel.PROP_NAME))));
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
@@ -522,17 +523,16 @@ public class CheckinCheckoutBean
|
|||||||
|
|
||||||
workingCopy.getProperties().put("url", url);
|
workingCopy.getProperties().put("url", url);
|
||||||
workingCopy.getProperties().put("fileType32", Utils.getFileTypeImage(workingCopy.getName(), false));
|
workingCopy.getProperties().put("fileType32", Utils.getFileTypeImage(workingCopy.getName(), false));
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
// mark as successful
|
// mark as successful
|
||||||
checkoutSuccessful = true;
|
checkoutSuccessful = true;
|
||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
|
|
||||||
Utils.addErrorMessage(Application.getMessage(
|
Utils.addErrorMessage(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_CHECKOUT) + err.getMessage(), err);
|
FacesContext.getCurrentInstance(), MSG_ERROR_CHECKOUT) + err.getMessage(), err);
|
||||||
}
|
}
|
||||||
@@ -689,25 +689,26 @@ public class CheckinCheckoutBean
|
|||||||
{
|
{
|
||||||
String outcome = null;
|
String outcome = null;
|
||||||
|
|
||||||
UserTransaction tx = null;
|
final Node node = getDocument();
|
||||||
|
|
||||||
Node node = getDocument();
|
|
||||||
if (node != null)
|
if (node != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
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 = contentService.getWriter(node.getNodeRef(), ContentModel.PROP_CONTENT, true);
|
||||||
writer.putContent(this.editorOutput);
|
writer.putContent(editorOutput);
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
// clean up and clear action context
|
// clean up and clear action context
|
||||||
resetState();
|
resetState();
|
||||||
@@ -719,8 +720,6 @@ public class CheckinCheckoutBean
|
|||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
|
|
||||||
Utils.addErrorMessage(Application.getMessage(
|
Utils.addErrorMessage(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE) + err.getMessage());
|
FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE) + err.getMessage());
|
||||||
}
|
}
|
||||||
@@ -828,18 +827,18 @@ public class CheckinCheckoutBean
|
|||||||
{
|
{
|
||||||
String outcome = null;
|
String outcome = null;
|
||||||
|
|
||||||
UserTransaction tx = null;
|
|
||||||
|
|
||||||
// NOTE: for checkin the document node _is_ the working document!
|
// NOTE: for checkin the document node _is_ the working document!
|
||||||
Node node = getDocument();
|
final Node node = getDocument();
|
||||||
if (node != null && (getCopyLocation().equals(COPYLOCATION_CURRENT) || this.getFileName() != null))
|
if (node != null && (getCopyLocation().equals(COPYLOCATION_CURRENT) || this.getFileName() != null))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FacesContext context = FacesContext.getCurrentInstance();
|
final FacesContext context = FacesContext.getCurrentInstance();
|
||||||
tx = Repository.getUserTransaction(context);
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
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());
|
||||||
|
|
||||||
@@ -856,11 +855,11 @@ public class CheckinCheckoutBean
|
|||||||
{
|
{
|
||||||
// add the content to an anonymous but permanent writer location
|
// add the content to an anonymous but permanent writer location
|
||||||
// we can then retrieve the URL to the content to to be set on the node during checkin
|
// we can then retrieve the URL to the content to to be set on the node during checkin
|
||||||
ContentWriter writer = this.contentService.getWriter(node.getNodeRef(), ContentModel.PROP_CONTENT, true);
|
ContentWriter writer = contentService.getWriter(node.getNodeRef(), ContentModel.PROP_CONTENT, true);
|
||||||
// also update the mime type in case a different type of file is uploaded
|
// also update the mime type in case a different type of file is uploaded
|
||||||
String mimeType = Repository.getMimeTypeForFileName(context, this.fileName);
|
String mimeType = Repository.getMimeTypeForFileName(context, fileName);
|
||||||
writer.setMimetype(mimeType);
|
writer.setMimetype(mimeType);
|
||||||
writer.putContent(this.file);
|
writer.putContent(file);
|
||||||
contentUrl = writer.getContentUrl();
|
contentUrl = writer.getContentUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -871,9 +870,9 @@ public class CheckinCheckoutBean
|
|||||||
|
|
||||||
// add version history text to props
|
// add version history text to props
|
||||||
Map<String, Serializable> props = new HashMap<String, Serializable>(1, 1.0f);
|
Map<String, Serializable> props = new HashMap<String, Serializable>(1, 1.0f);
|
||||||
props.put(Version.PROP_DESCRIPTION, this.versionNotes);
|
props.put(Version.PROP_DESCRIPTION, versionNotes);
|
||||||
// set the flag for minor or major change
|
// set the flag for minor or major change
|
||||||
if (this.minorChange)
|
if (minorChange)
|
||||||
{
|
{
|
||||||
props.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR);
|
props.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR);
|
||||||
}
|
}
|
||||||
@@ -883,11 +882,12 @@ public class CheckinCheckoutBean
|
|||||||
}
|
}
|
||||||
|
|
||||||
// perform the checkin
|
// perform the checkin
|
||||||
this.versionOperationsService.checkin(node.getNodeRef(),
|
versionOperationsService.checkin(node.getNodeRef(),
|
||||||
props, contentUrl, this.keepCheckedOut);
|
props, contentUrl, keepCheckedOut);
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
outcome = AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
|
||||||
|
|
||||||
@@ -902,8 +902,6 @@ public class CheckinCheckoutBean
|
|||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
|
|
||||||
Utils.addErrorMessage(Application.getMessage(
|
Utils.addErrorMessage(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_CHECKIN) + err.getMessage(), err);
|
FacesContext.getCurrentInstance(), MSG_ERROR_CHECKIN) + err.getMessage(), err);
|
||||||
}
|
}
|
||||||
@@ -923,32 +921,33 @@ public class CheckinCheckoutBean
|
|||||||
{
|
{
|
||||||
String outcome = null;
|
String outcome = null;
|
||||||
|
|
||||||
UserTransaction tx = null;
|
|
||||||
|
|
||||||
// NOTE: for update the document node _is_ the working document!
|
// NOTE: for update the document node _is_ the working document!
|
||||||
Node node = getDocument();
|
final Node node = getDocument();
|
||||||
if (node != null && this.getFileName() != null)
|
if (node != null && this.getFileName() != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FacesContext context = FacesContext.getCurrentInstance();
|
final FacesContext context = FacesContext.getCurrentInstance();
|
||||||
tx = Repository.getUserTransaction(context);
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
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 = contentService.getWriter(node.getNodeRef(), ContentModel.PROP_CONTENT, true);
|
||||||
|
|
||||||
// also update the mime type in case a different type of file is uploaded
|
// also update the mime type in case a different type of file is uploaded
|
||||||
String mimeType = Repository.getMimeTypeForFileName(context, this.fileName);
|
String mimeType = Repository.getMimeTypeForFileName(context, fileName);
|
||||||
writer.setMimetype(mimeType);
|
writer.setMimetype(mimeType);
|
||||||
|
|
||||||
writer.putContent(this.file);
|
writer.putContent(file);
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
// clear action context
|
// clear action context
|
||||||
setDocument(null);
|
setDocument(null);
|
||||||
@@ -958,8 +957,6 @@ public class CheckinCheckoutBean
|
|||||||
}
|
}
|
||||||
catch (Throwable err)
|
catch (Throwable err)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
|
|
||||||
Utils.addErrorMessage(Application.getMessage(
|
Utils.addErrorMessage(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE) + err.getMessage(), err);
|
FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE) + err.getMessage(), err);
|
||||||
}
|
}
|
||||||
|
@@ -36,11 +36,12 @@ import java.util.Map;
|
|||||||
import javax.faces.application.FacesMessage;
|
import javax.faces.application.FacesMessage;
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
import javax.faces.event.ActionEvent;
|
import javax.faces.event.ActionEvent;
|
||||||
import javax.transaction.UserTransaction;
|
|
||||||
|
|
||||||
import org.alfresco.model.ApplicationModel;
|
import org.alfresco.model.ApplicationModel;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||||
import org.alfresco.service.cmr.lock.LockService;
|
import org.alfresco.service.cmr.lock.LockService;
|
||||||
import org.alfresco.service.cmr.ml.ContentFilterLanguagesService;
|
import org.alfresco.service.cmr.ml.ContentFilterLanguagesService;
|
||||||
@@ -412,25 +413,25 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
|||||||
{
|
{
|
||||||
String outcome = "cancel";
|
String outcome = "cancel";
|
||||||
|
|
||||||
UserTransaction tx = null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
// firstly retrieve all the properties for the current node
|
// firstly retrieve all the properties for the current node
|
||||||
Map<QName, Serializable> updateProps = this.nodeService.getProperties(
|
Map<QName, Serializable> updateProps = nodeService.getProperties(getDocument().getNodeRef());
|
||||||
getDocument().getNodeRef());
|
|
||||||
|
|
||||||
// create a node ref representation of the selected id and set the new properties
|
// create a node ref representation of the selected id and set the new properties
|
||||||
updateProps.put(ContentModel.PROP_CATEGORIES, (Serializable)this.categories);
|
updateProps.put(ContentModel.PROP_CATEGORIES, (Serializable) categories);
|
||||||
|
|
||||||
// set the properties on the node
|
// set the properties on the node
|
||||||
this.nodeService.setProperties(getDocument().getNodeRef(), updateProps);
|
nodeService.setProperties(getDocument().getNodeRef(), updateProps);
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
// reset the state of the current document so it reflects the changes just made
|
// reset the state of the current document so it reflects the changes just made
|
||||||
getDocument().reset();
|
getDocument().reset();
|
||||||
@@ -439,7 +440,6 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
|||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE_CATEGORY), e.getMessage()), e);
|
FacesContext.getCurrentInstance(), MSG_ERROR_UPDATE_CATEGORY), e.getMessage()), e);
|
||||||
}
|
}
|
||||||
@@ -452,26 +452,25 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
|||||||
*/
|
*/
|
||||||
public void applyClassifiable()
|
public void applyClassifiable()
|
||||||
{
|
{
|
||||||
UserTransaction tx = null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
// add the general classifiable aspect to the node
|
// add the general classifiable aspect to the node
|
||||||
this.nodeService.addAspect(getDocument().getNodeRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, null);
|
nodeService.addAspect(getDocument().getNodeRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, null);
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
// reset the state of the current document
|
// reset the state of the current document
|
||||||
getDocument().reset();
|
getDocument().reset();
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_ASPECT_CLASSIFY), e.getMessage()), e);
|
FacesContext.getCurrentInstance(), MSG_ERROR_ASPECT_CLASSIFY), e.getMessage()), e);
|
||||||
}
|
}
|
||||||
@@ -482,26 +481,25 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
|||||||
*/
|
*/
|
||||||
public void applyVersionable()
|
public void applyVersionable()
|
||||||
{
|
{
|
||||||
UserTransaction tx = null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
// add the versionable aspect to the node
|
// add the versionable aspect to the node
|
||||||
this.nodeService.addAspect(getDocument().getNodeRef(), ContentModel.ASPECT_VERSIONABLE, null);
|
nodeService.addAspect(getDocument().getNodeRef(), ContentModel.ASPECT_VERSIONABLE, null);
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
// reset the state of the current document
|
// reset the state of the current document
|
||||||
getDocument().reset();
|
getDocument().reset();
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_ASPECT_VERSIONING), e.getMessage()), e);
|
FacesContext.getCurrentInstance(), MSG_ERROR_ASPECT_VERSIONING), e.getMessage()), e);
|
||||||
}
|
}
|
||||||
@@ -510,18 +508,18 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
|||||||
/**
|
/**
|
||||||
* Action Handler to unlock a locked document
|
* Action Handler to unlock a locked document
|
||||||
*/
|
*/
|
||||||
public void unlock(ActionEvent event)
|
public void unlock(final ActionEvent event)
|
||||||
{
|
{
|
||||||
FacesContext fc = FacesContext.getCurrentInstance();
|
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||||
|
|
||||||
UserTransaction tx = null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tx = Repository.getUserTransaction(fc);
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
this.lockService.unlock(getNode().getNodeRef());
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
|
lockService.unlock(getNode().getNodeRef());
|
||||||
|
|
||||||
String msg = Application.getMessage(fc, MSG_SUCCESS_UNLOCK);
|
String msg = Application.getMessage(fc, MSG_SUCCESS_UNLOCK);
|
||||||
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
|
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
|
||||||
@@ -529,14 +527,13 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
|||||||
fc.addMessage(formId + ':' + getPropertiesPanelId(), facesMsg);
|
fc.addMessage(formId + ':' + getPropertiesPanelId(), facesMsg);
|
||||||
|
|
||||||
getNode().reset();
|
getNode().reset();
|
||||||
|
return null;
|
||||||
// commit the transaction
|
}
|
||||||
tx.commit();
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
fc, Repository.ERROR_GENERIC), e.getMessage()), e);
|
fc, Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||||
}
|
}
|
||||||
@@ -547,13 +544,13 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
|||||||
*/
|
*/
|
||||||
public String applyInlineEditable()
|
public String applyInlineEditable()
|
||||||
{
|
{
|
||||||
UserTransaction tx = null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(FacesContext.getCurrentInstance());
|
||||||
tx.begin();
|
RetryingTransactionCallback<Object> callback = new RetryingTransactionCallback<Object>()
|
||||||
|
{
|
||||||
|
public Object execute() throws Throwable
|
||||||
|
{
|
||||||
// add the inlineeditable aspect to the node
|
// add the inlineeditable aspect to the node
|
||||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1, 1.0f);
|
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1, 1.0f);
|
||||||
String contentType = null;
|
String contentType = null;
|
||||||
@@ -574,18 +571,18 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
|||||||
props.put(ApplicationModel.PROP_EDITINLINE, true);
|
props.put(ApplicationModel.PROP_EDITINLINE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.nodeService.addAspect(getDocument().getNodeRef(), ApplicationModel.ASPECT_INLINEEDITABLE, props);
|
nodeService.addAspect(getDocument().getNodeRef(), ApplicationModel.ASPECT_INLINEEDITABLE, props);
|
||||||
|
|
||||||
// commit the transaction
|
return null;
|
||||||
tx.commit();
|
}
|
||||||
|
};
|
||||||
|
txnHelper.doInTransaction(callback);
|
||||||
|
|
||||||
// reset the state of the current document
|
// reset the state of the current document
|
||||||
getDocument().reset();
|
getDocument().reset();
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
|
||||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||||
FacesContext.getCurrentInstance(), MSG_ERROR_ASPECT_INLINEEDITABLE), e.getMessage()), e);
|
FacesContext.getCurrentInstance(), MSG_ERROR_ASPECT_INLINEEDITABLE), e.getMessage()), e);
|
||||||
}
|
}
|
||||||
|
@@ -26,16 +26,15 @@ package org.alfresco.web.bean.dialog;
|
|||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
import javax.transaction.UserTransaction;
|
|
||||||
|
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
import org.alfresco.service.cmr.model.FileFolderService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
@@ -96,26 +95,29 @@ public abstract class BaseDialogBean implements IDialogBean
|
|||||||
|
|
||||||
public String finish()
|
public String finish()
|
||||||
{
|
{
|
||||||
String outcome = getDefaultFinishOutcome();
|
final FacesContext context = FacesContext.getCurrentInstance();
|
||||||
|
final String defaultOutcome = getDefaultFinishOutcome();
|
||||||
|
String outcome = null;
|
||||||
|
|
||||||
// check the isFinished flag to stop the finish button
|
// check the isFinished flag to stop the finish button
|
||||||
// being pressed multiple times
|
// being pressed multiple times
|
||||||
if (this.isFinished == false)
|
if (this.isFinished == false)
|
||||||
{
|
{
|
||||||
this.isFinished = true;
|
this.isFinished = true;
|
||||||
UserTransaction tx = null;
|
|
||||||
|
|
||||||
|
RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(context);
|
||||||
|
RetryingTransactionCallback<String> callback = new RetryingTransactionCallback<String>()
|
||||||
|
{
|
||||||
|
public String execute() throws Throwable
|
||||||
|
{
|
||||||
|
// call the actual implementation
|
||||||
|
return finishImpl(context, defaultOutcome);
|
||||||
|
}
|
||||||
|
};
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FacesContext context = FacesContext.getCurrentInstance();
|
// Execute
|
||||||
tx = Repository.getUserTransaction(context);
|
outcome = txnHelper.doInTransaction(callback);
|
||||||
tx.begin();
|
|
||||||
|
|
||||||
// call the actual implementation
|
|
||||||
outcome = finishImpl(context, outcome);
|
|
||||||
|
|
||||||
// persist the changes
|
|
||||||
tx.commit();
|
|
||||||
|
|
||||||
// allow any subclasses to perform post commit processing
|
// allow any subclasses to perform post commit processing
|
||||||
// i.e. resetting state or setting status messages
|
// i.e. resetting state or setting status messages
|
||||||
@@ -126,8 +128,6 @@ public abstract class BaseDialogBean implements IDialogBean
|
|||||||
// reset the flag so we can re-attempt the operation
|
// reset the flag so we can re-attempt the operation
|
||||||
isFinished = false;
|
isFinished = false;
|
||||||
|
|
||||||
// rollback the transaction
|
|
||||||
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
|
|
||||||
Utils.addErrorMessage(formatErrorMessage(e), e);
|
Utils.addErrorMessage(formatErrorMessage(e), e);
|
||||||
outcome = getErrorOutcome(e);
|
outcome = getErrorOutcome(e);
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,7 @@ import org.alfresco.repo.configuration.ConfigurableService;
|
|||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.content.metadata.MetadataExtracter;
|
import org.alfresco.repo.content.metadata.MetadataExtracter;
|
||||||
import org.alfresco.repo.content.metadata.MetadataExtracterRegistry;
|
import org.alfresco.repo.content.metadata.MetadataExtracterRegistry;
|
||||||
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.lock.LockService;
|
import org.alfresco.service.cmr.lock.LockService;
|
||||||
import org.alfresco.service.cmr.lock.LockStatus;
|
import org.alfresco.service.cmr.lock.LockStatus;
|
||||||
@@ -376,6 +377,9 @@ public final class Repository
|
|||||||
* @param context FacesContext
|
* @param context FacesContext
|
||||||
*
|
*
|
||||||
* @return UserTransaction
|
* @return UserTransaction
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
|
* @see #getRetryingTransactionHelper(FacesContext)
|
||||||
*/
|
*/
|
||||||
public static UserTransaction getUserTransaction(FacesContext context)
|
public static UserTransaction getUserTransaction(FacesContext context)
|
||||||
{
|
{
|
||||||
@@ -383,6 +387,18 @@ public final class Repository
|
|||||||
return transactionService.getUserTransaction();
|
return transactionService.getUserTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the transaction helper that executes a unit of work.
|
||||||
|
*
|
||||||
|
* @param context FacesContext
|
||||||
|
* @return Returns the transaction helper
|
||||||
|
*/
|
||||||
|
public static RetryingTransactionHelper getRetryingTransactionHelper(FacesContext context)
|
||||||
|
{
|
||||||
|
TransactionService transactionService = getServiceRegistry(context).getTransactionService();
|
||||||
|
return transactionService.getRetryingTransactionHelper();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a UserTransaction instance
|
* Return a UserTransaction instance
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user