Esempio n. 1
0
  @Override
  public void process(
      final HasCancellation cancellation, OrcsSession session, TransactionData txData) {
    try {
      final Set<Long> datas = new LinkedHashSet<Long>();
      txData
          .getChangeSet()
          .accept(
              new OrcsVisitorAdapter() {
                @Override
                public void visit(AttributeData data) {
                  IAttributeType type = types.getByUuid(data.getTypeUuid());
                  if (types.isTaggable(type)) {
                    datas.add(data.getVersion().getGammaId());
                  }
                }
              });

      List<Future<?>> futures = indexer.indexResources(session, types, datas).call();
      for (Future<?> future : futures) {
        if (cancellation != null && cancellation.isCancelled()) {
          future.cancel(true);
        } else {
          // Wait for execution to complete
          future.get();
        }
      }
    } catch (Exception ex) {
      logger.error(ex, "Error indexing transaction [%s]", txData);
    }
  }
 /** Called after a resource method is executed */
 @Override
 public void filter(
     ContainerRequestContext requestContext, ContainerResponseContext responseContext) {
   if (activityLog.isEnabled()) {
     try {
       Long entryId =
           (Long) requestContext.getProperty(ActivityConstants.HTTP_HEADER__ACTIVITY_ENTRY_ID);
       if (entryId != null) {
         StatusType statusType = responseContext.getStatusInfo();
         if (statusType.getFamily() == Status.Family.SUCCESSFUL) {
           activityLog.completeEntry(entryId);
         } else {
           activityLog.endEntryAbnormally(entryId, responseContext.getStatus());
         }
       } else {
         // Response was called without a matching request
         activityLog.createActivityThread(
             Activity.JAXRS_METHOD_CALL_FILTER_ERROR,
             ActivityConstants.DEFAULT_ACCOUNT_ID,
             ActivityConstants.DEFAULT_SERVER_ID,
             ActivityConstants.DEFAULT_CLIENT_ID,
             ActivityConstants.ERROR_MSG__MISSING_ACTIVITY_HEADER);
       }
     } catch (Throwable th) {
       logger.error(th, "Error during ActivityContainerResponseFilter");
     }
   }
 }
  private static OseeServerInfoMutable createOseeServerInfo(
      Log logger, ApplicationServerDataStore dataStore, Set<String> defaultVersions) {
    String serverAddress = "127.0.0.1";
    try {
      serverAddress = InetAddress.getLocalHost().getCanonicalHostName();
    } catch (UnknownHostException ex) {
      //
    }
    int port = OseeServerProperties.getOseeApplicationServerPort();

    String checkSum = "-1";
    try {
      String address = String.format("%s:%s", serverAddress, port);
      ByteArrayInputStream inputStream = new ByteArrayInputStream(address.getBytes("UTF-8"));
      checkSum = ChecksumUtil.createChecksumAsString(inputStream, ChecksumUtil.MD5);
    } catch (Exception ex) {
      logger.error(ex, "Error generating application server id");
    }
    OseeServerInfoMutable toReturn =
        new OseeServerInfoMutable(
            checkSum,
            serverAddress,
            port,
            new String[0],
            GlobalTime.GreenwichMeanTimestamp(),
            false);
    toReturn.setVersions(defaultVersions);
    return toReturn;
  }
Esempio n. 4
0
  /** 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");
      }
    }
  }
 private void setServletRequestsAllowedNoDbUpdate(final boolean value) {
   try {
     setServletRequestsAllowed(value, PersistType.DONT_DB_PERSIST);
   } catch (OseeCoreException ex) {
     logger.warn(
         ex,
         "Error updating servlet requests allowed to [%s]- current setting is [%s]",
         value,
         getApplicationServerInfo().isAcceptingRequests());
   }
 }