Skip to content

Commit

Permalink
NXP-17447, NXP-16052: deprecate ClientException, remove throws Exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Guillaume committed Jul 6, 2015
1 parent 12411fb commit 2225636
Show file tree
Hide file tree
Showing 43 changed files with 92 additions and 194 deletions.
Expand Up @@ -54,15 +54,15 @@ public abstract class AbstractJbpmHandlerHelper implements ActionHandler, Assign

public static final String SUFFIX_MAJOR = "_MAJOR";

public void execute(ExecutionContext executionContext) throws Exception {
public void execute(ExecutionContext executionContext) {
throw new UnsupportedOperationException();
}

public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
public void assign(Assignable assignable, ExecutionContext executionContext) {
throw new UnsupportedOperationException();
}

public String decide(ExecutionContext executionContext) throws Exception {
public String decide(ExecutionContext executionContext) {
throw new UnsupportedOperationException();
}

Expand All @@ -74,7 +74,7 @@ public void submitTaskVariables(TaskInstance taskInstance, ContextInstance conte
throw new UnsupportedOperationException();
}

public JbpmService getJbpmService() throws Exception {
public JbpmService getJbpmService() {
if (jbpmService == null) {
jbpmService = Framework.getService(JbpmService.class);
}
Expand Down Expand Up @@ -114,12 +114,12 @@ protected String getSwimlaneUser(String swimlaneName) {

/** @deprecated since 5.4 */
@Deprecated
protected void followTransition(NuxeoPrincipal principal, DocumentRef docRef, String transition) throws Exception {
protected void followTransition(NuxeoPrincipal principal, DocumentRef docRef, String transition) {
followTransition(principal, docRef, transition, null);
}

protected void followTransition(NuxeoPrincipal principal, DocumentRef docRef, String transition,
VersioningOption option) throws Exception {
VersioningOption option) {
try (CoreSession coreSession = CoreInstance.openCoreSession(getDocumentRepositoryName(), principal)) {
coreSession.followTransition(docRef, transition);
if (option != null) {
Expand Down
Expand Up @@ -27,7 +27,6 @@
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.NuxeoPrincipal;
Expand Down
Expand Up @@ -20,7 +20,6 @@

import java.util.List;

import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;

/**
Expand Down
Expand Up @@ -16,12 +16,12 @@
*/
package org.nuxeo.ecm.platform.jbpm;

import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.NuxeoException;

/**
* @author arussel
*/
public class NuxeoJbpmException extends ClientException {
public class NuxeoJbpmException extends NuxeoException {

private static final long serialVersionUID = 1L;

Expand Down
Expand Up @@ -26,7 +26,6 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;

public class TaskListImpl implements TaskList {
Expand Down Expand Up @@ -93,12 +92,7 @@ public DocumentModel getDocument() {
}

public String getName() {
try {
return doc.getTitle();
} catch (ClientException e) {
log.error(e);
}
return null;
return doc.getTitle();
}

public String getUUID() {
Expand Down
Expand Up @@ -22,7 +22,6 @@
import java.util.Date;

import org.jbpm.graph.exe.ProcessInstance;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;

/**
Expand All @@ -47,11 +46,7 @@ public class DocumentProcessItemImpl implements DocumentProcessItem {
public DocumentProcessItemImpl(ProcessInstance processInstance, DocumentModel documentModel) {
this.documentModel = documentModel;
this.processInstance = processInstance;
try {
docTitle = documentModel.getTitle();
} catch (ClientException e) {
docTitle = null;
}
docTitle = documentModel.getTitle();
processInstanceName = processInstance.getProcessDefinition().getName();
processInstanceStartDate = processInstance.getStart();
}
Expand Down
Expand Up @@ -21,7 +21,6 @@

import java.util.Collection;

import org.nuxeo.ecm.core.api.ClientException;

public interface WorkflowDashBoard {

Expand Down
Expand Up @@ -20,7 +20,6 @@
import java.util.Map;

import org.nuxeo.common.utils.i18n.I18NUtils;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.impl.DocumentLocationImpl;
import org.nuxeo.ecm.platform.types.adapter.TypeInfo;
Expand Down
Expand Up @@ -106,7 +106,7 @@ public enum OperationTaskVariableName {

@OperationMethod(collector = DocumentModelCollector.class)
@SuppressWarnings("unchecked")
public DocumentModel run(DocumentModel document) throws Exception {
public DocumentModel run(DocumentModel document) throws OperationException {
Principal pal = coreSession.getPrincipal();
if (!(pal instanceof NuxeoPrincipal)) {
throw new OperationException("Principal is not an instance of NuxeoPrincipal");
Expand Down
Expand Up @@ -63,7 +63,7 @@ public class GetUserTasks {
protected JbpmService srv;

@OperationMethod
public Blob run() throws Exception {
public Blob run() {
NuxeoPrincipal principal = principal();
List<TaskInstance> tasks = srv.getCurrentTaskInstances(principal, filter());
if (tasks == null) {
Expand Down
Expand Up @@ -71,7 +71,7 @@ public class UserProcessPageProviderOperation extends AbstractWorkflowOperation

@SuppressWarnings("unchecked")
@OperationMethod
public Blob run() throws Exception {
public Blob run() {
Map<String, Serializable> props = new HashMap<String, Serializable>();
props.put(UserProcessPageProvider.CORE_SESSION_PROPERTY, (Serializable) session);
PageProviderService pps = Framework.getLocalService(PageProviderService.class);
Expand Down
Expand Up @@ -71,7 +71,7 @@ public class UserTaskPageProviderOperation extends AbstractWorkflowOperation {

@SuppressWarnings("unchecked")
@OperationMethod
public Blob run() throws Exception {
public Blob run() {
Map<String, Serializable> props = new HashMap<String, Serializable>();
props.put(UserProcessPageProvider.CORE_SESSION_PROPERTY, (Serializable) session);
PageProviderService pps = Framework.getLocalService(PageProviderService.class);
Expand Down
Expand Up @@ -26,7 +26,6 @@
import org.nuxeo.ecm.automation.InvalidChainException;
import org.nuxeo.ecm.automation.OperationContext;
import org.nuxeo.ecm.automation.jbpm.CreateTask.OperationTaskVariableName;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.event.Event;
import org.nuxeo.ecm.core.event.EventContext;
import org.nuxeo.ecm.core.event.EventListener;
Expand Down
Expand Up @@ -16,7 +16,6 @@
*/
package org.nuxeo.ecm.platform.jbpm.core.helper;

import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.DocumentRef;
Expand Down
Expand Up @@ -16,7 +16,6 @@
*/
package org.nuxeo.ecm.platform.jbpm.core.helper;

import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentRef;
import org.nuxeo.ecm.core.api.UnrestrictedSessionRunner;
Expand Down
Expand Up @@ -51,7 +51,7 @@ public class AddRightsActionHandler extends AbstractJbpmHandlerHelper {

@Override
@SuppressWarnings("unchecked")
public void execute(ExecutionContext executionContext) throws Exception {
public void execute(ExecutionContext executionContext) {
this.executionContext = executionContext;
if (nuxeoHasStarted() && list != null) {
List<VirtualTaskInstance> participants = (List<VirtualTaskInstance>) executionContext.getContextInstance().getTransientVariable(
Expand Down
Expand Up @@ -22,7 +22,6 @@

import org.jbpm.taskmgmt.exe.PooledActor;
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.UnrestrictedSessionRunner;

Expand Down
Expand Up @@ -36,7 +36,7 @@ public class LifecycleTransitionActionHandler extends AbstractJbpmHandlerHelper

private static final long serialVersionUID = 1L;

protected NuxeoPrincipal getNuxeoPrincipal(String user) throws Exception {
protected NuxeoPrincipal getNuxeoPrincipal(String user) {
UserManager userManager = Framework.getService(UserManager.class);
if (user.startsWith(NuxeoPrincipal.PREFIX)) {
user = user.substring(NuxeoPrincipal.PREFIX.length());
Expand All @@ -45,7 +45,7 @@ protected NuxeoPrincipal getNuxeoPrincipal(String user) throws Exception {
}

@Override
public void execute(ExecutionContext executionContext) throws Exception {
public void execute(ExecutionContext executionContext) {
this.executionContext = executionContext;
if (nuxeoHasStarted()) {
String endLifecycle = getEndLifecycleTransition();
Expand Down
Expand Up @@ -20,17 +20,16 @@

import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.taskmgmt.exe.Assignable;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;

// FIXME: this interface has no implementation. Remove?
public interface PublicationHelper extends Serializable {

String decide(ExecutionContext executionContext) throws Exception;
String decide(ExecutionContext executionContext);

void publishDocument(CoreSession session, DocumentModel docToPublish, DocumentModel sectionToPublish);

void assign(Assignable assignable, ExecutionContext executionContext) throws Exception;
void assign(Assignable assignable, ExecutionContext executionContext);

}
Expand Up @@ -35,7 +35,7 @@ public class RemoveRightsActionHandler extends AbstractJbpmHandlerHelper {
private static final long serialVersionUID = 1L;

@Override
public void execute(ExecutionContext executionContext) throws Exception {
public void execute(ExecutionContext executionContext) {
this.executionContext = executionContext;
if (nuxeoHasStarted()) {
try (CoreSession session = CoreInstance.openCoreSessionSystem(getDocumentRepositoryName())) {
Expand Down
Expand Up @@ -16,7 +16,6 @@
*/
package org.nuxeo.ecm.platform.jbpm.core.helper;

import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentRef;
import org.nuxeo.ecm.core.api.UnrestrictedSessionRunner;
Expand Down
Expand Up @@ -6,7 +6,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jbpm.graph.exe.ExecutionContext;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreInstance;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
Expand Down Expand Up @@ -39,7 +38,7 @@ public class SendEventActionHandler extends AbstractJbpmHandlerHelper {
protected String recipients;

@Override
public void execute(ExecutionContext executionContext) throws Exception {
public void execute(ExecutionContext executionContext) {
this.executionContext = executionContext;
assert eventName != null;
assert recipients != null;
Expand All @@ -60,11 +59,7 @@ public void execute(ExecutionContext executionContext) throws Exception {
}

protected EventProducer getEventProducerService() {
try {
return Framework.getService(EventProducer.class);
} catch (Exception e) {
throw new ClientException(e);
}
return Framework.getService(EventProducer.class);
}

protected String[] getRecipients() {
Expand Down
Expand Up @@ -21,7 +21,6 @@

import org.jbpm.graph.exe.Comment;
import org.jbpm.graph.exe.ExecutionContext;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreInstance;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
Expand All @@ -47,7 +46,7 @@ public class TaskNotificationHandler extends AbstractJbpmHandlerHelper {
private static final String DIRECTIVE_KEY = "directive";

@Override
public void execute(ExecutionContext executionContext) throws Exception {
public void execute(ExecutionContext executionContext) {
this.executionContext = executionContext;
if (nuxeoHasStarted()) {
DocumentModel documentModel = (DocumentModel) getTransientVariable(JbpmService.VariableName.document.name());
Expand All @@ -56,12 +55,7 @@ public void execute(ExecutionContext executionContext) throws Exception {
return;
}
try (CoreSession coreSession = CoreInstance.openCoreSession(getDocumentRepositoryName(), principal)) {
EventProducer eventProducer;
try {
eventProducer = Framework.getService(EventProducer.class);
} catch (Exception e) {
throw new ClientException(e);
}
EventProducer eventProducer = Framework.getService(EventProducer.class);
DocumentEventContext ctx = new DocumentEventContext(coreSession, principal, documentModel);
ctx.setProperty(NotificationConstants.RECIPIENTS_KEY, getRecipients());
ctx.setProperty(DocumentEventContext.COMMENT_PROPERTY_KEY, getComments());
Expand Down
Expand Up @@ -39,7 +39,6 @@
import org.jbpm.persistence.db.DbPersistenceServiceFactory;
import org.jbpm.svc.Services;
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreInstance;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
Expand All @@ -48,6 +47,7 @@
import org.nuxeo.ecm.core.api.NuxeoPrincipal;
import org.nuxeo.ecm.core.event.EventProducer;
import org.nuxeo.ecm.core.event.impl.DocumentEventContext;
import org.nuxeo.ecm.core.model.NoSuchDocumentException;
import org.nuxeo.ecm.platform.jbpm.JbpmActorsListFilter;
import org.nuxeo.ecm.platform.jbpm.JbpmListFilter;
import org.nuxeo.ecm.platform.jbpm.JbpmOperation;
Expand Down Expand Up @@ -326,7 +326,7 @@ protected DocumentModel getDocumentModel(NuxeoPrincipal user, String docId, Stri
DocumentModel result = session.getDocument(new IdRef(docId));
result.detach(true);
return result;
} catch (ClientException e) {
} catch (NoSuchDocumentException e) {
throw new NuxeoJbpmException(e);
}
}
Expand Down Expand Up @@ -553,12 +553,8 @@ public Serializable run(JbpmContext context) throws NuxeoJbpmException {
});
}

protected NuxeoPrincipal getPrincipal(String user) throws NuxeoJbpmException {
try {
return getUserManager().getPrincipal(user);
} catch (ClientException e) {
throw new NuxeoJbpmException(e);
}
protected NuxeoPrincipal getPrincipal(String user) {
return getUserManager().getPrincipal(user);
}

protected UserManager getUserManager() {
Expand Down Expand Up @@ -885,7 +881,7 @@ public ArrayList<TaskInstance> run(JbpmContext context) throws NuxeoJbpmExceptio
});
}

protected EventProducer getEventProducer() throws Exception {
protected EventProducer getEventProducer() {
if (eventProducer == null) {
eventProducer = Framework.getService(EventProducer.class);
}
Expand All @@ -898,11 +894,7 @@ public void notifyEventListeners(String name, String comment, String[] recipient
DocumentEventContext ctx = new DocumentEventContext(session, principal, doc);
ctx.setProperty("recipients", recipients);
ctx.getProperties().put("comment", comment);
try {
getEventProducer().fireEvent(ctx.newEvent(name));
} catch (Exception e) {
throw new ClientException(e);
}
getEventProducer().fireEvent(ctx.newEvent(name));
}

}
Expand Up @@ -21,7 +21,6 @@
import java.util.ArrayList;
import java.util.List;

import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.DocumentModelList;
Expand Down

0 comments on commit 2225636

Please sign in to comment.