/** Called before a resource method is executed */
  @Override
  public void filter(ContainerRequestContext context) {
    if (activityLog.isEnabled()) {
      try {
        String message =
            String.format("%s %s", context.getMethod(), context.getUriInfo().getRequestUri());
        Long serverId = getServerId(context);
        Long clientId = ActivityConstants.DEFAULT_CLIENT_ID;
        if (Strings.isNumeric(context.getHeaders().getFirst("osee.client.id"))) {
          clientId = Long.valueOf(context.getHeaders().getFirst("osee.client.id"));
        }

        Long accountId = ActivityConstants.DEFAULT_ACCOUNT_ID;
        if (Strings.isNumeric(context.getHeaders().getFirst("osee.account.id"))) {
          accountId = Long.valueOf(context.getHeaders().getFirst("osee.account.id"));
        }
        Long entryId =
            activityLog.createActivityThread(
                Activity.JAXRS_METHOD_CALL, accountId, serverId, clientId, message);

        context.setProperty(ActivityConstants.HTTP_HEADER__ACTIVITY_ENTRY_ID, entryId);
      } catch (Throwable th) {
        logger.error(th, "Error during ActivityContainerRequestFilter");
      }
    }
  }
示例#2
0
  @Override
  public Callable<?> createCallable(Console console, ConsoleParameters params) {
    List<Long> branchUuids = new ArrayList<Long>();
    for (String uuid : params.getArray("branchUuids")) {
      if (Strings.isNumeric(uuid)) {
        branchUuids.add(Long.parseLong(uuid));
      } else {
        console.writeln("UUID listed %s is not a valid UUID", uuid);
      }
    }

    if (branchUuids.isEmpty()) {
      console.writeln("No branch uuids where specified");
    }

    Collection<String> options = params.getOptions();
    boolean recurse = options.contains("R");
    boolean unArchived = options.contains("A");
    boolean unDeleted = options.contains("D");
    boolean baseline = options.contains("B");
    boolean runPurge = options.contains("P");

    OrcsBranch orcsBranch = getOrcsApi().getBranchOps(null);
    return new PurgeBranchCallable(
        console,
        orcsBranch,
        getOrcsApi().getQueryFactory(null),
        branchUuids,
        recurse,
        unArchived,
        unDeleted,
        baseline,
        runPurge);
  }
示例#3
0
  @Override
  protected void restoreWidgetValues() {
    super.restoreWidgetValues();
    IDialogSettings settings = getDialogSettings();
    if (settings != null) {
      if (getDefaultSourceFile() == null) {
        directoryFileSelector.setDirectorySelected(settings.getBoolean("isDirectory"));
        String file = settings.get("source.file");
        if (Strings.isValid(file)) {
          directoryFileSelector.setText(file);
        }
      }

      String parser = settings.get("selected.parser");
      if (Strings.isValid(parser)) {
        for (IArtifactExtractor item : importContributionManager.getExtractors()) {
          if (parser.equals(item.getClass().getSimpleName())) {
            parserSelectPanel.setArtifactExtractor(item);
          }
        }
      }
      if (getDefaultDestinationArtifact() == null) {
        String guid = settings.get("destination.artifact.guid");
        String branchUuidStr = settings.get("destination.branch.uuid");

        if (GUID.isValid(guid) && Strings.isNumeric(branchUuidStr)) {
          try {
            Long bramchUuid = Long.valueOf(branchUuidStr);
            Artifact artifact =
                ArtifactQuery.getArtifactFromId(guid, BranchManager.getBranchByUuid(bramchUuid));
            artifactSelectPanel.setDefaultItem(artifact);
          } catch (OseeCoreException ex) {
            OseeLog.logf(
                Activator.class,
                Level.SEVERE,
                "Unable to restore destination artifact- guid:[%s] branch uuid:[%d]",
                guid,
                branchUuidStr);
          }
        }
      }

      boolean toUpdate = settings.getBoolean("is.update.existing.selected");
      updateExistingArtifacts.setSelection(toUpdate);
      deleteUnmatchedArtifacts.setEnabled(toUpdate);
      if (toUpdate) {
        try {
          ArtifactType artType = ArtifactTypeManager.getType(getArtifactType());
          attributeTypeSelectPanel.setAllowedAttributeTypes(
              artType.getAttributeTypes(getDestinationArtifact().getFullBranch()));
        } catch (OseeCoreException ex) {
          OseeLog.log(Activator.class, Level.SEVERE, ex);
        }
      } else {
        attributeTypeSelectPanel.setAllowedAttributeTypes(new ArrayList<IAttributeType>());
      }
    }
  }
 @Override
 public IOseeBranch adapt(Attribute<?> attribute, Identity<String> identity)
     throws OseeCoreException {
   String uuid = identity.getGuid();
   return Strings.isNumeric(uuid) ? BranchManager.getBranchByUuid(Long.valueOf(uuid)) : null;
 }