Package org.sonatype.nexus.proxy

Examples of org.sonatype.nexus.proxy.ResourceStoreRequest


      throws ResourceException
  {

    try {
      final ResourceStore store = getResourceStore(request);
      final ResourceStoreRequest req = getResourceStoreRequest(request);

      try {
        StorageItem item = store.retrieveItem(req);

        return renderItem(context, request, response, variant, store, item);
View Full Code Here


            + "\" is not acceptable for uploads!");
      }
    }

    try {
      final ResourceStoreRequest req = getResourceStoreRequest(request);

      for (FileItem fileItem : files) {
        getResourceStore(request).storeItem(req, fileItem.getInputStream(), null);
      }
    }
View Full Code Here

  public void delete(Context context, Request request, Response response)
      throws ResourceException
  {
    try {
      final ResourceStore store = getResourceStore(request);
      final ResourceStoreRequest req = getResourceStoreRequest(request);

      store.deleteItem(req);

      getLogger().info(
          "Storage item(s) on path \"" + req.getRequestPath() + "\" (and below) were deleted from repository ["
              + request.getAttributes().get(AbstractRepositoryPlexusResource.REPOSITORY_ID_KEY) + "]");
    }
    catch (Exception e) {
      handleException(request, response, e);
    }
View Full Code Here

   * Centralized way to create ResourceStoreRequests, since we have to fill in various things in Request context,
   * like
   * authenticated username, etc.
   */
  protected ResourceStoreRequest getResourceStoreRequest(Request request, String resourceStorePath) {
    ResourceStoreRequest result = new ResourceStoreRequest(resourceStorePath);

    getLogger().trace("Created ResourceStore request for {}", result.getRequestPath());

    // honor the local only and remote only
    result.setRequestLocalOnly(isLocal(request, resourceStorePath));
    result.setRequestRemoteOnly(isRemote(request, resourceStorePath));
    result.setRequestAsExpired(asExpired(request, resourceStorePath));
    result.setExternal(true);

    // honor the describe, add timing
    if (isDescribe(request)) {
      result.getRequestContext().put(REQUEST_RECEIVED_KEY, System.currentTimeMillis());
    }

    // honor if-modified-since
    if (request.getConditions().getModifiedSince() != null) {
      result.setIfModifiedSince(request.getConditions().getModifiedSince().getTime());
    }

    // honor if-none-match
    if (request.getConditions().getNoneMatch() != null && request.getConditions().getNoneMatch().size() > 0) {
      final Tag tag = request.getConditions().getNoneMatch().get(0);
      // NEXUS-5704: 500 Internal Server Error when "If-None-Match" in header
      // Restlet 1.1 is very strict about properly formatted ETags (must be quoted)
      // If unquoted, their presence is detected (IF above evals to true), but will
      // actually return null as parsing the tag
      if (tag != null && tag.getName() != null) {
        result.setIfNoneMatch(tag.getName());
      }
    }

    // stuff in the originating remote address
    result.getRequestContext().put(AccessManager.REQUEST_REMOTE_ADDRESS, getValidRemoteIPAddress(request));

    // stuff in the user id if we have it in request
    Subject subject = securitySystem.getSubject();
    if (subject != null && subject.getPrincipal() != null) {
      result.getRequestContext().put(AccessManager.REQUEST_USER, subject.getPrincipal().toString());
    }
    result.getRequestContext().put(AccessManager.REQUEST_AGENT, request.getClientInfo().getAgent());

    // this is HTTPS, get the cert and stuff it too for later
    if (request.isConfidential()) {
      result.getRequestContext().put(AccessManager.REQUEST_CONFIDENTIAL, Boolean.TRUE);

      List<?> certs = (List<?>) request.getAttributes().get("org.restlet.https.clientCertificates");

      if (certs != null) {
        result.getRequestContext().put(AccessManager.REQUEST_CERTIFICATES, certs);
      }
    }

    // put the incoming URLs
    result.setRequestUrl(request.getOriginalRef().toString());

    return result;
  }
View Full Code Here

    lookup(ArtifactPackagingMapper.class).setPropertiesFile(
        getTestFile("src/test/resources/nexus-5525/packaging2extension-mapping.properties"));

    // simulate Maven3 deploy: it happens JAR then POM
    snapshots.storeItem(
        new ResourceStoreRequest("/org/sonatype/nexus5525/bundle/1.0-SNAPSHOT/" + jarFile.getName()),
        new FileInputStream(jarFile), null);
    snapshots.storeItem(
        new ResourceStoreRequest("/org/sonatype/nexus5525/bundle/1.0-SNAPSHOT/" + pomFile.getName()),
        new FileInputStream(pomFile), null);

    wairForAsyncEventsToCalmDown();

    IteratorSearchResponse response = null;
View Full Code Here

   * event about this and having ourselves manage the indexing to be able to control it.
   */
  protected void sneakyDeployAFile(String path, File file)
      throws Exception
  {
    ResourceStoreRequest request = new ResourceStoreRequest(path);

    FileContentLocator fc = new FileContentLocator(file, mimeSupport.guessMimeTypeFromPath(file.getName()));

    StorageFileItem item = new DefaultStorageFileItem(snapshots, request, true, true, fc);

View Full Code Here

  {
    StringBuilder path = new StringBuilder();
    path.append("/org/").append(key);
    path.append('/').append(version);
    path.append('/').append(key).append('-').append(version).append(".jar");
    final ResourceStoreRequest request = new ResourceStoreRequest(path.toString());
    releases.storeItem(request, new ByteArrayInputStream("Junk JAR".getBytes()), null);
  }
View Full Code Here

      // already found the artifact on this repo
      if (repositories.contains(repo.getId())) {
        continue;
      }

      final ResourceStoreRequest repoRequest =
          new ResourceStoreRequest(itemUid.getPath(), request.isRequestLocalOnly(),
              request.isRequestRemoteOnly());
      if (repo.getLocalStorage().containsItem(repo, repoRequest)) {
        try {
          StorageItem repoItem = repo.retrieveItem(repoRequest);
          if (checksum == null
View Full Code Here

      throws Exception
  {
    // check uniqueness
    ensureUniqueness();
    // simulate Maven deploy, get something stored
    releases.storeItem(new ResourceStoreRequest(POM_PATH),
        new FileInputStream(new File(fakeCentral, POM_PATH.substring(1))), null);
    releases.storeItem(new ResourceStoreRequest(JAR_PATH),
        new FileInputStream(new File(fakeCentral, JAR_PATH.substring(1))), null);
    waitForAsync(); // indexing happens async
    // check uniqueness
    ensureUniqueness();
    // update indexes, that will trigger buggy scan of local storage
View Full Code Here

      throws Exception
  {
    // check uniqueness
    ensureUniqueness();
    // simulate Maven deploy, get something stored
    releases.storeItem(new ResourceStoreRequest(POM_PATH),
        new FileInputStream(new File(fakeCentral, POM_PATH.substring(1))), null);
    releases.storeItem(new ResourceStoreRequest(JAR_PATH),
        new FileInputStream(new File(fakeCentral, JAR_PATH.substring(1))), null);
    waitForAsync(); // indexing happens async
    // check uniqueness
    ensureUniqueness();
    // update indexes, that will trigger buggy scan of local storage
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.ResourceStoreRequest

Copyright © 2018 www.massapicom. 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.