Examples of AbstractStorageItem


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

      throws MalformedURLException, RemoteAccessException, RemoteStorageException, ItemNotFoundException
  {
    final URL url = new URL(mirrorsURL);
    final ResourceStoreRequest request = new ResourceStoreRequest(url.getFile());
    final String baseUrl = getBaseMirrorsURL(url);
    final AbstractStorageItem mirrorsItem = getRemoteStorage().retrieveItem(this, request, baseUrl);
    if (mirrorsItem instanceof StorageFileItem) {
      return (StorageFileItem) mirrorsItem;
    }
    throw new ItemNotFoundException(
        ItemNotFoundException.reasonFor(request, this, "URL %s does not contain valid mirrors", mirrorsURL));
View Full Code Here

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

    try {
      repoLock.lock(Action.read);
      if (P2Constants.CONTENT_XML.equals(request.getRequestPath())
          || P2Constants.CONTENT_JAR.equals(request.getRequestPath())) {
        try {
          final AbstractStorageItem contentItem = doRetrieveLocalItem(request, repository);
          if (request.isRequestLocalOnly() || !isContentOld(contentItem, repository)) {
            return contentItem;
          }
        }
        catch (final ItemNotFoundException e) {
          // fall through
        }

        // give away the lock on content.xml as we will regenerate it
        itemLock.unlock();
        try {
          // we need to get new file, so update the lock
          repoLock.lock(Action.delete);
          // recheck the condition now that we have an exclusive lock
          try {
            final AbstractStorageItem contentItem = doRetrieveLocalItem(request, repository);
            if (!isContentOld(contentItem, repository)) {
              return contentItem;
            }
          }
          catch (final ItemNotFoundException e) {
            // fall through
          }

          try {
            final StorageItem result = doRetrieveContentItems(request.getRequestContext(), repository).get(
                request.getRequestPath()
            );
            doRetrieveArtifactsItems(request.getRequestContext(), repository);
            return result;
          }
          catch (final P2RuntimeExceptionMaskedAsINFException e) {
            return doRetrieveLocalOnTransferError(request, repository, e);
          }
        }
        finally {
          // release repo
          repoLock.unlock();
          // get back the lock we gave in
          itemLock.lock(Action.read);
        }
      }
      else if (P2Constants.ARTIFACTS_XML.equals(request.getRequestPath())
          || P2Constants.ARTIFACTS_JAR.equals(request.getRequestPath())) {
        try {
          final AbstractStorageItem artifactsItem = doRetrieveLocalItem(request, repository);
          if (request.isRequestLocalOnly() || !isArtifactsOld(artifactsItem, repository)) {
            return artifactsItem;
          }
        }
        catch (final ItemNotFoundException e) {
          // fall through
        }

        // give away the lock on artifacts.xml as we will regenerate it
        itemLock.unlock();
        try {
          // we need to get new file, so update the lock
          repoLock.lock(Action.delete);
          // recheck the condition now that we have an exclusive lock
          try {
            final AbstractStorageItem artifactsItem = doRetrieveLocalItem(request, repository);
            if (!isArtifactsOld(artifactsItem, repository)) {
              return artifactsItem;
            }
          }
          catch (final ItemNotFoundException e) {
View Full Code Here

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

  protected AbstractStorageItem doRetrieveLocalItem(final ResourceStoreRequest request, final E repository)
      throws LocalStorageException, ItemNotFoundException
  {
    if (repository.getLocalStorage() != null) {
      final AbstractStorageItem localItem = repository.getLocalStorage().retrieveItem(repository, request);
      return localItem;
    }
    throw new ItemNotFoundException(request, repository);
  }
View Full Code Here

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

  private void mirrorRelativeItem(final ResourceStoreRequest remoteRequest, final ResourceStoreRequest localRequest,
                                  final Set<String> mirrored)
      throws StorageException, IllegalOperationException, ItemNotFoundException
  {
    final AbstractStorageItem item = (AbstractStorageItem) retrieveItem(true, remoteRequest);

    // cerating update sites may not name there jars as we expect,
    // if thats the case, download as they request, but store in local storage normalized, this
    // of course means updating the mirrored list so the file isn't deleted upon completion of mirror process
    if (localRequest != null) {
      if (!mirrored.contains(localRequest.getRequestPath())) {
        mirrored.remove(remoteRequest.getRequestPath());
        mirrored.add(localRequest.getRequestPath());
      }

      // update the uid
      final RepositoryItemUid newUid = createUid(localRequest.getRequestPath());
      if (!newUid.equals(item.getRepositoryItemUid())) {
        item.setRepositoryItemUid(newUid);

        // update the resource store request
        item.setResourceStoreRequest(localRequest);

        // cache locally
        doCacheItem(item);
      }
    }
View Full Code Here

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

                                  final String basePath, ResourceStoreRequest localStoreRequest,
                                  final Set<String> mirrored)
      throws RemoteAccessException, StorageException, ItemNotFoundException
  {
    // chop off the baseDir from the request, as we only care about the file in this case
    final AbstractStorageItem item;
    remoteStoreRequest.pushRequestPath(remoteStoreRequest.getRequestPath().substring(basePath.length()));
    try {
      // we need to chop it up here to remove filename from url, as that is in request
      item = getRemoteStorage().retrieveItem(this, remoteStoreRequest, absoluteUrl);
    }
    finally {
      // now put the basePath back on
      remoteStoreRequest.popRequestPath();
    }

    if (localStoreRequest == null) {
      localStoreRequest = remoteStoreRequest;
    }
    else {
      // update the list of what we have mirrored, since we have changed filename
      if (!mirrored.contains(localStoreRequest.getRequestPath())) {
        mirrored.remove(remoteStoreRequest.getRequestPath());
        mirrored.add(localStoreRequest.getRequestPath());
      }

      // update the uid
      final RepositoryItemUid newUid = createUid(localStoreRequest.getRequestPath());
      if (!newUid.equals(item.getRepositoryItemUid())) {
        item.setRepositoryItemUid(newUid);

        // update the resource store request
        item.setResourceStoreRequest(localStoreRequest);

        // cache locally
        doCacheItem(item);
      }
    }
View Full Code Here

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

   */
  protected boolean isItemValid(final String path)
      throws StorageException
  {
    try {
      final AbstractStorageItem item = getLocalStorage().retrieveItem(this, new ResourceStoreRequest(path));

      return !isOld(item);
    }
    catch (final ItemNotFoundException e) {
      return false;
View Full Code Here

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

    repo1.retrieveItem(new ResourceStoreRequest("/org/slf4j/slf4j-api/1.4.3/slf4j-api-1.4.3.pom", false));

    repo1.retrieveItem(new ResourceStoreRequest("/rome/rome/0.9/rome-0.9.pom", false));

    // now mangle the attributes of one of them
    AbstractStorageItem mangledItem = repo1.getLocalStorage().retrieveItem(
        repo1,
        new ResourceStoreRequest("/activemq/activemq-core/1.2/activemq-core-1.2.jar", true));

    // make it last requested before 3 days
    mangledItem.setLastRequested(System.currentTimeMillis() - (3 * DAY));

    // store the change
    repo1.getAttributesHandler().storeAttributes(mangledItem);

    // and evict all that are not "used" for 2 days
View Full Code Here

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

      final ResourceStoreRequest metadataRequest = new ResourceStoreRequest(getObrPath());

      return refreshObr(getRemoteStorage().retrieveItem(this, metadataRequest, getRemoteUrl()));
    }
    else if (request.getRequestPath().startsWith(CacheableResource.BUNDLES_PATH)) {
      final AbstractStorageItem cachedItem = doCacheBundle(request);

      if (null != cachedItem) {
        return cachedItem;
      }
    }
View Full Code Here

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

        // then updating the ResourceStoreRequest to use only the filename for relativePath
        final String baseUrl = url.substring(0, url.lastIndexOf("/"));
        final String fileName = url.substring(url.lastIndexOf("/"));

        request.pushRequestPath(fileName);
        final AbstractStorageItem item;
        try {
          item = getRemoteStorage().retrieveItem(this, request, baseUrl);
        }
        finally {
          request.popRequestPath();
        }
        // since NEXUS-5511, the line above does not modify the request carried by item!
        // Those two are detached
        item.getResourceStoreRequest().setRequestPath(request.getRequestPath());

        // update the repositoryItemUid, as it will contain the request path with only the filename
        item.setRepositoryItemUid(createUid(request.getRequestPath()));

        return doCacheItem(item);
      }

      return null; // not found, this might be a real path in the original OBR
View Full Code Here

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

      throws UnsupportedStorageOperationException, IllegalOperationException, StorageException
  {
    // strip the '.' from the path
    if (AbstractStorageItem.class.isAssignableFrom(item.getClass())) {
      String normalizedPath = normalize(item.getPath());
      AbstractStorageItem fileItem = (AbstractStorageItem) item;
      fileItem.setPath(normalizedPath);
    }

    super.storeItem(fromTask, item);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.