Package org.sonatype.nexus.proxy.item

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


      mx.flush();
    }

    final ResourceStoreRequest request = new ResourceStoreRequest(path);
    request.getRequestContext().setParentContext(context);
    final DefaultStorageFileItem result =
        new DefaultStorageFileItem(repository, request, true /* isReadable */,
            false /* isWritable */, fileContentLocator);
    return result;
  }
View Full Code Here


         InputStream in = metadataXml.getInputStream()) {
      out.putNextEntry(new JarEntry(metadataXml.getName()));
      IOUtils.copy(in, out);
    }

    final DefaultStorageFileItem result = new DefaultStorageFileItem(
        repository, new ResourceStoreRequest(path), true /* isReadable */, false /* isWritable */, fileContentLocator
    );
    return result;
  }
View Full Code Here

  public static void storeItem(final Repository repository, final ResourceStoreRequest request, final InputStream in,
                               final String mimeType, final Map<String, String> userAttributes)
      throws Exception
  {
    final DefaultStorageFileItem fItem =
        new DefaultStorageFileItem(repository, request, true, true,
            new PreparedContentLocator(in, mimeType, ContentLocator.UNKNOWN_LENGTH));

    if (userAttributes != null) {
      fItem.getRepositoryItemAttributes().putAll(userAttributes);
    }

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

   */
  private void manageArchetypeCatalog(final Repository repository) {
    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",
            e.getRepository().getId());
View Full Code Here

                                final byte[] content,
                                final String mimeType)
      throws Exception
  {
    log.debug("Storing {}:{}", repository.getId(), path);
    DefaultStorageFileItem item = new DefaultStorageFileItem(
        repository,
        new ResourceStoreRequest("/" + path),
        true,
        true,
        new PreparedContentLocator(new ByteArrayInputStream(content), mimeType, ContentLocator.UNKNOWN_LENGTH)
View Full Code Here

  {
    final File source = new File(baseDir, relPath);

    final ResourceStoreRequest request = new ResourceStoreRequest(relPath);

    final DefaultStorageFileItem file =
        new DefaultStorageFileItem(this, request, source.canRead(), source.canWrite(), new FileContentLocator(
            source, getMimeSupport().guessMimeTypeFromPath(source.getName())));
    file.setModified(source.lastModified());
    file.setCreated(source.lastModified());

    storeItem(false, file);
  }
View Full Code Here

  private void storeItemFromFile(final String path, final File file, final P2ProxyRepository repository)
      throws LocalStorageException, UnsupportedStorageOperationException
  {
    final ContentLocator content = new FileContentLocator(file, "text/xml");
    final DefaultStorageFileItem storageItem =
        new DefaultStorageFileItem(repository, new ResourceStoreRequest(path), true /* isReadable */,
            false /* isWritable */, content);
    repository.getLocalStorage().storeItem(repository, storageItem);
  }
View Full Code Here

  }

  public void writeRawData(String path, byte[] data)
      throws Exception
  {
    DefaultStorageFileItem file = new DefaultStorageFileItem(
        repository,
        new ResourceStoreRequest(path),
        true,
        true,
        new ByteArrayContentLocator(data, "text/xml"));
View Full Code Here

  @Before
  public void prepare() throws Exception {
    final String contentString = "SOME_CONTENT";
    Repository inhouse = getRepositoryRegistry().getRepository("inhouse");
    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

                        boolean laxXmlValidation)
      throws Exception
  {
    File testFile = new File(getTestFilesBasedir(), testFileName);

    DefaultStorageFileItem file =
        new DefaultStorageFileItem(getDummyRepository(), new ResourceStoreRequest(expectedFileName), true, true,
            new FileContentLocator(testFile, "this-is-neglected-in-this-test"));
    file.getItemContext().put(MavenFileTypeValidator.XML_DETECTION_LAX_KEY, Boolean.valueOf(laxXmlValidation));

    boolean result = getValidationUtil().isExpectedFileType(file);

    Assert.assertEquals("File name: " + expectedFileName + " and file: " + testFileName + " match result: "
        + result + " expected: " + expectedResult, expectedResult, result);
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.