Package org.sonatype.nexus.proxy.item

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


            try
            {
              for(Map.Entry<String, String> entry : PATHS_TO_GENERATOR_MAP.entrySet())
              {
                // Packages.gz
                  DefaultStorageFileItem file =
                          new DynamicStorageFileItem( repository,
                              new ResourceStoreRequest( entry.getKey() ), true, false,
                                  new StringContentLocator( entry.getValue() ) );
                  file.setContentGeneratorId( entry.getValue() );
                  repository.storeItem( false, file );
              }
            }
            catch ( RepositoryNotAvailableException e )
            {
View Full Code Here


      throws IOException
  {
    final ResourceStoreRequest request = new ResourceStoreRequest(DISCOVERY_STATUS_FILE_PATH);
    request.setRequestLocalOnly(true);
    request.setRequestGroupLocalOnly(true);
    final DefaultStorageFileItem file =
        new DefaultStorageFileItem(getMavenProxyRepository(), request, true, true, content);
    try {
      getMavenProxyRepository().storeItem(true, file);
    }
    catch (UnsupportedStorageOperationException e) {
      // eh?
View Full Code Here

      String md5Hash = storedFile.getRepositoryItemAttributes().get(DigestCalculatingInspector.DIGEST_MD5_KEY);

      if (!StringUtils.isEmpty(sha1Hash)) {
        request.setRequestPath(storedFile.getPath() + ".sha1");

        storeItem(false, new DefaultStorageFileItem(this, request, true, true, new StringContentLocator(
            sha1Hash)));
      }

      if (!StringUtils.isEmpty(md5Hash)) {
        request.setRequestPath(storedFile.getPath() + ".md5");

        storeItem(false, new DefaultStorageFileItem(this, request, true, true, new StringContentLocator(
            md5Hash)));
      }
    }
    catch (ItemNotFoundException e) {
      throw new LocalStorageException("Storage inconsistency!", e);
View Full Code Here

      String md5Hash = storedFile.getRepositoryItemAttributes().get(DigestCalculatingInspector.DIGEST_MD5_KEY);

      if (!StringUtils.isEmpty(sha1Hash)) {
        req.setRequestPath(item.getPath() + ".sha1");

        storeItem(fromTask, new DefaultStorageFileItem(this, req, true, true, new StringContentLocator(
            sha1Hash)));
      }

      if (!StringUtils.isEmpty(md5Hash)) {
        req.setRequestPath(item.getPath() + ".md5");

        storeItem(fromTask, new DefaultStorageFileItem(this, req, true, true, new StringContentLocator(
            md5Hash)));
      }
    }
    catch (ItemNotFoundException e) {
      throw new LocalStorageException("Storage inconsistency!", e);
View Full Code Here

    if (this.downUrls.contains(baseUrl)) {
      throw new RemoteStorageException("Mock " + baseUrl + " is expected to be down.");
    }

    if (this.validUrlContentMap.containsKey(requestUrl)) {
      return new DefaultStorageFileItem(repository, request, true, false,
          new ByteArrayContentLocator(
              this.validUrlContentMap.get(requestUrl).getBytes(),
              "plain/text"));
    }
View Full Code Here

        marshaller.marshal(attributes, bos);

        final Repository repository = uid.getRepository();

        final DefaultStorageFileItem attributeItem =
            new DefaultStorageFileItem(repository, new ResourceStoreRequest(getAttributePath(repository,
                uid.getPath())), true, true, new ByteArrayContentLocator(bos.toByteArray(), "text/xml"));

        repository.getLocalStorage().storeItem(repository, attributeItem);
      }
      catch (UnsupportedStorageOperationException ex) {
View Full Code Here

    // a "release"
    repository.setRepositoryPolicy(RepositoryPolicy.RELEASE);
    repository.getCurrentCoreConfiguration().commitChanges();

    DefaultStorageFileItem item = new DefaultStorageFileItem(
        repository, new ResourceStoreRequest(SPOOF_RELEASE), true, true, new StringContentLocator(SPOOF_RELEASE)
    );

    repository.storeItem(false, item);

    try {
      item = new DefaultStorageFileItem(
          repository, new ResourceStoreRequest(SPOOF_SNAPSHOT), true, true, new StringContentLocator(SPOOF_SNAPSHOT)
      );

      repository.storeItem(false, item);

      assertThat("Should not be able to store snapshot to release repo", false);
    }
    catch (UnsupportedStorageOperationException e) {
      // good
    }

    // reset NFC
    repository.expireCaches(new ResourceStoreRequest(RepositoryItemUid.PATH_ROOT, true));

    // a "snapshot"
    repository.setRepositoryPolicy(RepositoryPolicy.SNAPSHOT);
    repository.getCurrentCoreConfiguration().commitChanges();

    item = new DefaultStorageFileItem(
        repository, new ResourceStoreRequest(SPOOF_SNAPSHOT), true, true, new StringContentLocator(SPOOF_SNAPSHOT)
    );

    repository.storeItem(false, item);

    try {
      item = new DefaultStorageFileItem(
          repository, new ResourceStoreRequest(SPOOF_RELEASE), true, true, new StringContentLocator(SPOOF_RELEASE)
      );

      repository.storeItem(false, item);
View Full Code Here

    String sha1str = "0123456789012345678901234567890123456789";
    String md5str = "01234567012345670123456701234567";

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

    repository.storeItem(false, new DefaultStorageFileItem(
        repository, new ResourceStoreRequest(item.getPath() + ".sha1"), true, true, new StringContentLocator(sha1str))
    );
    repository.storeItem(false, new DefaultStorageFileItem(
        repository, new ResourceStoreRequest(item.getPath() + ".md5"), true, true, new StringContentLocator(md5str))
    );

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

      throws IOException
  {
    try {
      ResourceStoreRequest req = new ResourceStoreRequest(path);

      DefaultStorageFileItem mdFile = new DefaultStorageFileItem(repository, req, true, true, contentLocator);

      repository.storeItem(false, mdFile);

      // TODO: why? storeItem() already does this!!!
      repository.removeFromNotFoundCache(req);
View Full Code Here

                "Path %s not found in local storage of repository %s", request.getRequestPath(),
                RepositoryStringUtils.getHumanizedNameString(repository)), e);
          }
        }
        else {
          DefaultStorageFileItem file =
              new DefaultStorageFileItem(repository, request, target.canRead(), target.canWrite(),
                  fileContent);
          repository.getAttributesHandler().fetchAttributes(file);
          file.setModified(target.lastModified());
          file.setCreated(target.lastModified());
          result = file;

          repository.getAttributesHandler().touchItemLastRequested(System.currentTimeMillis(), file);
        }
      }
View Full Code Here

TOP

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

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.