Package org.sonatype.nexus.proxy.item

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


    ResourceStoreRequest request = new ResourceStoreRequest(requestPath, false, false);

    repo.setChecksumPolicy(policy);
    repo.getCurrentCoreConfiguration().commitChanges();

    StorageFileItem item = (StorageFileItem) repo.retrieveItem(request);

    return item;
  }
View Full Code Here


      throws Exception
  {
    ChecksumPolicy policy = ChecksumPolicy.IGNORE;

    // it should simply pull all four without problem
    StorageFileItem file = requestWithPolicy(policy, ITEM_WITH_SHA1_AND_MD5);
    checkForFileAndMatchContents(file);
    // IGNORE: the req ignores checksum
    Assert.assertFalse(cachedHashItem(ITEM_WITH_SHA1_AND_MD5, ".sha1"));

    file = requestWithPolicy(policy, ITEM_WITH_MD5);
View Full Code Here

      throws Exception
  {
    ChecksumPolicy policy = ChecksumPolicy.WARN;

    // it should simply pull all four without problem
    StorageFileItem file = requestWithPolicy(policy, ITEM_WITH_SHA1_AND_MD5);
    checkForFileAndMatchContents(file);
    // WARN: the req implicitly gets the "best" checksum available implicitly
    Assert.assertTrue(cachedHashItem(ITEM_WITH_SHA1_AND_MD5, ".sha1"));

    file = requestWithPolicy(policy, ITEM_WITH_MD5);
View Full Code Here

      throws Exception
  {
    ChecksumPolicy policy = ChecksumPolicy.STRICT_IF_EXISTS;

    // it should simply pull all four without problem
    StorageFileItem file = requestWithPolicy(policy, ITEM_WITH_SHA1_AND_MD5);
    checkForFileAndMatchContents(file);
    // STRICT_IF_EXISTS: the req implicitly gets the "best" checksum available implicitly
    Assert.assertTrue(cachedHashItem(ITEM_WITH_SHA1_AND_MD5, ".sha1"));

    file = requestWithPolicy(policy, ITEM_WITH_MD5);
View Full Code Here

      throws Exception
  {
    ChecksumPolicy policy = ChecksumPolicy.STRICT;

    // it should simply pull all four without problem
    StorageFileItem file = requestWithPolicy(policy, ITEM_WITH_SHA1_AND_MD5);
    checkForFileAndMatchContents(file);
    // STRICT: the req implicitly gets the "best" checksum available implicitly
    Assert.assertTrue(cachedHashItem(ITEM_WITH_SHA1_AND_MD5, ".sha1"));

    file = requestWithPolicy(policy, ITEM_WITH_MD5);
View Full Code Here

      AbstractStorageItem attributeItemCandidate =
          repository.getLocalStorage().retrieveItem(repository,
              new ResourceStoreRequest(getAttributePath(repository, uid.getPath())));

      if (attributeItemCandidate instanceof StorageFileItem) {
        StorageFileItem attributeItem = (StorageFileItem) attributeItemCandidate;

        if (attributeItem.getLength() == 0) {
          // NEXUS-4871
          throw new InvalidInputException("Attribute of " + uid + " is empty!");
        }

        try (InputStream attributeStream = attributeItem.getContentLocator().getContent())
        {
          result = marshaller.unmarshal(attributeStream);
        }

        result.setRepositoryId(uid.getRepository().getId());
View Full Code Here

    Assert.assertTrue(repository.getRepositoryKind().isFacetAvailable(ProxyRepository.class));

    StorageItem item = repository.retrieveItem(new ResourceStoreRequest("/spoof/simple.txt"));

    StorageFileItem sha1 =
        (StorageFileItem) repository.retrieveItem(new ResourceStoreRequest("/spoof/simple.txt.sha1"));
    String sha1str = MUtils.readDigestFromFileItem((StorageFileItem) sha1);
    Assert.assertEquals(item.getRepositoryItemAttributes().get(StorageFileItem.DIGEST_SHA1_KEY), sha1str);
    Assert.assertEquals(item.getModified(), sha1.getModified());
    Assert.assertEquals(40, sha1.getLength());

    StorageFileItem md5 =
        (StorageFileItem) repository.retrieveItem(new ResourceStoreRequest("/spoof/simple.txt.md5"));
    String md5str = MUtils.readDigestFromFileItem((StorageFileItem) md5);
    Assert.assertEquals(item.getRepositoryItemAttributes().get(StorageFileItem.DIGEST_MD5_KEY), md5str);
    Assert.assertEquals(item.getModified(), md5.getModified());
    Assert.assertEquals(32, md5.getLength());
  }
View Full Code Here

    Map<String, StorageItem> paths = new HashMap<String, StorageItem>();
    for (StorageItem item : items) {
      paths.put(item.getPath(), item);
    }

    StorageFileItem item = (StorageFileItem) paths.get("/spoof/simple.txt");
    Assert.assertNotNull(item);

    StorageFileItem sha1 = (StorageFileItem) paths.get("/spoof/simple.txt.sha1");
    Assert.assertNotNull(sha1);
    String sha1str = MUtils.readDigestFromFileItem((StorageFileItem) sha1);
    Assert.assertEquals(item.getRepositoryItemAttributes().get(StorageFileItem.DIGEST_SHA1_KEY), sha1str);
    Assert.assertEquals(item.getModified(), sha1.getModified());
    Assert.assertEquals(40, sha1.getLength());

    StorageFileItem md5 = (StorageFileItem) paths.get("/spoof/simple.txt.md5");
    Assert.assertNotNull(md5);
    String md5str = MUtils.readDigestFromFileItem((StorageFileItem) md5);
    Assert.assertEquals(item.getRepositoryItemAttributes().get(StorageFileItem.DIGEST_MD5_KEY), md5str);
    Assert.assertEquals(item.getModified(), md5.getModified());
    Assert.assertEquals(32, md5.getLength());
  }
View Full Code Here

    );

    // reread the item to refresh attributes map
    item = repository.retrieveItem(new ResourceStoreRequest("/spoof/simple.txt"));

    StorageFileItem sha1 =
        (StorageFileItem) repository.retrieveItem(new ResourceStoreRequest("/spoof/simple.txt.sha1"));
    Assert.assertEquals(item.getRepositoryItemAttributes().get(ChecksumContentValidator.ATTR_REMOTE_SHA1),
        sha1str);
    Assert.assertEquals(item.getModified(), sha1.getModified());
    Assert.assertEquals(40, sha1.getLength());

    StorageFileItem md5 =
        (StorageFileItem) repository.retrieveItem(new ResourceStoreRequest("/spoof/simple.txt.md5"));
    Assert.assertEquals(item.getRepositoryItemAttributes().get(ChecksumContentValidator.ATTR_REMOTE_MD5), md5str);
    Assert.assertEquals(item.getModified(), md5.getModified());
    Assert.assertEquals(32, md5.getLength());
  }
View Full Code Here

  @Override
  public void processStorageItem(final StorageItem item)
      throws Exception
  {
    if (item instanceof StorageFileItem) {
      final StorageFileItem file = (StorageFileItem) item;
      final ChecksummingContentLocator sha1cl =
          new ChecksummingContentLocator(file.getContentLocator(), MessageDigest.getInstance("SHA1"),
              StorageFileItem.DIGEST_SHA1_KEY, item.getItemContext());
      // md5 is deprecated but still calculated
      ChecksummingContentLocator md5cl =
          new ChecksummingContentLocator(sha1cl, MessageDigest.getInstance("MD5"),
              StorageFileItem.DIGEST_MD5_KEY, item.getItemContext());
View Full Code Here

TOP

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

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.