Examples of ArtifactCoordinate


Examples of org.sonatype.nexus.rest.model.ArtifactCoordinate

  GAV getArtifactForStorageItem(StorageFileItem item) throws IOException {
    try {
      PomArtifactManager mgr = new PomArtifactManager(
          this.nexusConfig.getTemporaryDirectory());
      mgr.storeTempPomFile(item.getInputStream());
      ArtifactCoordinate ac = mgr.getArtifactCoordinateFromTempPomFile();
      return new GAV(ac.getGroupId(), ac.getArtifactId(), ac.getVersion());
    } catch (Exception e) {
      getLogger().warn(
              "Error processing POM file for artifact usage data.", ExceptionUtils.getRootCause(e));
      return null;
    }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.ArtifactCoordinate

              is = fi.getInputStream();
            }

            try {
              // parse and read GAVs from stored POM, fill in them all into context
              final ArtifactCoordinate coords = pomManager.getArtifactCoordinateFromTempPomFile();
              uploadContext.setGroupId(coords.getGroupId());
              uploadContext.setArtifactId(coords.getArtifactId());
              uploadContext.setVersion(coords.getVersion());
              uploadContext.setPackaging(coords.getPackaging());
            }
            catch (IOException e) {
              getLogger().info("Error occurred while reading the POM file. Malformed POM?", e);
              throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,
                  "Error occurred while reading the POM file. Malformed POM?", e);
            }

            if (isPom) {
              uploadGavParametersAvailable(request, uploadContext);
              gavRequest =
                  getResourceStoreRequest(request, true, false, uploadContext.getRepositoryId(),
                      uploadContext.getGroupId(), uploadContext.getArtifactId(),
                      uploadContext.getVersion(), uploadContext.getPackaging(), null, null);
            }
            else {
              gavRequest =
                  getResourceStoreRequest(request, true, false, uploadContext.getRepositoryId(),
                      uploadContext.getGroupId(), uploadContext.getArtifactId(),
                      uploadContext.getVersion(), uploadContext.getPackaging(),
                      uploadContext.getClassifier(), uploadContext.getExtension());
            }
          }
          else {
            uploadGavParametersAvailable(request, uploadContext);
            is = fi.getInputStream();
            gavRequest =
                getResourceStoreRequest(request, true, false, uploadContext.getRepositoryId(),
                    uploadContext.getGroupId(), uploadContext.getArtifactId(), uploadContext.getVersion(),
                    uploadContext.getPackaging(), uploadContext.getClassifier(),
                    uploadContext.getExtension());
          }

          final MavenRepository mr = gavRequest.getMavenRepository();
          final ArtifactStoreHelper helper = mr.getArtifactStoreHelper();

          // temporarily we disable SNAPSHOT upload
          // check is it a Snapshot repo
          if (RepositoryPolicy.SNAPSHOT.equals(mr.getRepositoryPolicy())) {
            getLogger().info("Upload to SNAPSHOT maven repository {} attempted, returning Bad Request.",
                mr);
            throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,
                "This is a Maven SNAPSHOT repository, and manual upload against it is forbidden!");
          }

          if (!versionMatchesPolicy(gavRequest.getVersion(), mr.getRepositoryPolicy())) {
            getLogger().info("Artifact version {} and {} Repository Policy {} mismatch",
                gavRequest.getVersion(), mr, mr.getRepositoryPolicy());
            throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "The version "
                + gavRequest.getVersion() + " does not match the repository policy!");
          }

          if (isPom) {
            helper.storeArtifactPom(gavRequest, is, null);
            isPom = false;
          }
          else {
            if (uploadContext.isPomAvailable()) {
              helper.storeArtifact(gavRequest, is, null);
            }
            else {
              helper.storeArtifactWithGeneratedPom(gavRequest, uploadContext.getPackaging(), is, null);
            }
          }
        }
      }
    }
    catch (Exception t) {
      return buildUploadFailedHtmlResponse(t, request, response);
    }
    finally {
      if (uploadContext.isPomAvailable()) {
        pomManager.removeTempPomFile();
      }
    }

    final ArtifactCoordinate coords = new ArtifactCoordinate();
    coords.setGroupId(uploadContext.getGroupId());
    coords.setArtifactId(uploadContext.getArtifactId());
    coords.setVersion(uploadContext.getVersion());
    coords.setPackaging(uploadContext.getPackaging());
    return coords;
  }
View Full Code Here

Examples of org.sonatype.nexus.rest.model.ArtifactCoordinate

      }

      eventType = parser.next();
    }

    ArtifactCoordinate artifactCoordinates = new ArtifactCoordinate();

    artifactCoordinates.setGroupId(groupId);

    artifactCoordinates.setArtifactId(artifactId);

    artifactCoordinates.setVersion(version);

    artifactCoordinates.setPackaging(packaging);

    return artifactCoordinates;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.