Examples of DefaultStorageFileItem


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

      final LocalStorageContext localStorageContext = new DefaultLocalStorageContext(null);
      when(repository.getLocalStorageContext()).thenReturn(localStorageContext);

      final PreparedContentLocator pcl = new PreparedContentLocator(preparedStream, "text/plain", ContentLocator.UNKNOWN_LENGTH);

      final DefaultStorageFileItem file =
          new DefaultStorageFileItem(repository, new ResourceStoreRequest("/some/file.txt"), true, true, pcl);

      testSubject.storeItem(repository, file);
    }
    finally {
      Mockito.verify(preparedStream, Mockito.times(1)).close();
View Full Code Here

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

      when(repository.getLocalUrl()).thenThrow(new RuntimeException("Something unexpected!"));

      final PreparedContentLocator pcl = new PreparedContentLocator(preparedStream, "text/plain", ContentLocator.UNKNOWN_LENGTH);

      final DefaultStorageFileItem file =
          new DefaultStorageFileItem(repository, new ResourceStoreRequest("/some/file.txt"), true, true, pcl);

      try {
        testSubject.storeItem(repository, file);
      }
      catch (RuntimeException e) {
View Full Code Here

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

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

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

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

  @Test
  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());

    RepositoryItemUid uid = getRepositoryItemUidFactory().createUid(repository, "/a.txt");
    Attributes file1 = attributeStorage.getAttributes(uid);

    assertTrue(file1.containsKey("kuku"));
View Full Code Here

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

  @Test
  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());

    RepositoryItemUid uid = getRepositoryItemUidFactory().createUid(repository, "/b.txt");

    assertNotNull(attributeStorage.getAttributes(uid));
View Full Code Here

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

    // check getAttributes is gonna delete it
    Attributes att = lsStorage.getAttributes(uid);
    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));

    att = file.getRepositoryItemAttributes();
    lsStorage.putAttributes(uid, att);

    // put shall create the file
    assertThat(attFile, FileMatchers.exists());
    // must be newer then the zero length file
View Full Code Here

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

  {
    String contentString = "SOME_CONTENT";

    Repository repo1 = getRepositoryRegistry().getRepository("repo1");

    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());
    repo1.getLocalStorage().storeItem(repo1, link);

    StorageItem item = repo1.retrieveItem(new ResourceStoreRequest("/b.txt", true));
    assertEquals(DefaultStorageLinkItem.class, item.getClass());
View Full Code Here

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

    // 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(
View Full Code Here

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

    assertNull(obrMetadataSource.buildResource(item));
  }

  private StorageFileItem createStorageFileItem(final String path, final ContentLocator content) {
    return new DefaultStorageFileItem(testRepository, new ResourceStoreRequest(path), true, true, content);
  }
View Full Code Here

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

    final ResourceStoreRequest request = new ResourceStoreRequest(path);
    final ContentLocator content = new FileContentLocator(file,
        mimeSupport.guessMimeTypeFromPath(file.getAbsolutePath()));

    try {
      repository.storeItem(false, new DefaultStorageFileItem(repository, request, true, true, content));
    }
    catch (final IllegalOperationException e) {
      throw new StorageException(e);
    }
    catch (final UnsupportedStorageOperationException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.