Package org.sonatype.nexus.proxy

Examples of org.sonatype.nexus.proxy.ResourceStoreRequest


  }

  /** local root of repo store */
  public static File repoRoot(final Repository repository) throws Exception {

    final ResourceStoreRequest request = new ResourceStoreRequest("/");

    final LocalRepositoryStorage storage = repository.getLocalStorage();

    @SuppressWarnings("deprecation")
    final URL repoURL = storage.getAbsoluteUrlFromBase(repository, request);
View Full Code Here


    }
    ArtifactUsageCalculationRepositoryResult result = new ArtifactUsageCalculationRepositoryResult(
        repository.getId());

    DefaultWalkerContext ctxMain = new DefaultWalkerContext(repository,
        new ResourceStoreRequest("/"), new DottedStoreWalkerFilter());

    ctxMain.getProcessors().add(
        new ArtifactUsageCalculationWalkerProcessor(repository
            .getGavCalculator()));
View Full Code Here

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

      for(String path : PATHS_TO_GENERATOR_MAP.keySet())
      {
        try
        {
          // Retrieve the item, update the modification time and save it
        StorageItem item = repository.retrieveItem(new ResourceStoreRequest(path));
        item.getRepositoryItemAttributes().setModified(System.currentTimeMillis());
        repository.storeItem(false, item);
      }
        catch (StorageException e)
        {
View Full Code Here

  protected StorageFileItem getFileItem()
      throws IOException
  {
    try {
      final ResourceStoreRequest request = new ResourceStoreRequest(DISCOVERY_STATUS_FILE_PATH);
      request.setRequestLocalOnly(true);
      request.setRequestGroupLocalOnly(true);
      @SuppressWarnings("deprecation")
      final StorageItem item = getMavenProxyRepository().retrieveItem(true, request);
      if (item instanceof StorageFileItem) {
        return (StorageFileItem) item;
      }
View Full Code Here

  }

  protected void putFileItem(final ContentLocator content)
      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);
    }
View Full Code Here

  }

  protected void deleteFileItem()
      throws IOException
  {
    final ResourceStoreRequest request = new ResourceStoreRequest(DISCOVERY_STATUS_FILE_PATH);
    request.setRequestLocalOnly(true);
    request.setRequestGroupLocalOnly(true);
    try {
      getMavenProxyRepository().deleteItemWithChecksums(true, request);
    }
    catch (ItemNotFoundException e) {
      // ignore
View Full Code Here

      }
      catch (IOException e) {
        throw new LocalStorageException("Could not get the content from the ContentLocator!", e);
      }

      StorageFileItem storedFile = (StorageFileItem) retrieveItem(fromTask, 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");

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

      throws UnsupportedStorageOperationException, IllegalOperationException, StorageException
  {
    List<String> shadowPaths = transformMaster2Shadow(item.getPath());

    if (shadowPaths != null && !shadowPaths.isEmpty()) {
      ResourceStoreRequest req = new ResourceStoreRequest(shadowPaths.get(0));
      req.getRequestContext().setParentContext(item.getItemContext());

      DefaultStorageLinkItem link =
          new DefaultStorageLinkItem(this, req, true, true, item.getRepositoryItemUid());

      storeItem(false, link);
View Full Code Here

      throws UnsupportedStorageOperationException, IllegalOperationException, ItemNotFoundException, StorageException
  {
    List<String> shadowPaths = transformMaster2Shadow(item.getPath());

    if (shadowPaths != null && !shadowPaths.isEmpty()) {
      ResourceStoreRequest req = new ResourceStoreRequest(shadowPaths.get(0));
      req.getRequestContext().setParentContext(item.getItemContext());
      try {
        deleteItem(false, req);
      }
      catch (ItemNotFoundException e) {
        // NEXUS-5673: just ignore it silently, this might happen when
        // link to be deleted was not found in shadow (like a parent folder was deleted
        // or M2 checksum file in master)
        // simply ignoring this is okay, as our initial goal is to lessen log spam.
        // If parent cleanup fails below, thats fine too, superclass with handle the
        // exception. This catch here is merely to logic continue with empty parent cleanup
      }

      // we need to clean up empty shadow parent directories
      String parentPath =
          req.getRequestPath().substring(0, req.getRequestPath().lastIndexOf(item.getName()));
      ResourceStoreRequest parentRequest = new ResourceStoreRequest(parentPath);

      while (parentRequest != null) {
        StorageItem parentItem = null;
        parentItem = this.retrieveItem(false, parentRequest);

        // this should be a collection Item
        if (StorageCollectionItem.class.isInstance(parentItem)) {
          StorageCollectionItem parentCollectionItem = (StorageCollectionItem) parentItem;
          try {
            if (parentCollectionItem.list().size() == 0) {
              deleteItem(false, parentRequest);
              parentRequest = new ResourceStoreRequest(parentCollectionItem.getParentPath());
            }
            else {
              // exit loop
              parentRequest = null;
            }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.ResourceStoreRequest

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.