Package org.sonatype.nexus.proxy.item

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


    extends AbstractStorageItemInspector
{
  @Override
  public boolean isHandled(final StorageItem item) {
    if (item instanceof StorageFileItem) {
      final StorageFileItem fitem = (StorageFileItem) item;
      addIfExistsButDontContains(fitem, AccessManager.REQUEST_USER);
      addIfExistsButDontContains(fitem, AccessManager.REQUEST_REMOTE_ADDRESS);
      addIfExistsButDontContains(fitem, AccessManager.REQUEST_CONFIDENTIAL);
    }
    // don't do File copy for us, we done our job already
View Full Code Here


      item.setExpired(false);

      ContentLocator cl = null;

      if (item instanceof StorageFileItem) {
        StorageFileItem fItem = (StorageFileItem) item;

        prepareStorageFileItemForStore(fItem);

        cl = fItem.getContentLocator();
      }
      else if (item instanceof StorageLinkItem) {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();

        try {
View Full Code Here

      String pomPath = gavCalculator.gavToPath(pomGav);

      request.setRequestPath(pomPath);

      StorageFileItem pomFile = (StorageFileItem) request.getMavenRepository().retrieveItem(false, request);

      try (final Reader reader = ReaderFactory.newXmlReader(pomFile.getInputStream())) {
        packaging = getPackaging(reader);
      }
    }
    catch (ItemNotFoundException e) {
      return null;
View Full Code Here

      String pomPath = request.getMavenRepository().getGavCalculator().gavToPath(gav);

      request.setRequestPath(pomPath);

      StorageFileItem pomFile = (StorageFileItem) request.getMavenRepository().retrieveItem(false, request);

      try (final InputStream is = pomFile.getInputStream()) {
        MavenXpp3Reader rd = new MavenXpp3Reader();
        return rd.read(is);
      }
      catch (XmlPullParserException e) {
        throw createIOExceptionWithCause(e.getMessage(), e);
View Full Code Here

      request.setRequestPath(uid.getPath());

      StorageItem item = uid.getRepository().retrieveItem(false, request);

      if (StorageFileItem.class.isAssignableFrom(item.getClass())) {
        StorageFileItem fileItem = (StorageFileItem) item;

        try (final InputStream is = fileItem.getInputStream()) {
          result = MetadataBuilder.read(is);
        }
      }
      else {
        throw new IllegalArgumentException("The UID " + uid.toString() + " is not a file!");
View Full Code Here

      }

      String hash = attributes.get(attrname);
      if (hash == null || request.isRequestAsExpired()) {
        try {
          final StorageFileItem remoteItem =
              (StorageFileItem) proxy.getRemoteStorage().retrieveItem(proxy, request, proxy.getRemoteUrl());
          hash = MUtils.readDigestFromFileItem(remoteItem); // closes http input stream
        }
        catch (ItemNotFoundException e) {
          // fall through
View Full Code Here

  protected void checkForFileAndMatchContents(StorageItem item, StorageFileItem expected)
      throws Exception
  {
    assertStorageFileItem(item);

    StorageFileItem fileItem = (StorageFileItem) item;

    assertTrue("content equals", contentEquals(fileItem.getInputStream(), expected.getInputStream()));
  }
View Full Code Here

  protected void checkForFileAndMatchContents(StorageItem item, File expected)
      throws Exception
  {
    assertStorageFileItem(item);

    StorageFileItem fileItem = (StorageFileItem) item;

    assertTrue("content equals", contentEquals(fileItem.getInputStream(), new FileInputStream(expected)));
  }
View Full Code Here

    assertFalse(item.isVirtual());

    // have UID
    assertTrue(item.getRepositoryItemUid() != null);

    StorageFileItem file = (StorageFileItem) item;

    // is reusable
    assertTrue(file.isReusableStream());
  }
View Full Code Here

      throws UnsupportedStorageOperationException, RemoteStorageException
  {
    if (!(item instanceof StorageFileItem)) {
      throw new UnsupportedStorageOperationException("Storing of non-files remotely is not supported!");
    }
    final StorageFileItem fileItem = (StorageFileItem) item;

    final ResourceStoreRequest request = new ResourceStoreRequest(item);

    try {
      validatePath(repository, request);
    }
    catch (ItemNotFoundException e) {
      throw new RemoteStorageException("Invalid path to store", e);
    }

    final URL remoteUrl = appendQueryString(repository, request, getAbsoluteUrlFromBase(repository, request));

    final HttpPut method = new HttpPut(remoteUrl.toExternalForm());

    final InputStreamEntity entity;
    try {
      entity =
          new InputStreamEntity(new InterruptableInputStream(fileItem.getInputStream()), fileItem.getLength());
    }
    catch (IOException e) {
      throw new RemoteStorageException(e.getMessage() + " [repositoryId=\"" + repository.getId()
          + "\", requestPath=\"" + request.getRequestPath() + "\", remoteUrl=\"" + remoteUrl.toString() + "\"]",
          e);
    }

    entity.setContentType(fileItem.getMimeType());
    method.setEntity(entity);

    final HttpResponse httpResponse = executeRequestAndRelease(repository, request, method, repository.getRemoteUrl());
    final int statusCode = httpResponse.getStatusLine().getStatusCode();
View Full Code Here

TOP

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

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.