Package org.sonatype.nexus.proxy.item

Examples of org.sonatype.nexus.proxy.item.DefaultStorageFileItem


    String mdString = outputStream.toString("UTF-8");

    outputStream.close();

    DefaultStorageFileItem file =
        new DefaultStorageFileItem(uid.getRepository(), new ResourceStoreRequest(uid.getPath()), true, true,
            new StringContentLocator(mdString));

    ((MavenRepository) uid.getRepository()).storeItemWithChecksums(false, file);
  }
View Full Code Here


    }
    catch (ItemNotFoundException e) {
      throw new AccessDeniedException(request, e.getMessage());
    }

    DefaultStorageFileItem fItem =
        new DefaultStorageFileItem(this, request, true, true, new PreparedContentLocator(is,
            getMimeSupport().guessMimeTypeFromPath(getMimeRulesSource(), request.getRequestPath()),
            ContentLocator.UNKNOWN_LENGTH));

    if (userAttributes != null) {
      fItem.getRepositoryItemAttributes().putAll(userAttributes);
    }

    storeItem(false, fItem);
  }
View Full Code Here

    try {
      StorageItem item = retrieveItem(fromTask, from);

      if (StorageFileItem.class.isAssignableFrom(item.getClass())) {
        try {
          DefaultStorageFileItem target =
              new DefaultStorageFileItem(this, to, true, true, ((StorageFileItem) item).getContentLocator());

          storeItem(fromTask, target);

          // remove the "to" item from n-cache if there
          removeFromNotFoundCache(to);
View Full Code Here

  public static DefaultStorageFileItem newHashItem(ProxyRepository proxy, ResourceStoreRequest request,
                                                   StorageItem artifact, String hash)
  {
    StringContentLocator content = new StringContentLocator(hash);
    // XXX do we need to clone request here?
    DefaultStorageFileItem hashItem =
        new DefaultStorageFileItem(proxy, request, true /* canRead */, false/* canWrite */, content);
    hashItem.setModified(artifact.getModified());
    return hashItem;
  }
View Full Code Here

              getMimeSupport().guessMimeTypeFromPath(repository.getMimeRulesSource(),
                  request.getRequestPath());
        }

        final long entityLength = httpResponse.getEntity().getContentLength();
        final DefaultStorageFileItem httpItem =
            new DefaultStorageFileItem(repository, request, CAN_READ, CAN_WRITE, new PreparedContentLocator(
                is, mimeType, entityLength != -1 ? entityLength : ContentLocator.UNKNOWN_LENGTH));

        httpItem.setRemoteUrl(remoteURL.toString());
        httpItem.setModified(makeDateFromHeader(httpResponse.getFirstHeader("last-modified")));
        httpItem.setCreated(httpItem.getModified());

        return httpItem;
      }
      catch (IOException ex) {
        release(httpResponse);
View Full Code Here

    ErrorServlet.CONTENT = expectedContent;
    ErrorServlet.clearHeaders();

    // remote request
    ResourceStoreRequest storeRequest = new ResourceStoreRequest("random/file.txt");
    DefaultStorageFileItem item =
        (DefaultStorageFileItem) remoteStorage.retrieveItem(aProxyRepository, storeRequest, server.getServerProvider().getUrl().toExternalForm());

    // result should be HTML
    try (InputStream io = item.getInputStream()) {
      String content = IOUtils.toString(io);
      Assert.assertEquals(expectedContent, content);
    }
  }
View Full Code Here

    ErrorServlet.addHeader(HttpClientRemoteStorage.NEXUS_MISSING_ARTIFACT_HEADER, "true");

    // remote request
    ResourceStoreRequest storeRequest = new ResourceStoreRequest("random/file.txt");
    try {
      DefaultStorageFileItem item =
          (DefaultStorageFileItem) remoteStorage.retrieveItem(aProxyRepository, storeRequest, server.getServerProvider().getUrl().toExternalForm());
      Assert.fail("expected  RemoteStorageException");
    }
    // expect artifact not found
    catch (RemoteStorageException e) {
View Full Code Here

      if (!StringUtils.isEmpty(sha1Hash)) {
        request.setRequestPath(storedFile.getPath() + ".sha1");

        getMavenRepository().storeItem(
            false,
            new DefaultStorageFileItem(getMavenRepository(), request, true, true, new StringContentLocator(
                sha1Hash)));
      }

      if (!StringUtils.isEmpty(md5Hash)) {
        request.setRequestPath(storedFile.getPath() + ".md5");

        getMavenRepository().storeItem(
            false,
            new DefaultStorageFileItem(getMavenRepository(), request, true, true, new StringContentLocator(
                md5Hash)));
      }
    }
    catch (ItemNotFoundException e) {
      throw new LocalStorageException("Storage inconsistency!", e);
View Full Code Here

      if (!StringUtils.isEmpty(sha1Hash)) {
        req.setRequestPath(item.getPath() + ".sha1");

        getMavenRepository().storeItem(
            false,
            new DefaultStorageFileItem(getMavenRepository(), req, true, true, new StringContentLocator(
                sha1Hash)));
      }

      if (!StringUtils.isEmpty(md5Hash)) {
        req.setRequestPath(item.getPath() + ".md5");

        getMavenRepository().storeItem(
            false,
            new DefaultStorageFileItem(getMavenRepository(), req, true, true, new StringContentLocator(
                md5Hash)));
      }
    }
    catch (ItemNotFoundException e) {
      throw new LocalStorageException("Storage inconsistency!", e);
View Full Code Here

  {
    final ResourceStoreRequest request = new ResourceStoreRequest(getFilePath());
    request.setRequestLocalOnly(true);
    request.setRequestGroupLocalOnly(true);
    request.getRequestContext().put(Manager.ROUTING_INITIATED_FILE_OPERATION_FLAG_KEY, Boolean.TRUE);
    final DefaultStorageFileItem file =
        new DefaultStorageFileItem(getMavenRepository(), request, true, true, content);
    try {
      // NXCM-5188: Remark to not get tempted to change these to storeItemWithChecksums() method:
      // Since NEXUS-5418 was fixed (in 2.4), Nexus serves up ALL request for existing items that
      // has extra trailing ".sha1" or ".md5" from item attributes. This means, that when prefix file
      // is published in Nexus, there is no need anymore to save checksums to disk, as they will
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.item.DefaultStorageFileItem

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.