Package org.sonatype.nexus.proxy

Examples of org.sonatype.nexus.proxy.LocalStorageException


            result.add(file);
          }
        }
      }
      else {
        throw new LocalStorageException("Cannot list directory in repository " + repository + ", path "
            + target.getAbsolutePath());
      }
      return result;
    }
    else if (target.isFile()) {
View Full Code Here


      // NEXUS-4955 add APPENDIX to make sure prefix is bigger the 3 chars
      return File.createTempFile(target.getName() + APPENDIX, HIDDEN_TARGET_SUFFIX, repoTmpFolder);
    }
    catch (IOException e) {
      throw new LocalStorageException(e.getMessage(), e);
    }
  }
View Full Code Here

  {
    try {
      DirSupport.mkdir(target.toPath());
    }
    catch (IOException e) {
      throw new LocalStorageException(String.format(
          "Could not create the directory hierarchy in repository %s to write \"%s\"",
          RepositoryStringUtils.getHumanizedNameString(repository), target.getAbsolutePath()), e);
    }
  }
View Full Code Here

    itemUid.getLock().lock(Action.read);
    try {
      final Attributes attributes = artifact.getRepositoryItemAttributes();

      if (attributes == null) {
        throw new LocalStorageException("Null item repository attributes");
      }

      if (Boolean.parseBoolean(attributes.get(noattrname)) && !request.isRequestAsExpired()) {
        throw new ItemNotFoundException(request);
      }

      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
        }
        catch (RemoteAccessException e) {
          // fall through
        }
        catch (RemoteStorageException e) {
          // this is (potentially) transient network or remote server problem will be cached
          // there is no automatic retry for this hash time
          // either expire the artifact or request the hash asExpired to retry
        }

        doStoreChechsumItem(proxy, artifact, attrname, noattrname, hash);
      }

      if (hash != null) {
        return new RemoteHashResponse(inspector, hash, newHashItem(proxy, request, artifact, hash));
      }
      else {
        throw new ItemNotFoundException(request);
      }
    }
    catch (IOException e) {
      throw new LocalStorageException(e);
    }
    finally {
      itemUid.getLock().unlock();
    }
  }
View Full Code Here

    try {
      doStoreChechsumItem(proxy, artifact, ATTR_REMOTE_SHA1, ATTR_NO_REMOTE_SHA1,
          MUtils.readDigestFromFileItem(hash));
    }
    catch (IOException e) {
      throw new LocalStorageException(e);
    }
  }
View Full Code Here

    try {
      doStoreChechsumItem(proxy, artifact, ATTR_REMOTE_MD5, ATTR_NO_REMOTE_MD5,
          MUtils.readDigestFromFileItem(hash));
    }
    catch (IOException e) {
      throw new LocalStorageException(e);
    }
  }
View Full Code Here

    try {
      try {
        getMavenRepository().storeItem(request, is, userAttributes);
      }
      catch (IOException e) {
        throw new LocalStorageException(String.format("Could not store item to repository %s, path %s",
            RepositoryStringUtils.getHumanizedNameString(getMavenRepository()), request), e);
      }

      // NXCM-4861: Doing "local only" lookup, same code should be used as in
      // org.sonatype.nexus.proxy.repository.AbstractProxyRepository#doCacheItem
      // Note: ResourceStoreRequest( ResourceStoreRequest ) creates a "subordinate" request from passed with same
      // path but localOnly=true
      StorageFileItem storedFile =
          (StorageFileItem) getMavenRepository().retrieveItem(false, new ResourceStoreRequest(request));

      String sha1Hash = storedFile.getRepositoryItemAttributes().get(DigestCalculatingInspector.DIGEST_SHA1_KEY);

      String md5Hash = storedFile.getRepositoryItemAttributes().get(DigestCalculatingInspector.DIGEST_MD5_KEY);

      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);
    }
    finally {
      request.setRequestPath(originalPath);
    }
  }
View Full Code Here

    try {
      try {
        getMavenRepository().storeItem(false, item);
      }
      catch (IOException e) {
        throw new LocalStorageException("Could not get the content from the ContentLocator!", e);
      }

      StorageFileItem storedFile =
          (StorageFileItem) getMavenRepository().retrieveItem(false, new ResourceStoreRequest(item));

      ResourceStoreRequest req = new ResourceStoreRequest(storedFile);

      String sha1Hash = storedFile.getRepositoryItemAttributes().get(DigestCalculatingInspector.DIGEST_SHA1_KEY);

      String md5Hash = storedFile.getRepositoryItemAttributes().get(DigestCalculatingInspector.DIGEST_MD5_KEY);

      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

      }

      return gav;
    }
    catch (IOException e) {
      throw new LocalStorageException("Could not maintain metadata!", e);
    }
  }
View Full Code Here

    if (StorageFileItem.class.isAssignableFrom(item.getClass())) {
      return (StorageFileItem) item;
    }
    else {
      throw new LocalStorageException("The Artifact retrieval returned non-file, path:"
          + item.getRepositoryItemUid().toString());
    }
  }
View Full Code Here

TOP

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

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.