Package org.sonatype.nexus.proxy.item

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


    DefaultStorageFileItem file = new DefaultStorageFileItem(
        repository,
        new ResourceStoreRequest(YumConfigContentGenerator.configFilePath(repository.getId())),
        true,
        false,
        new StringContentLocator(YumConfigContentGenerator.ID)
    );
    file.setContentGeneratorId(YumConfigContentGenerator.ID);

    try {
      repository.storeItem(false, file);
View Full Code Here


    if (repository.isIndexable()) {
      // "install" the archetype catalog
      try {
        final DefaultStorageFileItem file =
            new DefaultStorageFileItem(repository, new ResourceStoreRequest(ARCHETYPE_PATH), true, false,
                new StringContentLocator(ArchetypeContentGenerator.ID));
        file.setContentGeneratorId(ArchetypeContentGenerator.ID);
        repository.storeItem(false, file);
      }
      catch (RepositoryNotAvailableException e) {
        log.info("Unable to install the generated archetype catalog, repository {} is out of service",
View Full Code Here

  {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    try (final InputStream is = item.getInputStream()) {
      StreamSupport.copy(is, bos, StreamSupport.BUFFER_SIZE);
      String body = new String(bos.toByteArray(), "UTF-8");
      StringContentLocator result = null;
      if (BaseUrlHolder.isSet()) {
        result = new StringContentLocator(body.replace("@rootUrl@", BaseUrlHolder.get()));
      }
      else {
        result = new StringContentLocator(body.replace("@rootUrl@", ""));
      }
      return result;
    }
    catch (IOException e) {
      throw new LocalStorageException(e);
View Full Code Here

    DefaultStorageFileItem file = new DefaultStorageFileItem(
        inhouse,
        new ResourceStoreRequest("/a.txt"),
        true,
        true,
        new StringContentLocator(contentString));
    inhouse.storeItem(false, file);
    DefaultStorageLinkItem link = new DefaultStorageLinkItem(inhouse, new ResourceStoreRequest("/b.txt"), true, true,
        file.getRepositoryItemUid());
    inhouse.storeItem(false, link);
  }
View Full Code Here

    // deploy some stuff in it
    // a file
    final ResourceStoreRequest fileRequest = new ResourceStoreRequest("/fileItem.txt");
    final StorageFileItem fileItem =
        new DefaultStorageFileItem(repository, fileRequest, true, true, new StringContentLocator(
            "This is a file."));
    repository.storeItem(false, fileItem);
    // a link
    final ResourceStoreRequest linkRequest = new ResourceStoreRequest("/linkItem.txt");
    final StorageLinkItem linkItem =
        new DefaultStorageLinkItem(repository, linkRequest, true, true, fileItem.getRepositoryItemUid());
    repository.storeItem(false, linkItem);
    // a composite
    final ResourceStoreRequest compositeRequest = new ResourceStoreRequest("/compositeItem.txt");
    final StorageCompositeFileItem compositeItem =
        new DefaultStorageCompositeFileItem(repository, compositeRequest, true, true, new StringContentLocator(
            "This is a Composite!"), Arrays.asList(new StorageItem[]{fileItem}));
    repository.storeItem(false, compositeItem);

    // recreate attributes
    final HashMap<String, String> initialData = new HashMap<String, String>();
View Full Code Here

    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);

      fail("Should not be able to store snapshot to release repo");
    }
    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);

      fail("Should not be able to store release to snapshot repo");
View Full Code Here

  public void testSimplePutGet()
      throws Exception
  {
    DefaultStorageFileItem file =
        new DefaultStorageFileItem(repository, new ResourceStoreRequest("/a.txt"), true, true,
            new StringContentLocator("CONTENT"));

    file.getRepositoryItemAttributes().put("kuku", "kuku");

    attributeStorage.putAttributes(file.getRepositoryItemUid(), file.getRepositoryItemAttributes());
View Full Code Here

  public void testSimplePutDelete()
      throws Exception
  {
    DefaultStorageFileItem file =
        new DefaultStorageFileItem(repository, new ResourceStoreRequest("/b.txt"), true, true,
            new StringContentLocator("CONTENT"));

    file.getRepositoryItemAttributes().put("kuku", "kuku");

    attributeStorage.putAttributes(file.getRepositoryItemUid(), file.getRepositoryItemAttributes());
View Full Code Here

    assertThat(att, nullValue());
    assertThat(attFile, not(FileMatchers.exists()));

    DefaultStorageFileItem file =
        new DefaultStorageFileItem(repository, new ResourceStoreRequest(uid.getPath()), true, true,
            new StringContentLocator("CONTENT"));

    // make a zero length file
    long creationTime = createFile(attFile);
    assertThat(attFile, FileMatchers.sized(0L));
View Full Code Here

    DefaultStorageFileItem file = new DefaultStorageFileItem(
        repo1,
        new ResourceStoreRequest("/a.txt"),
        true,
        true,
        new StringContentLocator(contentString));
    file.getRepositoryItemAttributes().put("attr1", "ATTR1");
    repo1.storeItem(false, file);

    DefaultStorageLinkItem link = new DefaultStorageLinkItem(repo1, new ResourceStoreRequest("/b.txt"), true, true, file
        .getRepositoryItemUid());
View Full Code Here

TOP

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

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.