public void execute(XmlDoc.Element args, Inputs in, Outputs out, XmlWriter w) throws Throwable {
   // By definition the CID is for a local object. We don't care if
   // asset exists or primary/replica
   String id = args.value("id");
   String project = args.value("project");
   grantAccessToProject(executor(), id, project);
 }
Ejemplo n.º 2
0
  public void execute(XmlDoc.Element args, Inputs in, Outputs out, XmlWriter w) throws Throwable {
    String id = args.value("id");
    Collection docTypes = args.values("doctype");

    // Decrypt
    boolean encrypt = false;
    SvcSubjectEncrypt.encryptDecrypt(executor(), id, docTypes, encrypt, w);
  }
Ejemplo n.º 3
0
  public static Archive instantiate(XmlDoc.Element arcElement) throws Throwable {

    Type type = Type.instantiate(arcElement.value("type"));
    Archive arc = new Archive(type);
    List<XmlDoc.Element> pes = arcElement.elements("parameter");
    if (pes != null) {
      for (XmlDoc.Element pe : pes) {
        arc.setParameter(pe.value("@name"), pe.value());
      }
    }
    return arc;
  }
Ejemplo n.º 4
0
  public void execute(XmlDoc.Element args, Inputs in, Outputs out, XmlWriter w) throws Throwable {
    // Get arguments and parse
    XmlDoc.Element authority = args.element("authority");
    String domain = args.value("domain");
    String user = args.value("user");
    Collection<String> roles = args.values("role");
    Collection<String> pssdRoles = args.values("pssd-role");
    if (roles == null && pssdRoles == null) {
      throw new Exception("You must supply a 'role' and/or 'pssd-role'.");
    }

    // Do the work
    Boolean grant = false;
    SvcUserRoleGrant.grantRevoke(executor(), authority, domain, user, roles, pssdRoles, w, grant);
  }
  public void execute(XmlDoc.Element args, Inputs in, Outputs out, XmlWriter w) throws Throwable {

    /*
     * get the cid argument value
     */
    String id = args.value("cid");
    /*
     * build the args for om.pssd.object.describe service.
     */
    XmlDocMaker dm = new XmlDocMaker("args");
    dm.add("id", id);
    /*
     * call om.pssd.object.describe service.
     */
    XmlDoc.Element r = executor().execute("om.pssd.object.describe", dm.root());
    /*
     * return the result.
     */
    w.add(r.element("object"));
  }
  public void execute(XmlDoc.Element args, Inputs in, Outputs out, XmlWriter w) throws Throwable {

    // Add the role ID on
    XmlDoc.Element role = args.element("role");
    PSSDUtils.checkRoleExists(executor(), role.value(), true);
    SvcRoleMemberRegAdd.addRoleID(executor(), role);

    // Find the registry asset. If does not exist yet return silently.
    String id =
        AssetRegistry.findRegistry(
            executor(), SvcRoleMemberRegAdd.REGISTRY_ASSET_NAME, AssetRegistry.AccessType.PUBLIC);
    if (id == null) return;

    // See if role already exists
    Boolean checkTopName = true;
    String docId =
        AssetRegistry.checkExists(executor(), id, SvcRoleMemberRegAdd.DOCTYPE, role, checkTopName);

    // Remove the role
    if (docId != null) {
      AssetRegistry.removeItem(executor(), id, docId, role, SvcRoleMemberRegAdd.DOCTYPE);
      w.add("id", id);
    }
  }
Ejemplo n.º 7
0
  @Override
  public void consume(
      java.lang.Object multiCtx,
      java.lang.String path,
      java.util.Map<java.lang.String, java.lang.String> parameters,
      XmlDoc.Element userMeta,
      XmlDoc.Element meta,
      LongInputStream in,
      java.lang.String appMimeType,
      java.lang.String streamMimeType,
      long length)
      throws Throwable {

    Connection conn = multiCtx == null ? null : ((MultiTransferContext) multiCtx).connection;
    Session session = multiCtx == null ? null : ((MultiTransferContext) multiCtx).session;
    Params params = Params.parse(parameters);
    if (multiCtx == null) {
      conn = Ssh.get().getConnection(params.serverDetails());
      session = conn.connect(params.userDetails(), true);
    }

    String assetId = meta != null ? meta.value("@id") : null;
    String ext = meta != null ? meta.value("content/type/@ext") : null;

    try {

      String baseDir = params.directory != null ? params.directory : session.getHome();
      StringBuilder sb = new StringBuilder(baseDir);
      if (!baseDir.endsWith("/")) {
        sb.append("/");
      }
      if (path != null) {
        path = path.replace("\\\\", "/").replace("\\", "/");
        while (path.startsWith("/")) {
          path = path.substring(1);
        }
        sb.append(path);
      }

      Set<String> existingDirs =
          multiCtx == null
              ? Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>())
              : ((MultiTransferContext) multiCtx).existingDirectories;
      if (params.decompress
          && streamMimeType != null
          && ArchiveRegistry.isAnArchive(streamMimeType)) {
        // decompress archive
        if (assetId != null) {
          sb.append("/");
          sb.append("asset_");
          sb.append(assetId);
        }
        if (RemoteArchiveExtractor.canExtract(session, streamMimeType)) {
          sb.append("/");
          sb.append(PathUtil.getRandomFileName(8));
          sb.append(".tmp");
          String remotePath = sb.toString();
          transfer(session, in, length, remotePath, params.fileMode, existingDirs);
          RemoteArchiveExtractor.extract(session, remotePath);
        } else {
          extractAndTransfer(
              session,
              sb.toString(),
              ArchiveRegistry.createInput(in, new NamedMimeType(streamMimeType)),
              params.fileMode,
              existingDirs);
        }
      } else {
        // single file
        if (assetId != null) {
          sb.append("/");
          sb.append("asset_");
          sb.append(assetId);
        }
        if (ext != null) {
          sb.append(".");
          sb.append(ext);
        }
        transfer(session, in, length, sb.toString(), params.fileMode, existingDirs);
      }
    } finally {
      if (multiCtx == null) {
        if (session != null) {
          session.close();
        }
        if (conn != null) {
          conn.disconnect();
        }
      }
    }
  }