protected void writeMetadata( RepositoryItemUid uid, Map<String, Object> ctx, Metadata md ) throws IllegalOperationException, UnsupportedStorageOperationException, MetadataException, IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); MetadataBuilder.write( md, outputStream ); String mdString = outputStream.toString( "UTF-8" ); outputStream.close(); DefaultStorageFileItem file = new DefaultStorageFileItem( uid.getRepository(), new ResourceStoreRequest( uid.getPath() ), true, true, new StringContentLocator( mdString ) ); ( (MavenRepository) uid.getRepository() ).storeItemWithChecksums( false, file ); }
protected void storeIndexItem(Repository repository, File file, IndexingContext context) { String path = PUBLISHING_PATH_PREFIX + "/" + file.getName(); try { ResourceStoreRequest request = new ResourceStoreRequest(path); DefaultStorageFileItem fItem = new DefaultStorageFileItem(repository, request, true, true, new FileContentLocator(file, mimeSupport.guessMimeTypeFromPath(repository.getMimeRulesSource(), file.getAbsolutePath()))); if (context.getTimestamp() == null) { fItem.setModified(0); fItem.setCreated(0); } else { fItem.setModified(context.getTimestamp().getTime()); fItem.setCreated(context.getTimestamp().getTime()); } if (repository instanceof MavenRepository) { // this is maven repo, so use the checksumming facility ((MavenRepository) repository).storeItemWithChecksums(false, fItem); } else { // simply store it repository.storeItem(false, fItem); } } catch (Exception e) { log.error("Cannot store index file " + path, e); } }
( (MavenRepository) repository ).storeItemWithChecksums( false, fItem );
public void storeArtifact( ArtifactStoreRequest gavRequest, InputStream is, Map<String, String> attributes ) throws UnsupportedStorageOperationException, IllegalOperationException, ItemNotFoundException, StorageException, AccessDeniedException { checkRequest( gavRequest ); Gav gav = new Gav( gavRequest.getGroupId(), gavRequest.getArtifactId(), gavRequest.getVersion(), gavRequest.getClassifier(), gavRequest.getExtension(), null, null, null, false, null, false, null ); gavRequest.setRequestPath( repository.getGavCalculator().gavToPath( gav ) ); repository.storeItemWithChecksums( gavRequest, is, attributes ); }
public void storeArtifactPom( ArtifactStoreRequest gavRequest, InputStream is, Map<String, String> attributes ) throws UnsupportedStorageOperationException, IllegalOperationException, ItemNotFoundException, StorageException, AccessDeniedException { checkRequest( gavRequest ); Gav gav = new Gav( gavRequest.getGroupId(), gavRequest.getArtifactId(), gavRequest.getVersion(), gavRequest.getClassifier(), "pom", null, null, null, false, null, false, null ); gavRequest.setRequestPath( repository.getGavCalculator().gavToPath( gav ) ); repository.storeItemWithChecksums( gavRequest, is, attributes ); try { repository.getMetadataManager().deployArtifact( gavRequest ); } catch ( IOException e ) { throw new LocalStorageException( "Could not maintain metadata!", e ); } }
repository.storeItemWithChecksums( gavRequest, new ByteArrayInputStream( sw.toString().getBytes() ), attributes ); repository.storeItemWithChecksums( gavRequest, is, attributes );