99import edu .harvard .iq .dataverse .RoleAssigneeServiceBean ;
1010import edu .harvard .iq .dataverse .UserNotification ;
1111import edu .harvard .iq .dataverse .UserNotificationServiceBean ;
12- import edu .harvard .iq .dataverse .DatasetLock .Reason ;
1312import edu .harvard .iq .dataverse .authorization .users .ApiToken ;
1413import edu .harvard .iq .dataverse .authorization .users .AuthenticatedUser ;
1514import edu .harvard .iq .dataverse .engine .command .CommandContext ;
@@ -79,9 +78,6 @@ public class WorkflowServiceBean {
7978 @ EJB
8079 EjbDataverseEngine engine ;
8180
82- @ EJB
83- WorkflowServiceBean self ;
84-
8581 @ Inject
8682 DataverseRequestServiceBean dvRequestService ;
8783
@@ -137,9 +133,7 @@ public void start(Workflow wf, WorkflowContext ctxt, boolean findDataset) throws
137133 * (e.g. if this method is not asynchronous)
138134 *
139135 */
140- logger .info ("Ctxt lock id is " + ctxt .getLockId ());
141- boolean isLocked = ctxt .getLockId ()!=null ;
142- if (!findDataset && !isLocked ) {
136+ if (!findDataset ) {
143137 /*
144138 * Sleep here briefly to make sure the database update from the callers
145139 * transaction completes which avoids any concurrency/optimistic lock issues.
@@ -157,9 +151,7 @@ public void start(Workflow wf, WorkflowContext ctxt, boolean findDataset) throws
157151 }
158152 //Refresh will only em.find the dataset if findDataset is true. (otherwise the dataset is em.merged)
159153 ctxt = refresh (ctxt , retrieveRequestedSettings ( wf .getRequiredSettings ()), getCurrentApiToken (ctxt .getRequest ().getAuthenticatedUser ()), findDataset );
160- if (!isLocked ) {
161- lockDataset (ctxt , new DatasetLock (DatasetLock .Reason .Workflow , ctxt .getRequest ().getAuthenticatedUser ()));
162- }
154+ lockDataset (ctxt , new DatasetLock (DatasetLock .Reason .Workflow , ctxt .getRequest ().getAuthenticatedUser ()));
163155 forward (wf , ctxt );
164156 }
165157
@@ -274,7 +266,7 @@ private void rollback(Workflow wf, WorkflowContext ctxt, Failure failure, int la
274266
275267 logger .log ( Level .INFO , "Removing workflow lock" );
276268 try {
277- self . unlockDataset (ctxt );
269+ unlockDataset (ctxt );
278270 } catch (CommandException ex ) {
279271 logger .log (Level .SEVERE , "Error restoring dataset locks state after rollback: " + ex .getMessage (), ex );
280272 }
@@ -355,12 +347,11 @@ void lockDataset(WorkflowContext ctxt, DatasetLock datasetLock) throws CommandEx
355347 em .persist (datasetLock );
356348 //flush creates the id
357349 em .flush ();
358- logger .info ("Adding new lock id " + datasetLock .getId ());
359350 ctxt .setLockId (datasetLock .getId ());
360351 }
361352
362353 @ TransactionAttribute (TransactionAttributeType .REQUIRES_NEW )
363- public void unlockDataset (WorkflowContext ctxt ) throws CommandException {
354+ void unlockDataset (WorkflowContext ctxt ) throws CommandException {
364355 /*
365356 * Since the lockDataset command above directly persists a lock to the database,
366357 * the ctxt.getDataset() is not updated and its list of locks can't be used.
@@ -372,15 +363,12 @@ public void unlockDataset(WorkflowContext ctxt) throws CommandException {
372363 lockCounter .setParameter ("datasetId" , ctxt .getDataset ().getId ());
373364 List <DatasetLock > locks = lockCounter .getResultList ();
374365 for (DatasetLock lock : locks ) {
375- logger .info ("Found lock id " + lock .getId ());
376366 if (lock .getReason () == DatasetLock .Reason .Workflow ) {
377367 ctxt .getDataset ().removeLock (lock );
378- logger .info ("Removing lock id " + lock .getId ());
379368 em .remove (lock );
380369 }
381370 }
382371 em .flush ();
383- logger .info ("dataset locked " + (null != ctxt .getDataset ().getLockFor (Reason .Workflow )));
384372 }
385373
386374 //
@@ -416,7 +404,7 @@ private void workflowCompleted(Workflow wf, WorkflowContext ctxt) {
416404 lockDataset (ctxt , lock );
417405 ctxt .getDataset ().addLock (lock );
418406
419- self . unlockDataset (ctxt );
407+ unlockDataset (ctxt );
420408 ctxt .setLockId (null ); //the workflow lock
421409 //Refreshing merges the dataset
422410 ctxt = refresh (ctxt );
0 commit comments