Exemplo n.º 1
0
  @Test
  public void testModifyPassword() throws Exception {
    String name = "createUser" + r.nextInt();
    String password = "******";
    UserWrapper user = UserHelper.addUser(name, password, true);

    // check user can connect
    BiobankApplicationService newUserAppService = AllTestsSuite.connect(name, password);
    String newPwd = "new123";
    // search the user again otherwise the appService will still try with
    // testuser
    user = UserWrapper.getUser(newUserAppService, name);
    user.modifyPassword(password, newPwd, null);

    // check user can't connect with old password
    try {
      AllTestsSuite.connect(name, password);
      Assert.fail("Should not be able to connect with the old password anymore");
    } catch (ApplicationException ae) {
      Assert.assertTrue(
          "Should failed because of authentication",
          ae.getMessage().contains("Error authenticating user"));
    }
    // check user can't connect with new password
    AllTestsSuite.connect(name, newPwd);
  }
 @Override
 public boolean isEnabled() {
   if (allowed == null)
     try {
       allowed = SessionManager.getAppService().isAllowed(new UserManagerPermission());
     } catch (ApplicationException e) {
       BgcPlugin.openAsyncError("Unable to Load User Management Data", e.getMessage());
     }
   return allowed;
 }
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
      BiobankApplicationService service = SessionManager.getAppService();
      ManagerContext context =
          service.doAction(new ManagerContextGetAction(new ManagerContextGetInput())).getContext();

      new UserManagementDialog(
              PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), context)
          .open();
    } catch (ApplicationException e) {
      BgcPlugin.openAsyncError("Unable to Load User Management Data", e.getMessage());
    }

    return null;
  }
  @Override
  public boolean print() {
    PrintOperation printOperation = null;
    BarcodeViewGuiData guiData = null;
    try {
      guiData = new BarcodeViewGuiData();

      List<String> patientNumbers =
          SessionManager.getAppService().executeGetSourceSpecimenUniqueInventoryIds(32);

      // print operation
      printOperation = new PrintOperation(guiData, patientNumbers);

      try {
        new ProgressMonitorDialog(shell).run(true, true, printOperation);
      } catch (InvocationTargetException e1) {
        printOperation.saveFailed();
        printOperation.setError(
            Messages.PatientLabelEntryForm_print_error_title,
            "InvocationTargetException: " //$NON-NLS-1$
                + e1.getCause().getMessage());
      }

      if (printOperation.isSuccessful()) {
        updateSavePreferences();
        clearFieldsConfirm();
        return true;
      }

      if (printOperation.errorExists()) {
        BgcPlugin.openAsyncError(printOperation.getError()[0], printOperation.getError()[1]);
        return false;
      }

    } catch (BiobankServerException e) {
      BgcPlugin.openAsyncError(Messages.PatientLabelEntryForm_specimenid_error_msg, e.getMessage());
    } catch (ApplicationException e) {
      BgcPlugin.openAsyncError(Messages.PatientLabelEntryForm_server_error_msg, e.getMessage());
    } catch (CBSRGuiVerificationException e1) {
      BgcPlugin.openAsyncError(
          Messages.PatientLabelEntryForm_validation_error_msg, e1.getMessage());
    } catch (InterruptedException e2) {
      // do nothing
    }
    return false;
  }
  public void testTissueSpecimenReadAccess() {
    List<Object> result = null;
    try {
      result =
          getApplicationService()
              .query(
                  CqlUtility.getTissueSpecimensForCP(
                      PropertiesLoader.getCPTitleForScientistReadForTissueSpecimen()));

      for (Object o : result) {
        TissueSpecimen t = (TissueSpecimen) o;
        if (t.getCreatedOn() != null) {
          assertFalse("Failed to retrieve Tissue Specimens having masked data", true);
        }
      }
    } catch (ApplicationException e) {
      e.printStackTrace();
      assertFalse("Not able to retrieve Fuild Specimen list using API", true);
    }
  }
        @Override
        public void widgetSelected(SelectionEvent e) {
          BarcodeViewGuiData guiData = null;

          try {
            guiData = new BarcodeViewGuiData();

            // save dialog for pdf file.
            FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
            fileDialog.setFilterPath(
                perferenceStore.getString(PreferenceConstants.PDF_DIRECTORY_PATH));
            fileDialog.setOverwrite(true);
            fileDialog.setFileName("default.pdf"); // $NON-NLS-1$
            String pdfFilePath = fileDialog.open();

            if (pdfFilePath == null) return;

            List<String> patientNumbers =
                SessionManager.getAppService().executeGetSourceSpecimenUniqueInventoryIds(32);

            SaveOperation saveOperation = new SaveOperation(guiData, patientNumbers, pdfFilePath);

            try {
              new ProgressMonitorDialog(shell).run(true, true, saveOperation);

            } catch (InvocationTargetException e1) {
              saveOperation.saveFailed();
              saveOperation.setError(
                  Messages.PatientLabelEntryForm_saveop_error_title,
                  "InvocationTargetException: " //$NON-NLS-1$
                      + e1.getCause().getMessage());

            } catch (InterruptedException e2) {
              BgcPlugin.openAsyncError(Messages.PatientLabelEntryForm_save_error_title, e2);
            }

            if (saveOperation.isSuccessful()) {
              String parentDir = new File(pdfFilePath).getParentFile().getPath();
              if (parentDir != null)
                perferenceStore.setValue(PreferenceConstants.PDF_DIRECTORY_PATH, parentDir);

              updateSavePreferences();
              clearFieldsConfirm();
              return;
            }

            if (saveOperation.errorExists()) {
              BgcPlugin.openAsyncError(saveOperation.getError()[0], saveOperation.getError()[1]);
            }

          } catch (CBSRGuiVerificationException e1) {
            BgcPlugin.openAsyncError(e1.title, e1.messsage);
            return;
          } catch (BiobankServerException e2) {
            BgcPlugin.openAsyncError(
                Messages.PatientLabelEntryForm_specId_error_title, e2.getMessage());
          } catch (ApplicationException e3) {
            BgcPlugin.openAsyncError(
                Messages.PatientLabelEntryForm_server_error_title, e3.getMessage());
          }
        }