Examples of StorageFileItem


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

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

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

  {
    AbstractStorageItem localItem = null;
    try {
      localItem = getLocalStorage().retrieveItem(this, request);
      if (localItem instanceof StorageFileItem) {
        StorageFileItem file = (StorageFileItem) localItem;
        // wrap the content locator if needed
        if (!(file.getContentLocator() instanceof ReadLockingContentLocator)) {
          final RepositoryItemUid uid = createUid(request.getRequestPath());
          file.setContentLocator(new ReadLockingContentLocator(uid, file.getContentLocator()));
        }
      }
      if (log.isDebugEnabled()) {
        log.debug("Item " + request.toString() + " found in local storage.");
      }
View Full Code Here

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

  @Override
  public StrategyResult doDiscover(final MavenProxyRepository mavenProxyRepository) throws StrategyFailedException,
      IOException
  {
    StorageFileItem item;
    String path = config.getRemotePrefixFilePath();
    log.debug("Looking for remote prefix on {} at path {}", mavenProxyRepository, path);
    // we keep exclusive lock on UID during discovery to prevent other threads grabbing this file
    // prematurely. We release the lock only when file is present locally, and is validated.
    // in that moment it's not published yet, but the content is correct and it will be
    // the same that will get published.
    final RepositoryItemUid uid = mavenProxyRepository.createUid(path);
    uid.getLock().lock(Action.update);
    try {
      item = retrieveFromRemoteIfExists(mavenProxyRepository, path);
      if (item != null) {
        log.debug("Remote prefix on {} at path {} found!", mavenProxyRepository, path);
        long prefixFileAgeInDays = (System.currentTimeMillis() - item.getModified()) / 86400000L;
        Result unmarshalled = new TextFilePrefixSourceMarshaller(config).read(item);
        if (!unmarshalled.supported()) {
          return new StrategyResult("Remote disabled automatic routing", UNSUPPORTED_PREFIXSOURCE, false);
        }
        if (unmarshalled.entries().isEmpty()) {
View Full Code Here

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

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

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

      }
      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(
View Full Code Here

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

      throws Exception
  {

    ResourceStoreRequest request =
        new ResourceStoreRequest("/repositories/inhouse/activemq/activemq-core/1.2/activemq-core-1.2.jar", true);
    StorageFileItem item =
        (StorageFileItem) getRootRouter().retrieveItem(
            new ResourceStoreRequest("/repositories/repo1/activemq/activemq-core/1.2/activemq-core-1.2.jar", false));

    getRootRouter().storeItem(request, item.getInputStream(), null);

    assertTrue(FileUtils.contentEquals(
        getFile(getRepositoryRegistry().getRepository("repo1"),
            "/activemq/activemq-core/1.2/activemq-core-1.2.jar"),
        getFile(getRepositoryRegistry().getRepository("inhouse"),
View Full Code Here

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

      {
        @Override
        public Boolean call()
            throws IOException
        {
          StorageFileItem file = getFileItem();
          if (file != null) {
            return getPrefixSourceMarshaller().read(file).supported();
          }
          return false;
        }
View Full Code Here

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

      {
        @Override
        public Long call()
            throws Exception
        {
          final StorageFileItem file = getFileItem();
          if (file != null) {
            return file.getModified();
          }
          else {
            return -1L;
          }
        }
View Full Code Here

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

    {
      @Override
      public List<String> call()
          throws Exception
      {
        final StorageFileItem file = getFileItem();
        if (file == null) {
          return null;
        }
        return getPrefixSourceMarshaller().read(file).entries();
      }
View Full Code Here

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

  }

  @Override
  public boolean isExpectedFileType(final StorageItem item) {
    if (item instanceof StorageFileItem) {
      StorageFileItem file = (StorageFileItem) item;

      for (Map.Entry<String, FileTypeValidator> fileTypeValidatorEntry : fileTypeValidators.entrySet()) {
        FileTypeValidity validity = fileTypeValidatorEntry.getValue().isExpectedFileType(file);

        if (FileTypeValidity.INVALID.equals(validity)) {
          log.info("File item {} evaluated as INVALID during file type validation (validator={})",
              file.getRepositoryItemUid().toString(), fileTypeValidatorEntry.getKey());
          // fail fast
          return false;
        }
      }
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.