/**
  * @throws FinderException
  * @ejb.interface-method
  */
 public void deletePrivateFile(long file_pk) throws RemoteException {
   try {
     privFileHome.remove(new Long(file_pk));
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 /** @ejb.interface-method */
 public void deletePrivatePatient(long patient_pk) throws RemoteException {
   try {
     privPatHome.remove(new Long(patient_pk));
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
  /**
   * Delete a list of instances, i.e., move them to trash bin
   *
   * @ejb.interface-method
   * @param iuids A list of instance uid
   * @param cascading True to delete the series/study if there's no instance/series
   * @return a collection of Dataset containing the actuall detetion information per study
   * @throws RemoteException
   */
  public Collection moveInstancesToTrash(String[] iuids, boolean cascading) throws RemoteException {
    try {
      // These instances may belong to multiple studies,
      // although mostly they should be the same study
      Map mapStudies = new HashMap();
      for (int i = 0; i < iuids.length; i++) {
        InstanceLocal instance = instHome.findBySopIuid(iuids[i]);
        SeriesLocal series = instance.getSeries();
        StudyLocal study = series.getStudy();
        if (!mapStudies.containsKey(study)) mapStudies.put(study, new HashMap());
        Map mapSeries = (Map) mapStudies.get(study);
        if (!mapSeries.containsKey(series)) mapSeries.put(series, new ArrayList());
        Collection colInstances = (Collection) mapSeries.get(series);
        colInstances.add(instance);
      }

      List dss = new ArrayList();
      Iterator iter = mapStudies.keySet().iterator();
      while (iter.hasNext()) {
        StudyLocal study = (StudyLocal) iter.next();
        dss.add(getStudyMgtDataset(study, (Map) mapStudies.get(study)));
        Iterator iter2 = ((Map) mapStudies.get(study)).keySet().iterator();
        while (iter2.hasNext()) {
          SeriesLocal series = (SeriesLocal) iter2.next();
          List instances = (List) ((Map) mapStudies.get(study)).get(series);
          for (int i = 0; i < instances.size(); i++) {
            // Delete the instance now, i.e., move to trash bin,
            // becoming private instance
            getPrivateInstance((InstanceLocal) instances.get(i), DELETED, null);
            ((InstanceLocal) instances.get(i)).remove();
          }
          if (series.getInstances().size() == 0 && cascading) {
            // Delete the series too since there's no instance left
            getPrivateSeries(series, DELETED, null, false);
            series.remove();
          } else UpdateDerivedFieldsUtils.updateDerivedFieldsOf(series);
        }
        if (study.getSeries().size() == 0 && cascading) {
          // Delete the study too since there's no series left
          getPrivateStudy(study, DELETED, null, false);
          study.remove();
        } else UpdateDerivedFieldsUtils.updateDerivedFieldsOf(study);
      }

      return dss;
    } catch (CreateException e) {
      throw new RemoteException(e.getMessage());
    } catch (EJBException e) {
      throw new RemoteException(e.getMessage());
    } catch (FinderException e) {
      throw new RemoteException(e.getMessage());
    } catch (RemoveException e) {
      throw new RemoteException(e.getMessage());
    }
  }
 /**
  * @throws FinderException
  * @ejb.interface-method
  */
 public void deletePrivateFiles(Collection fileDTOs) throws RemoteException {
   try {
     for (Iterator iter = fileDTOs.iterator(); iter.hasNext(); ) {
       privFileHome.remove(new Long(((FileDTO) iter.next()).getPk()));
     }
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 /** @ejb.interface-method */
 public void deleteAll(int privateType) throws RemoteException {
   try {
     Collection c = privPatHome.findByPrivateType(privateType);
     for (Iterator iter = c.iterator(); iter.hasNext(); ) {
       privPatHome.remove(((PrivatePatientLocal) iter.next()).getPk());
     }
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   } catch (FinderException e) {
     throw new RemoteException(e.getMessage());
   }
 }
  @Override
  public CommandResult execute(ParameterContainer parameters) {

    boolean force = parameters.containsKey(FORCE_KEY);

    try {
      String username = parameters.get(USERNAME_KEY);
      int inp = 121;
      if (!force) {
        getLogger().info("Have you revoked the end entity [y/N]? ");
        try {
          inp = System.in.read();
        } catch (IOException e) {
          throw new IllegalStateException("Could not read console input.");
        }
      }
      if ((inp == 121) || (inp == 89)) {
        try {
          EjbRemoteHelper.INSTANCE
              .getRemoteSession(EndEntityManagementSessionRemote.class)
              .deleteUser(getAuthenticationToken(), username);
          getLogger().info("Deleted end entity with username: "******"ERROR: Not authorized to remove end entity.");
          return CommandResult.FUNCTIONAL_FAILURE;
        } catch (RemoveException e) {
          getLogger().error("ERROR: User could not be removed. " + e.getMessage());
          return CommandResult.FUNCTIONAL_FAILURE;
        }
      } else {
        getLogger().info("Deletion aborted!");
        getLogger()
            .info(
                "Please run '"
                    + new RevokeEndEntityCommand().getMainCommand()
                    + " "
                    + new RevokeEndEntityCommand().getMainCommand()
                    + " "
                    + username
                    + "'.");
        return CommandResult.FUNCTIONAL_FAILURE;
      }
    } catch (NotFoundException e) {
      getLogger().error("ERROR: No such end entity.");
      return CommandResult.FUNCTIONAL_FAILURE;
    }
  }
 /**
  * @throws FinderException
  * @ejb.interface-method
  */
 public Collection deletePrivateStudy(long study_pk) throws RemoteException, FinderException {
   try {
     PrivateStudyLocal study = privStudyHome.findByPrimaryKey(new Long(study_pk));
     ArrayList files = null;
     PrivatePatientLocal pat = study.getPatient();
     study.remove();
     if (pat.getStudies().isEmpty()) {
       pat.remove();
     }
     return files;
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 /** @ejb.interface-method */
 public Dataset moveStudyToTrash(long study_pk) throws RemoteException {
   try {
     StudyLocal study = studyHome.findByPrimaryKey(new Long(study_pk));
     Dataset ds = getStudyMgtDataset(study, null);
     getPrivateStudy(study, DELETED, null, true);
     study.remove();
     return ds;
   } catch (CreateException e) {
     throw new RemoteException(e.getMessage());
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (FinderException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 /**
  * @throws FinderException
  * @ejb.interface-method
  */
 public void deletePrivateSeries(long series_pk) throws RemoteException, FinderException {
   try {
     PrivateSeriesLocal series = privSeriesHome.findByPrimaryKey(new Long(series_pk));
     PrivateStudyLocal study = series.getStudy();
     series.remove();
     if (study.getSeries().isEmpty()) {
       PrivatePatientLocal pat = study.getPatient();
       study.remove();
       if (pat.getStudies().isEmpty()) {
         pat.remove();
       }
     }
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
Exemplo n.º 10
0
 public String delete() {
   if (name.equalsIgnoreCase("default")) {
     setErrorMessage("Builtin profile 'Default' can not be deleted.");
     return null;
   }
   try {
     Ejb.lookupDeviceProfileBean().findByPrimaryKey(name).remove();
     setDeleted();
     return "deleted";
   } catch (RemoveException ex) {
     setErrorMessage(ex.getMessage());
   } catch (EJBException ex) {
     setErrorMessage(ex.getMessage());
   } catch (FinderException ex) {
     setErrorMessage(ex.getMessage());
   }
   return null;
 }
 /** @ejb.interface-method */
 public Dataset moveSeriesToTrash(long series_pk) throws RemoteException {
   try {
     SeriesLocal series = seriesHome.findByPrimaryKey(new Long(series_pk));
     StudyLocal study = series.getStudy();
     Map mapSeries = new HashMap();
     mapSeries.put(series, series.getInstances());
     Dataset ds = getStudyMgtDataset(series.getStudy(), mapSeries);
     getPrivateSeries(series, DELETED, null, true);
     series.remove();
     UpdateDerivedFieldsUtils.updateDerivedFieldsOf(study);
     return ds;
   } catch (CreateException e) {
     throw new RemoteException(e.getMessage());
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (FinderException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
Exemplo n.º 12
0
  public void remove(Object ejbRef) {

    EJBLocalObjectImpl localObjectImpl = getEJBLocalObject(ejbRef);

    if (localObjectImpl == null) {
      throw new UnsupportedOperationException("Invalid ejb ref");
    }

    Container container = localObjectImpl.getContainer();
    EjbDescriptor ejbDesc = container.getEjbDescriptor();
    boolean isStatefulBean = false;

    if (ejbDesc.getType().equals(EjbSessionDescriptor.TYPE)) {

      EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
      isStatefulBean = sessionDesc.isStateful();
    }

    if (!isStatefulBean) {

      // TODO 299 impl may incorrectly call this for stateless/singleton
      // beans.  Until it's fixed just treat it as a no-op. Otherwise, any app acquiring
      // stateless/singleton references via 299 could fail until bug is fixed.
      return;

      // TODO reenable this after bug is fixed
      // throw new UnsupportedOperationException("ejbRef for ejb " +
      //       ejbDesc.getName() + " is not a stateful bean ");
    }

    try {
      localObjectImpl.remove();
    } catch (EJBException e) {
      LogFacade.getLogger().log(Level.FINE, "EJBException during remove. ", e);
    } catch (javax.ejb.RemoveException re) {
      throw new NoSuchEJBException(re.getMessage(), re);
    }
  }
 /** @ejb.interface-method */
 public Collection movePatientToTrash(long pat_pk) throws RemoteException {
   try {
     PatientLocal patient = patHome.findByPrimaryKey(new Long(pat_pk));
     Collection col = patient.getStudies();
     Collection result = new ArrayList();
     for (Iterator iter = col.iterator(); iter.hasNext(); ) {
       result.add(getStudyMgtDataset((StudyLocal) iter.next(), null));
     }
     Dataset ds = patient.getAttributes(true);
     getPrivatePatient(patient, DELETED, true);
     patient.remove();
     if (result.isEmpty()) result.add(ds);
     return result;
   } catch (CreateException e) {
     throw new RemoteException(e.getMessage());
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (FinderException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }
 /** @ejb.interface-method */
 public Dataset moveInstanceToTrash(long instance_pk) throws RemoteException {
   try {
     InstanceLocal instance = instHome.findByPrimaryKey(new Long(instance_pk));
     Collection colInstance = new ArrayList();
     colInstance.add(instance);
     SeriesLocal series = instance.getSeries();
     Map mapSeries = new HashMap();
     mapSeries.put(series, colInstance);
     Dataset ds = getStudyMgtDataset(series.getStudy(), mapSeries);
     getPrivateInstance(instance, DELETED, null);
     instance.remove();
     UpdateDerivedFieldsUtils.updateDerivedFieldsOf(series);
     UpdateDerivedFieldsUtils.updateDerivedFieldsOf(series.getStudy());
     return ds;
   } catch (CreateException e) {
     throw new RemoteException(e.getMessage());
   } catch (EJBException e) {
     throw new RemoteException(e.getMessage());
   } catch (FinderException e) {
     throw new RemoteException(e.getMessage());
   } catch (RemoveException e) {
     throw new RemoteException(e.getMessage());
   }
 }