/*
   * (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
  @POST
  @Consumes("application/json")
  public Response importRealm(@Context final UriInfo uriInfo, final RealmRepresentation rep) {
    logger.debug("importRealm: {0}", rep.getRealm());
    RealmManager realmManager = new RealmManager(session);
    if (realmManager.getRealm(rep.getRealm()) != null) {
      return Flows.errors().exists("Realm " + rep.getRealm() + " already exists");
    }

    RealmModel realm = realmManager.importRealm(rep, admin);
    URI location = realmUrl(uriInfo).build(realm.getId());
    logger.debug("imported realm success, sending back: {0}", location.toString());
    return Response.created(location).build();
  }
예제 #3
0
  @PUT
  @Consumes("application/json")
  public void updateRealm(final RealmRepresentation rep) {
    auth.requireManage();

    logger.debug("updating realm: " + realm.getName());
    new RealmManager(session).updateRealm(rep, realm);
  }
예제 #4
0
 @GET
 @NoCache
 @Produces("application/json")
 public List<RealmRepresentation> getRealms() {
   logger.debug(("getRealms()"));
   RealmManager realmManager = new RealmManager(session);
   List<RealmModel> realms = session.getRealms(admin);
   List<RealmRepresentation> reps = new ArrayList<RealmRepresentation>();
   for (RealmModel realm : realms) {
     reps.add(realmManager.toRepresentation(realm));
   }
   return reps;
 }
예제 #5
0
 public ResourceInvoker getInvoker(HttpRequest request) throws Failure {
   logger.debug("PathInfo: " + request.getUri().getPath());
   if (!request.isInitial()) {
     throw new InternalServerErrorException(
         request.getUri().getPath()
             + " is not initial request.  Its suspended and retried.  Aborting.");
   }
   ResourceInvoker invoker = registry.getResourceInvoker(request);
   if (invoker == null) {
     throw new NotFoundException(
         "Unable to find JAX-RS resource associated with path: " + request.getUri().getPath());
   }
   return invoker;
 }
예제 #6
0
  protected void handleFailure(HttpRequest request, HttpResponse response, Failure failure) {
    if (failure.isLoggable())
      logger.error(
          "Failed executing " + request.getHttpMethod() + " " + request.getUri().getPath(),
          failure);
    else
      logger.debug(
          "Failed executing " + request.getHttpMethod() + " " + request.getUri().getPath(),
          failure);

    if (failure.getResponse() != null) {
      writeFailure(request, response, failure.getResponse());
    } else {
      try {
        if (failure.getMessage() != null) {
          response.sendError(failure.getErrorCode(), failure.getMessage());
        } else {
          response.sendError(failure.getErrorCode());
        }
      } catch (IOException e1) {
        throw new UnhandledException(e1);
      }
    }
  }