Package org.sonatype.nexus.proxy.item

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


  private void mirrorUpdateSite(final boolean force)
      throws StorageException, IllegalOperationException, UnsupportedStorageOperationException
  {
    UpdateSite site;
    try {
      final RepositoryItemUid siteUID = createUid(P2Constants.SITE_XML);
      String oldSha1 = null;

      final ResourceStoreRequest request = new ResourceStoreRequest(siteUID.getPath());

      try {
        oldSha1 =
            getLocalStorage().retrieveItem(this, request).getRepositoryItemAttributes().get(
                StorageFileItem.DIGEST_SHA1_KEY);
View Full Code Here


        mirrored.remove(remoteRequest.getRequestPath());
        mirrored.add(localRequest.getRequestPath());
      }

      // update the uid
      final RepositoryItemUid newUid = createUid(localRequest.getRequestPath());
      if (!newUid.equals(item.getRepositoryItemUid())) {
        item.setRepositoryItemUid(newUid);

        // update the resource store request
        item.setResourceStoreRequest(localRequest);
View Full Code Here

  @Override
  public void removeConfiguration(final P2RepositoryAggregatorConfiguration configuration) {
    try {
      final Repository repository = repositories.getRepository(configuration.repositoryId());
      final RepositoryItemUid p2RepoUid = repository.createUid(P2_REPOSITORY_ROOT_PATH);
      try {
        p2RepoUid.getLock().lock(Action.create);
        final ResourceStoreRequest request = new ResourceStoreRequest(P2_REPOSITORY_ROOT_PATH);
        repository.deleteItem(request);
      }
      finally {
        p2RepoUid.getLock().unlock();
      }
    }
    catch (final Exception e) {
      logger.warn(String.format("Could not delete P2 repository [%s:%s] due to [%s]",
          configuration.repositoryId(), P2_REPOSITORY_ROOT_PATH, e.getMessage()), e);
View Full Code Here

        mirrored.remove(remoteStoreRequest.getRequestPath());
        mirrored.add(localStoreRequest.getRequestPath());
      }

      // update the uid
      final RepositoryItemUid newUid = createUid(localStoreRequest.getRequestPath());
      if (!newUid.equals(item.getRepositoryItemUid())) {
        item.setRepositoryItemUid(newUid);

        // update the resource store request
        item.setResourceStoreRequest(localStoreRequest);
View Full Code Here

    if (P2Constants.SITE_XML.equals(request.getRequestPath())) {
      return;
    }

    try {
      final RepositoryItemUid siteUID = createUid(P2Constants.SITE_XML);
      final ResourceStoreRequest siteRequest = new ResourceStoreRequest(siteUID.getPath());
      StorageFileItem siteItem;
      try {
        siteItem = (StorageFileItem) getLocalStorage().retrieveItem(this, siteRequest);
      }
      catch (final ItemNotFoundException e) {
View Full Code Here

      return;
    }
    logger.debug("Updating P2 repository artifacts (update) for [{}:{}]", item.getRepositoryId(), item.getPath());
    try {
      final Repository repository = repositories.getRepository(configuration.repositoryId());
      final RepositoryItemUid p2RepoUid = repository.createUid(P2_REPOSITORY_ROOT_PATH);
      File destinationP2Repository = null;
      try {
        p2RepoUid.getLock().lock(Action.update);

        // copy repository artifacts to a temporary location
        destinationP2Repository = createTemporaryP2Repository();
        final File artifacts = getP2Artifacts(configuration, repository);
        final File tempArtifacts = new File(destinationP2Repository, artifacts.getName());
        FileUtils.copyFile(artifacts, tempArtifacts);

        updateP2Artifacts(repository, retrieveFile(repository, item.getPath()), destinationP2Repository);

        // copy repository artifacts back to exposed location
        FileUtils.copyFile(tempArtifacts, artifacts);
      }
      finally {
        p2RepoUid.getLock().unlock();
        FileUtils.deleteDirectory(destinationP2Repository);
      }
    }
    catch (final Exception e) {
      logger.warn(
View Full Code Here

      return;
    }
    logger.debug("Updating P2 repository artifacts (remove) for [{}:{}]", item.getRepositoryId(), item.getPath());
    try {
      final Repository repository = repositories.getRepository(configuration.repositoryId());
      final RepositoryItemUid p2RepoUid = repository.createUid(P2_REPOSITORY_ROOT_PATH);
      File sourceP2Repository = null;
      File destinationP2Repository = null;
      try {
        p2RepoUid.getLock().lock(Action.update);

        // copy repository artifacts to a temporary location
        destinationP2Repository = createTemporaryP2Repository();
        final File artifacts = getP2Artifacts(configuration, repository);
        final File tempArtifacts = new File(destinationP2Repository, artifacts.getName());
        FileUtils.copyFile(artifacts, tempArtifacts);

        // copy item artifacts to a temp location
        sourceP2Repository = createTemporaryP2Repository();
        FileUtils.copyFile(retrieveFile(repository, item.getPath()), new File(sourceP2Repository,
            "artifacts.xml"));

        artifactRepository.remove(sourceP2Repository.toURI(), destinationP2Repository.toURI());

        // copy repository artifacts back to exposed location
        FileUtils.copyFile(tempArtifacts, artifacts);
      }
      finally {
        p2RepoUid.getLock().unlock();
        FileUtils.deleteDirectory(sourceP2Repository);
        FileUtils.deleteDirectory(destinationP2Repository);
      }
    }
    catch (final Exception e) {
View Full Code Here

      return;
    }
    logger.debug("Updating P2 repository metadata (update) for [{}:{}]", item.getRepositoryId(), item.getPath());
    try {
      final Repository repository = repositories.getRepository(configuration.repositoryId());
      final RepositoryItemUid p2RepoUid = repository.createUid(P2_REPOSITORY_ROOT_PATH);
      File destinationP2Repository = null;
      try {
        p2RepoUid.getLock().lock(Action.update);

        // copy repository content to a temporary location
        destinationP2Repository = createTemporaryP2Repository();
        final File content = getP2Content(configuration, repository);
        final File tempContent = new File(destinationP2Repository, content.getName());
        FileUtils.copyFile(content, tempContent);

        updateP2Metadata(repository, retrieveFile(repository, item.getPath()), destinationP2Repository);

        // copy repository content back to exposed location
        FileUtils.copyFile(tempContent, content);
      }
      finally {
        p2RepoUid.getLock().unlock();
        FileUtils.deleteDirectory(destinationP2Repository);
      }
    }
    catch (final Exception e) {
      logger.warn(
View Full Code Here

      return;
    }
    logger.debug("Updating P2 repository metadata (remove) for [{}:{}]", item.getRepositoryId(), item.getPath());
    try {
      final Repository repository = repositories.getRepository(configuration.repositoryId());
      final RepositoryItemUid p2RepoUid = repository.createUid(P2_REPOSITORY_ROOT_PATH);
      File sourceP2Repository = null;
      File destinationP2Repository = null;
      try {
        p2RepoUid.getLock().lock(Action.update);

        // copy repository content to a temporary location
        destinationP2Repository = createTemporaryP2Repository();
        final File content = getP2Content(configuration, repository);
        final File tempContent = new File(destinationP2Repository, content.getName());
        FileUtils.copyFile(content, tempContent);

        // copy item content to a temp location
        sourceP2Repository = createTemporaryP2Repository();
        FileUtils.copyFile(retrieveFile(repository, item.getPath()), new File(sourceP2Repository,
            "content.xml"));

        metadataRepository.remove(sourceP2Repository.toURI(), destinationP2Repository.toURI());

        // copy repository content back to exposed location
        FileUtils.copyFile(tempContent, content);
      }
      finally {
        p2RepoUid.getLock().unlock();
        FileUtils.deleteDirectory(sourceP2Repository);
        FileUtils.deleteDirectory(destinationP2Repository);
      }
    }
    catch (final Exception e) {
View Full Code Here

    }

    try {
      final Repository repository = repositories.getRepository(repositoryId);
      final File scanPath = localStorageOfRepositoryAsFile(repository);
      final RepositoryItemUid p2RepoUid = repository.createUid(P2_REPOSITORY_ROOT_PATH);
      final File destinationP2Repository = createTemporaryP2Repository();
      try {
        p2RepoUid.getLock().lock(Action.update);

        // copy repository artifacts to a temporary location
        final File artifacts = getP2Artifacts(configuration, repository);
        final File tempArtifacts = new File(destinationP2Repository, artifacts.getName());
        FileUtils.copyFile(artifacts, tempArtifacts);

        // copy repository content to a temporary location
        final File content = getP2Content(configuration, repository);
        final File tempContent = new File(destinationP2Repository, content.getName());
        FileUtils.copyFile(content, tempContent);

        new SerialScanner().scan(scanPath, new ListenerSupport()
        {

          @Override
          public void onFile(final File file) {
            try {
              if (!isHidden(getRelativePath(scanPath, file))) {
                if (isP2ArtifactsXML(file.getPath())) {
                  updateP2Artifacts(repository, file, destinationP2Repository);
                }
                else if (isP2ContentXML(file.getPath())) {
                  updateP2Metadata(repository, file, destinationP2Repository);
                }
              }
            }
            catch (final Exception e) {
              throw new RuntimeException(e);
            }
          }

        });

        // copy artifacts back to exposed location
        FileUtils.copyFile(tempArtifacts, artifacts);
        // copy content back to exposed location
        FileUtils.copyFile(tempContent, content);
      }
      finally {
        p2RepoUid.getLock().unlock();

        FileUtils.deleteDirectory(destinationP2Repository);
      }
    }
    catch (final Exception e) {
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.