Package org.sonatype.nexus.proxy

Examples of org.sonatype.nexus.proxy.ResourceStoreRequest


          // to check that, we will check is remote is Nexus by pinging "well know" location
          // if we got it, we will know it's only browsing forbidden on remote
          final RemoteStorageContext ctx = getRemoteStorageContext(repository);
          final HttpClient httpClient = (HttpClient) ctx.getContextObject(CTX_KEY_CLIENT);
          final PageContext pageContext = new RepositoryPageContext(httpClient, repository);
          final ResourceStoreRequest rmRequest = new ResourceStoreRequest("/.meta/repository-metadata.xml");
          final URL nxRepoMetadataUrl = appendQueryString(
              repository, rmRequest,
              getAbsoluteUrlFromBase(repository, rmRequest));
          try {
            final Page page = Page.getPageFor(pageContext, nxRepoMetadataUrl.toExternalForm());
View Full Code Here


  @Override
  public void doDelete(WalkerContext ctx, StorageFileItem item)
      throws StorageException, UnsupportedStorageOperationException, IllegalOperationException, ItemNotFoundException
  {
    final MavenRepository repository = (MavenRepository) getRepository(ctx);
    final ResourceStoreRequest rsr = new ResourceStoreRequest(item);
    rsr.getRequestContext().put(DeleteOperation.DELETE_OPERATION_CTX_KEY,DeleteOperation.DELETE_PERMANENTLY);
    repository.deleteItemWithChecksums(false, rsr);
  }
View Full Code Here

  @Override
  public void onCollectionExit(WalkerContext ctx, StorageCollectionItem coll) {
    // expiring now empty directories
    try {
      if (getRepository(ctx).list(false, coll).size() == 0) {
        final ResourceStoreRequest rsr = new ResourceStoreRequest(coll);
        rsr.getRequestContext().put(DeleteOperation.DELETE_OPERATION_CTX_KEY,DeleteOperation.DELETE_PERMANENTLY);
        ((MavenRepository) getRepository(ctx)).deleteItemWithChecksums(false, rsr);
      }
    }
    catch (UnsupportedStorageOperationException e) {
      // if op not supported (R/O repo?)
View Full Code Here

  // ==

  protected StorageFileItem retrieveFromRemoteIfExists(final MavenProxyRepository mavenProxyRepository,
      final String path) throws IOException
  {
    final ResourceStoreRequest request = new ResourceStoreRequest(path);
    request.setRequestRemoteOnly(true);
    request.getRequestContext().put(Manager.ROUTING_INITIATED_FILE_OPERATION_FLAG_KEY, Boolean.TRUE);
    // NXCM-5188: Disable checksum policy for prefix file request, it will be processed and checked anyway
    request.getRequestContext().put(ChecksumPolicy.REQUEST_CHECKSUM_POLICY_KEY, ChecksumPolicy.IGNORE);

    // check for remote presence, as fetching with setRequestRemoteOnly has a side effect of
    // DELETING the file from local cache if not present remotely. In this case, prefix
    // file (on default location) obviously originates from scrape, so we should not delete it.
    final boolean presentRemotely = mavenProxyRepository.getRemoteStorage().containsItem(mavenProxyRepository, request);
View Full Code Here

      // 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);
View Full Code Here

      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)));
View Full Code Here

          RepositoryStatusCheckMode repositoryStatusCheckMode =
              getRepository().getRepositoryStatusCheckMode();

          if (RepositoryStatusCheckMode.ALWAYS.equals(repositoryStatusCheckMode)) {
            // just do it, don't care for proxyMode
            getRepository().getRemoteStatus(new ResourceStoreRequest(RepositoryItemUid.PATH_ROOT), true);
          }
          else if (RepositoryStatusCheckMode.AUTO_BLOCKED_ONLY.equals(repositoryStatusCheckMode)) {
            // do it only if proxyMode , don't care for proxyMode
            ProxyMode repositoryProxyMode = getRepository().getProxyMode();

            if (repositoryProxyMode.shouldAutoUnblock()) {
              getRepository().getRemoteStatus(new ResourceStoreRequest(RepositoryItemUid.PATH_ROOT),
                  true);
            }
          }
          else if (RepositoryStatusCheckMode.NEVER.equals(repositoryStatusCheckMode)) {
            // nothing
View Full Code Here

  protected StorageFileItem getFileItem()
      throws IOException
  {
    try {
      final ResourceStoreRequest request = new ResourceStoreRequest(getFilePath());
      request.setRequestLocalOnly(true);
      request.setRequestGroupLocalOnly(true);
      request.getRequestContext().put(Manager.ROUTING_INITIATED_FILE_OPERATION_FLAG_KEY, Boolean.TRUE);
      @SuppressWarnings("deprecation")
      final StorageItem item = getMavenRepository().retrieveItem(true, request);
      if (item instanceof StorageFileItem) {
        return (StorageFileItem) item;
      }
View Full Code Here

  }

  protected void putFileItem(final ContentLocator content)
      throws IOException
  {
    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
View Full Code Here

  @SuppressWarnings("deprecation")
  protected void deleteFileItem()
      throws IOException
  {
    final ResourceStoreRequest request = new ResourceStoreRequest(getFilePath());
    request.setRequestLocalOnly(true);
    request.setRequestGroupLocalOnly(true);
    request.getRequestContext().put(Manager.ROUTING_INITIATED_FILE_OPERATION_FLAG_KEY, Boolean.TRUE);
    try {
      // NXCM-5188: Remark to not get tempted to change these to deleteItemWithChecksums() 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.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.