private void doIt( final Map<String, String> properties ) { final Repository repo = getRepository( TouchTestCapabilityDescriptor.FIELD_REPO_OR_GROUP_ID, properties ); try { repo.storeItem( new ResourceStoreRequest( "/capability/test.txt" ), new ByteArrayInputStream( ( "capabilities test!\n" + properties.get( TouchTestCapabilityDescriptor.FIELD_MSG_ID ) + "\n" + properties.get( TouchTestCapabilityDescriptor.FIELD_REPO_OR_GROUP_ID ) ).getBytes() ), null ); } catch ( Exception e ) { throw new RuntimeException( e.getMessage(), e ); } } }
/** * Store repository item. * * @param repository containing item to be stored * @param path of item to be stored * @param content of item to be stored * @param mimeType of item to be stored */ private static void storeItem(final Repository repository, final String path, 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) ); repository.storeItem(false, item); }
getResourceStoreRequest(request, basePath + "/" + entry.getName()); try (InputStream is = zip.getInputStream(entry)) { repository.storeItem(storeRequest, is, null);
new StringContentLocator(ArchetypeContentGenerator.ID)); file.setContentGeneratorId(ArchetypeContentGenerator.ID); repository.storeItem(false, file);
public void writeRawData( String path, byte[] data ) throws Exception { DefaultStorageFileItem file = new DefaultStorageFileItem( repository, new ResourceStoreRequest( path ), true, true, new ByteArrayContentLocator( data, "text/xml" ) ); repository.storeItem( false, file ); lastWriteFile = file; }
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); }
static void createLink(final Repository repository, final StorageItem item, final String path) throws Exception { final ResourceStoreRequest req = new ResourceStoreRequest(path); req.getRequestContext().setParentContext(item.getItemContext()); final DefaultStorageLinkItem link = new DefaultStorageLinkItem(repository, req, true, true, item.getRepositoryItemUid()); repository.storeItem(false, link); }
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); } }
repository.storeItem( false, fItem );
public void storeItem( ResourceStoreRequest request, InputStream is, Map<String, String> userAttributes ) throws UnsupportedStorageOperationException, ItemNotFoundException, IllegalOperationException, StorageException, AccessDeniedException { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it try { request.pushRequestPath( route.getRepositoryPath() ); route.getTargetedRepository().storeItem( request, is, userAttributes ); } finally { request.popRequestPath(); } } else { // this is "above" repositories throw new IllegalRequestException( request, "The path '" + request.getRequestPath() + "' does not points to any repository!" ); } }
toRoute.getTargetedRepository().storeItem( to, ( (StorageFileItem) item ).getInputStream(), item.getRepositoryItemAttributes().asMap() );