/**
 * @author bardhi
 * @since 8/19/14.
 */
public class WorkflowScriptRefConstants {

  public static final String SCRIPT_URI = "scriptURI";
  public static final String PARAMS = "params";
  public static final String URI =
      RaptureURI.builder(Scheme.WORKFLOW, "core").docPath("script/ref").build().toString();
}
Ejemplo n.º 2
0
  @Override
  public Boolean writeLog(String category, int level, String message, String user) {
    StringBuilder logMessage = new StringBuilder();
    logMessage.append(df.print(DateTime.now()));
    logMessage.append(" ");
    logMessage.append(message);
    logMessage.append("\n");

    String docPath = blobPrefix;
    RaptureURI uri = RaptureURI.builder(Scheme.BLOB, blobUri).docPath(docPath).build();
    Kernel.getBlob()
        .getTrusted()
        .appendToBlobLower(
            ContextFactory.getKernelUser(),
            uri.toString(),
            logMessage.toString().getBytes(),
            "text/plain");
    return true;
  }
Ejemplo n.º 3
0
  @Override
  public List<AuditLogEntry> getRecentEntries(int count) {
    String docPath = blobPrefix;
    RaptureURI uri = RaptureURI.builder(Scheme.BLOB, blobUri).docPath(docPath).build();
    CallingContext context = ContextFactory.getKernelUser();
    BlobApiImpl blobApi = Kernel.getBlob().getTrusted();

    ArrayList<AuditLogEntry> ret = new ArrayList<AuditLogEntry>();
    BlobContainer content = blobApi.getBlob(context, uri.toString());
    if (content != null) {
      addContentToList(content, ret);
      return (ret.size() > count) ? ret.subList(ret.size() - count, ret.size()) : ret;
    } else {
      // get children blobs, eg. get logs for all steps of a work order
      Map<String, RaptureFolderInfo> childrenMap =
          blobApi.listBlobsByUriPrefix(context, uri.toString(), 1);

      if (childrenMap != null) {
        for (RaptureFolderInfo child : childrenMap.values()) {
          if (child.isFolder()) {
            continue;
          }
          String childUri = uri.getFullPath() + "/" + child.getName();
          content = blobApi.getBlob(context, childUri);
          addContentToList(content, ret, true);
          if (ret.size() >= count) {
            break;
          }
        }
      }
    }
    // sort audit log entries by time
    Collections.sort(
        ret,
        new Comparator<AuditLogEntry>() {
          @Override
          public int compare(AuditLogEntry o1, AuditLogEntry o2) {
            return o1.getWhen().compareTo(o2.getWhen());
          }
        });
    return (ret.size() > count) ? ret.subList(0, count) : ret;
  }