Package org.sonatype.nexus.proxy.item

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


  }

  public void moveItem(Repository repository, ResourceStoreRequest from, ResourceStoreRequest to)
      throws ItemNotFoundException, UnsupportedStorageOperationException, LocalStorageException
  {
    RepositoryItemUid fromUid = repository.createUid(from.getRequestPath());

    try {
      Attributes fromAttr = repository.getAttributesHandler().getAttributeStorage().getAttributes(fromUid);

      // check does it have attrs at all
      if (fromAttr != null) {
        RepositoryItemUid toUid = repository.createUid(to.getRequestPath());
        fromAttr.setRepositoryId(toUid.getRepository().getId());
        fromAttr.setPath(toUid.getPath());
        repository.getAttributesHandler().getAttributeStorage().putAttributes(toUid, fromAttr);
      }

      File fromTarget = getFileFromBase(repository, from);
View Full Code Here


    String mdPath = request.getRequestPath();

    // GAV
    mdPath = mdPath.substring(0, mdPath.lastIndexOf(RepositoryItemUid.PATH_SEPARATOR)) + "/maven-metadata.xml";

    RepositoryItemUid uid = request.getMavenRepository().createUid(mdPath);

    Metadata result = readOrCreateMetadata(uid, request);

    result.setGroupId(gav.getGroupId());
View Full Code Here

    mdPath = mdPath.substring(0, mdPath.lastIndexOf(RepositoryItemUid.PATH_SEPARATOR));

    // GA
    mdPath = mdPath.substring(0, mdPath.lastIndexOf(RepositoryItemUid.PATH_SEPARATOR)) + "/maven-metadata.xml";

    RepositoryItemUid uid = request.getMavenRepository().createUid(mdPath);

    Metadata result = readOrCreateMetadata(uid, request);

    result.setGroupId(gav.getGroupId());
View Full Code Here

    mdPath = mdPath.substring(0, mdPath.lastIndexOf(RepositoryItemUid.PATH_SEPARATOR));

    // G
    mdPath = mdPath.substring(0, mdPath.lastIndexOf(RepositoryItemUid.PATH_SEPARATOR)) + "/maven-metadata.xml";

    RepositoryItemUid uid = request.getMavenRepository().createUid(mdPath);

    Metadata result = readOrCreateMetadata(uid, request);

    result.setGroupId(null);
View Full Code Here

    String mdPath = request.getRequestPath();

    // GAV
    mdPath = mdPath.substring(0, mdPath.lastIndexOf(RepositoryItemUid.PATH_SEPARATOR)) + "/maven-metadata.xml";

    RepositoryItemUid uid = request.getMavenRepository().createUid(mdPath);

    writeMetadata(uid, request.getRequestContext(), md);
  }
View Full Code Here

    mdPath = mdPath.substring(0, mdPath.lastIndexOf(RepositoryItemUid.PATH_SEPARATOR));

    // GA
    mdPath = mdPath.substring(0, mdPath.lastIndexOf(RepositoryItemUid.PATH_SEPARATOR)) + "/maven-metadata.xml";

    RepositoryItemUid uid = request.getMavenRepository().createUid(mdPath);

    writeMetadata(uid, request.getRequestContext(), md);
  }
View Full Code Here

    mdPath = mdPath.substring(0, mdPath.lastIndexOf(RepositoryItemUid.PATH_SEPARATOR));

    // G
    mdPath = mdPath.substring(0, mdPath.lastIndexOf(RepositoryItemUid.PATH_SEPARATOR)) + "/maven-metadata.xml";

    RepositoryItemUid uid = request.getMavenRepository().createUid(mdPath);

    writeMetadata(uid, request.getRequestContext(), md);
  }
View Full Code Here

  @Override
  protected RemoteHashResponse retrieveRemoteHash(AbstractStorageItem item, ProxyRepository proxy, String baseUrl)
      throws LocalStorageException
  {
    RepositoryItemUid uid = item.getRepositoryItemUid();

    ResourceStoreRequest request = new ResourceStoreRequest(item);

    RemoteHashResponse response = null;
    try {
      // we prefer SHA1 ...
      request.pushRequestPath(uid.getPath() + SUFFIX_SHA1);
      try {
        response = doRetrieveSHA1(proxy, request, item);
      }
      finally {
        request.popRequestPath();
      }
    }
    catch (ItemNotFoundException e) {
      // ... but MD5 will do too
      request.pushRequestPath(uid.getPath() + SUFFIX_MD5);
      try {
        response = doRetrieveMD5(proxy, request, item);
      }
      catch (ItemNotFoundException e1) {
        log.debug("Item checksums (SHA1, MD5) remotely unavailable " + uid.toString());
      }
      finally {
        request.popRequestPath();
      }
    }
View Full Code Here

    request.addProcessedRepository(getId());

    maintainNotFoundCache(request);

    final RepositoryItemUid uid = createUid(request.getRequestPath());

    final RepositoryItemUidLock uidLock = uid.getLock();

    uidLock.lock(Action.read);

    try {
      StorageItem item = doRetrieveItem(request);

      // file with generated content?
      if (item instanceof StorageFileItem && ((StorageFileItem) item).isContentGenerated()) {
        StorageFileItem file = (StorageFileItem) item;

        String key = file.getContentGeneratorId();

        if (getContentGenerators().containsKey(key)) {
          ContentGenerator generator = getContentGenerators().get(key);

          try {
            file.setContentLocator(generator.generateContent(this, uid.getPath(), file));
          }
          catch (Exception e) {
            throw new LocalStorageException("Could not generate content:", e);
          }
        }
        else {
          log.info(
              String.format(
                  "The file in repository %s on path=\"%s\" should be generated by ContentGeneratorId=%s, but component does not exists!",
                  RepositoryStringUtils.getHumanizedNameString(this), uid.getPath(), key));

          throw new ItemNotFoundException(reasonFor(request, this,
              "The generator for generated path %s with key %s not found in %s", request.getRequestPath(),
              key, this));
        }
      }

      eventBus().post(new RepositoryItemEventRetrieve(this, item));

      if (log.isDebugEnabled()) {
        log.debug(getId() + " retrieveItem() :: FOUND " + uid.toString());
      }

      return item;
    }
    catch (ItemNotFoundException ex) {
      if (log.isDebugEnabled()) {
        log.debug(getId() + " retrieveItem() :: NOT FOUND " + uid.toString());
      }

      if (shouldAddToNotFoundCache(request)) {
        addToNotFoundCache(request);
      }
View Full Code Here

  private static RemoteHashResponse doRetrieveChecksumItem(ProxyRepository proxy, ResourceStoreRequest request,
                                                           StorageItem artifact, String inspector, String attrname,
                                                           String noattrname)
      throws ItemNotFoundException, LocalStorageException
  {
    final RepositoryItemUid itemUid = artifact.getRepositoryItemUid();
    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

TOP

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

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.