Exemple #1
0
 /**
  * Returns true if the workflow JAR is deployed to the s-ramp repository.
  *
  * @param groupId
  * @param artifactId
  * @param version
  * @return true or false
  */
 public boolean isSRAMPPackageDeployed(String groupId, String artifactId, String version) {
   try {
     SrampAtomApiClient client = SrampAtomApiClientFactory.createAtomApiClient();
     QueryResultSet results =
         client
             .buildQuery(SRAMP_KIE_JAR_QUERY)
             .parameter(groupId)
             .parameter(artifactId)
             .parameter(version)
             .count(1)
             .query();
     if (results.size() > 0) {
       return Boolean.TRUE;
     }
   } catch (SrampClientException e) {
     logger.error(e.getMessage(), e);
   } catch (SrampAtomException e) {
     logger.error(e.getMessage(), e);
   }
   return Boolean.FALSE;
 }
Exemple #2
0
  /**
   * * Gets the artifact content from the s-ramp repository and stores it in the {@link InputData}
   * object for use by Maven.
   *
   * @param gavInfo
   * @param inputData
   * @throws TransferFailedException
   * @throws ResourceDoesNotExistException
   * @throws AuthorizationException
   */
  private void doGetArtifact(MavenGavInfo gavInfo, InputData inputData)
      throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException {
    // RESTEasy uses the current thread's context classloader to load its logger class.  This
    // fails in Maven because the context classloader is the wagon plugin's classloader, which
    // doesn't know about any of the RESTEasy JARs.  So here we're temporarily setting the
    // context classloader to the s-ramp wagon extension's classloader, which should have access
    // to all the right stuff.
    ClassLoader oldCtxCL = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(SrampWagon.class.getClassLoader());
    try {
      // Query the artifact meta data using GAV info
      BaseArtifactType artifact = findExistingArtifact(client, gavInfo);
      if (artifact == null)
        throw new ResourceDoesNotExistException(
            Messages.i18n.format("ARTIFACT_NOT_FOUND", gavInfo.getName())); // $NON-NLS-1$
      this.archive.addEntry(gavInfo.getFullName(), artifact, null);
      ArtifactType type = ArtifactType.valueOf(artifact);

      // Get the artifact content as an input stream
      InputStream artifactContent = client.getArtifactContent(type, artifact.getUuid());
      inputData.setInputStream(artifactContent);
    } catch (ResourceDoesNotExistException e) {
      throw e;
    } catch (SrampClientException e) {
      if (e.getCause() instanceof HttpHostConnectException) {
        this.debug(Messages.i18n.format("SRAMP_CONNECTION_FAILED", e.getMessage())); // $NON-NLS-1$
      } else {
        this.error(e.getMessage(), e);
      }
      throw new ResourceDoesNotExistException(
          Messages.i18n.format(
              "FAILED_TO_GET_RESOURCE_FROM_SRAMP", gavInfo.getName())); // $NON-NLS-1$
    } catch (Throwable t) {
      this.error(t.getMessage(), t);
    } finally {
      Thread.currentThread().setContextClassLoader(oldCtxCL);
    }
  }