protected Dataset doNAction(ActiveAssociation assoc, Dimse rq, Command rspCmd)
     throws IOException, DcmServiceException {
   Command cmd = rq.getCommand();
   int actionTypeID = cmd.getInt(Tags.ActionTypeID, -1);
   String iuid = cmd.getRequestedSOPInstanceUID();
   Dataset ds = rq.getDataset();
   if (log.isDebugEnabled()) {
     log.debug("Received N-Action cmd with ds:");
     log.debug(ds);
   }
   checkStudyIuid(iuid, ds);
   try {
     switch (actionTypeID) {
       case 1:
         service.moveSeriesToTrash(toSeriesIuids(ds));
         break;
       case 2:
         service.moveInstancesToTrash(toSopIuids(ds));
         break;
     }
   } catch (Exception e) {
     throw new DcmServiceException(Status.ProcessingFailure, e);
   }
   service.sendStudyMgtNotification(assoc, Command.N_ACTION_RQ, actionTypeID, iuid, ds);
   return null;
 }
 protected Dataset doNSet(ActiveAssociation assoc, Dimse rq, Command rspCmd)
     throws IOException, DcmServiceException {
   Command cmd = rq.getCommand();
   String iuid = cmd.getRequestedSOPInstanceUID();
   Dataset ds = rq.getDataset();
   checkStudyIuid(iuid, ds);
   try {
     StudyMgt stymgt = getStudyMgtHome().create();
     try {
       stymgt.updateStudy(iuid, ds, service.studyMovePatientMatching());
     } finally {
       try {
         stymgt.remove();
       } catch (Exception e) {
         log.warn("Failed to remove StudyMgt Session Bean", e);
       }
     }
   } catch (DcmServiceException e) {
     throw e;
   } catch (Exception e) {
     throw new DcmServiceException(Status.ProcessingFailure, e);
   }
   service.sendStudyMgtNotification(assoc, Command.N_SET_RQ, 0, iuid, ds);
   return null;
 }
 protected Dataset doNCreate(ActiveAssociation assoc, Dimse rq, Command rspCmd)
     throws IOException, DcmServiceException {
   Command cmd = rq.getCommand();
   String iuid = cmd.getAffectedSOPInstanceUID();
   Dataset ds = rq.getDataset();
   String suid = ds.getString(Tags.StudyInstanceUID);
   if (suid == null) {
     throw new DcmServiceException(Status.MissingAttribute, "Missing Study Instance UID");
   }
   if (iuid == null) {
     rspCmd.putUI(Tags.AffectedSOPInstanceUID, iuid = suid);
   } else {
     checkStudyIuid(iuid, ds);
   }
   try {
     StudyMgt stymgt = getStudyMgtHome().create();
     try {
       stymgt.createStudy(ds, service.patientMatching());
     } finally {
       try {
         stymgt.remove();
       } catch (Exception e) {
         log.warn("Failed to remove StudyMgt Session Bean", e);
       }
     }
   } catch (DcmServiceException e) {
     throw e;
   } catch (Exception e) {
     throw new DcmServiceException(Status.ProcessingFailure, e);
   }
   service.sendStudyMgtNotification(assoc, Command.N_CREATE_RQ, 0, iuid, ds);
   return null;
 }
 protected Dataset doNDelete(ActiveAssociation assoc, Dimse rq, Command rspCmd)
     throws IOException, DcmServiceException {
   Command cmd = rq.getCommand();
   String iuid = cmd.getRequestedSOPInstanceUID();
   Dataset ds = rq.getDataset(); // should be null
   try {
     service.moveStudyToTrash(iuid);
   } catch (ObjectNotFoundException e) {
     if (!ignoreDeleteFailed) {
       throw new DcmServiceException(Status.NoSuchObjectInstance);
     }
   } catch (Exception e) {
     throw new DcmServiceException(Status.ProcessingFailure, e);
   }
   service.sendStudyMgtNotification(assoc, Command.N_DELETE_RQ, 0, iuid, null);
   return null;
 }
 public StudyMgtScp(StudyMgtScpService service) {
   this.service = service;
   this.log = service.getLog();
 }