/*
   * (non-Javadoc)
   *
   * @see org.jboss.arquillian.container.sramp.SrampService#undeployArchives()
   */
  public void undeployArchives(String archiveId) throws SrampClientException, SrampAtomException {

    log.debug("Deleting expanded artifacts");

    // Delete expanded artifacts
    QueryResultSet rset =
        client
            .buildQuery("/s-ramp[expandedFromDocument[@arquillian-archive-id = ?]]")
            .parameter(archiveId)
            .query();

    for (ArtifactSummary artifactSummary : rset) {
      log.debug("Deleting: " + artifactSummary.getName());
      client.deleteArtifact(artifactSummary.getUuid(), artifactSummary.getType());
    }

    // Delete (un)deployment information
    rset =
        client
            .buildQuery("/s-ramp[describesDeployment[@arquillian-archive-id = ?]]")
            .parameter(archiveId)
            .query();
    for (ArtifactSummary artifactSummary : rset) {
      log.debug("Deleting: " + artifactSummary.getName());
      client.deleteArtifact(artifactSummary.getUuid(), artifactSummary.getType());
    }

    // Delete main archive
    // Related are deleted along with the primary
    rset = client.buildQuery("/s-ramp[@arquillian-archive-id = ?]").parameter(archiveId).query();

    ArtifactSummary archiveArtifact = rset.get(0);

    log.debug("Deleting: " + archiveArtifact.getName());

    client.deleteArtifact(archiveArtifact.getUuid(), archiveArtifact.getType());

    // Internal consistency check whether the number of artifacts before
    // deploy and after deploy match
    long artifactCounterTemp = client.query("/s-ramp").getTotalResults();

    if (artifactCounter != artifactCounterTemp) {
      log.warn("Artifact counts does not match!");
      log.warn(
          "Artifacts before deploy: "
              + artifactCounter
              + ". Artifacts after undeploy: "
              + artifactCounterTemp);
      artifactCounter = artifactCounterTemp;
    }
  }
示例#2
0
  /**
   * Main.
   *
   * @param args
   */
  public static void main(String[] args) throws Exception {
    System.out.println("\n*** Running S-RAMP Simple Client Demo ***\n");

    // Figure out the endpoint of the S-RAMP repository's Atom API
    String endpoint = System.getProperty("sramp.endpoint");
    if (endpoint == null || endpoint.trim().length() == 0) {
      endpoint = DEFAULT_ENDPOINT;
    }
    System.out.println("S-RAMP Endpoint: " + endpoint);

    // Upload some artifacts to the S-RAMP repository
    System.out.println("Uploading some XML schemas...");
    SrampAtomApiClient client = new SrampAtomApiClient(endpoint);
    for (String file : FILES) {
      // Get an InputStream over the file content
      InputStream is = SimpleClientDemo.class.getResourceAsStream(file);

      try {
        // We need to know the artifact type
        ArtifactType type = ArtifactType.XsdDocument;
        if (file.endsWith(".wsdl")) {
          type = ArtifactType.WsdlDocument;
        }

        // Upload that content to S-RAMP
        System.out.print("\tUploading artifact " + file + "...");
        BaseArtifactType artifact = client.uploadArtifact(type, is, file);
        System.out.println("done.");

        // Update the artifact meta-data (set the version and add a custom property)
        artifact.setVersion("1.1");
        SrampModelUtils.setCustomProperty(artifact, "demo", "simple-client");

        // Tell the server about the updated meta-data
        System.out.print("\tUpdating meta-data for artifact " + file + "...");
        client.updateArtifactMetaData(artifact);
        System.out.println("done.");
      } finally {
        is.close();
      }
    }

    // Now query the S-RAMP repository (for the Schemas only)
    System.out.print("Querying the S-RAMP repository for Schemas...");
    QueryResultSet rset = client.query("/s-ramp/xsd/XsdDocument");
    System.out.println("success: " + rset.size() + " Schemas found:");
    for (ArtifactSummary entry : rset) {
      System.out.println("\t * " + entry.getName() + " (" + entry.getUuid() + ")");
    }

    System.out.println("\n*** Demo Completed Successfully ***\n\n");
    Thread.sleep(3000);
  }