Beispiel #1
0
  @Override
  public boolean processResponse(final String response) {

    CoreThreadFactory.getCallBackExecutorService()
        .execute(
            new Runnable() {
              @Override
              public void run() {
                if (response.equals("OK")) {
                  log.info(
                      String.format(
                          "Action [%s] callback executed for [%s] ", getName(), workflowName));
                  listener.onActionFinished(RepositoryAction.this);
                } else {
                  log.error(
                      String.format(
                          "Action [%s] executed for [%s] but got error response: %s ",
                          getName(), workflowName, response));
                  listener.onActionError(RepositoryAction.this, response);
                }
              }
            });

    return false;
  }
Beispiel #2
0
  @Override
  public void processAction() {

    if (source == null || source.isEmpty()) {
      source = cache.getString(WorkflowCache.RECENTLOCATION);
    }

    log.info(String.format("Action [%s] is being executed for [%s] ", getName(), workflowName));
    log.info(String.format("Using [%s]", clientURL));
    Client client = Client.create();
    client.setReadTimeout(990000);
    WebResource webResource = client.resource(clientURL);

    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    for (Entry ent : (List<Entry>) cache.getAll(Entry.class)) {
      queryParams.add(
          "filepath", StringHelper.joinDirectoryString(source, ent.getString(Entry.NAME)));
    }

    queryParams.add("callback", config.getCallbackURL());
    queryParams.add("actionid", String.valueOf(getID()));
    queryParams.add("workflowid", String.valueOf(workflowId));
    queryParams.add("actionsetid", String.valueOf(actionSetId));

    try {
      ClientResponse response = webResource.queryParams(queryParams).post(ClientResponse.class);

      if (response.getClientResponseStatus() != ClientResponse.Status.OK) {
        final String error =
            String.format(
                "Action [%s] executed for [%s] but got HTTP status: %s ",
                getName(), workflowName, response.getClientResponseStatus().toString());
        log.error(error);
        log.error(String.format("HTTP response: %s ", response.getEntity(String.class)));
        log.error(String.format("HTTP headers: %s ", response.getHeaders()));

        CoreThreadFactory.getCallBackExecutorService()
            .execute(
                new Runnable() {
                  @Override
                  public void run() {
                    listener.onActionError(RepositoryAction.this, error);
                  }
                });
      } else {
        log.info(
            String.format(
                "Action [%s] executed for [%s] with HTTP status: %s ",
                getName(), workflowName, response.getClientResponseStatus().toString()));
        CoreThreadFactory.getCallBackExecutorService()
            .execute(
                new Runnable() {
                  @Override
                  public void run() {
                    listener.onActionFinished(RepositoryAction.this);
                  }
                });
      }
    } catch (final Exception e) {
      log.error(
          String.format("Action [%s] executed for [%s] but got error", getName(), workflowName), e);
      CoreThreadFactory.getCallBackExecutorService()
          .execute(
              new Runnable() {
                @Override
                public void run() {
                  listener.onActionError(
                      RepositoryAction.this,
                      e.getMessage() + " [make sure that repository client is running]");
                }
              });
    }
  }