@Override public String extractItemPath( StorageItem item ) { return item.getPath(); }
@Override public void renderCollection(final HttpServletRequest request, final HttpServletResponse response, final StorageCollectionItem coll, final Collection<StorageItem> children) throws IOException { final Set<String> uniqueNames = Sets.newHashSetWithExpectedSize(children.size()); final List<CollectionEntry> entries = Lists.newArrayListWithCapacity(children.size()); final String collUrl = request.getRequestURL().toString(); for (StorageItem child : children) { if (child.isVirtual() || !child.getRepositoryItemUid().getBooleanAttributeValue(IsHiddenAttribute.class)) { if (!uniqueNames.contains(child.getName())) { final boolean isCollection = child instanceof StorageCollectionItem; final String name = isCollection ? child.getName() + "/" : child.getName(); final CollectionEntry entry = new CollectionEntry(name, isCollection, collUrl + name, new Date(child.getModified()), StorageFileItem.class.isAssignableFrom(child .getClass()) ? ((StorageFileItem) child).getLength() : -1, ""); entries.add(entry); uniqueNames.add(child.getName()); } } } Collections.sort(entries, new CollectionEntryComparator()); final Map<String, Object> dataModel = createBaseModel(coll.getResourceStoreRequest()); dataModel.put("requestPath", coll.getPath()); dataModel.put("listItems", entries); render(getTemplate("repositoryContentHtml.vm"), dataModel, response); }
@Override @Deprecated public void touchItemLastRequested( long timestamp, Repository repository, ResourceStoreRequest request, StorageItem storageItem ) throws ItemNotFoundException, LocalStorageException, IOException { if ( storageItem instanceof StorageCollectionItem ) { return; } touchItemLastRequested( timestamp, request, storageItem.getRepositoryItemUid(), storageItem.getRepositoryItemAttributes() ); }
@Override public void touchItemLastRequested( final long timestamp, final StorageItem storageItem ) throws IOException { if ( storageItem instanceof StorageCollectionItem ) { // not storing attributes of directories return; } touchItemLastRequested( timestamp, storageItem.getResourceStoreRequest(), storageItem.getRepositoryItemUid(), storageItem.getRepositoryItemAttributes() ); }
@Override public void removeP2Metadata(final StorageItem item) { final P2MetadataGeneratorConfiguration configuration = getConfiguration(item.getRepositoryId()); if (configuration == null) { return; } logger.debug("Removing P2 metadata for [{}:{}]", item.getRepositoryId(), item.getPath()); // TODO implement }
/** * Creates a request for a given item. * * @param item */ public ResourceStoreRequest( StorageItem item ) { this( item.getRepositoryItemUid().getPath(), true, false ); this.requestContext = item.getItemContext(); }
result.setResponsePath(item.getPath()); if (!item.isVirtual()) { result.setResponseUid(item.getRepositoryItemUid().toString()); result.setOriginatingRepositoryId(item.getRepositoryItemUid().getRepository().getId()); result.setOriginatingRepositoryName(item.getRepositoryItemUid().getRepository().getName()); item.getRepositoryItemUid().getRepository().getRepositoryKind().getMainFacet().getName()); result.addProperty("created=" + item.getCreated()); result.addProperty("modified=" + item.getModified()); result.addProperty("lastRequested=" + item.getLastRequested()); result.addProperty("remoteChecked=" + item.getRemoteChecked()); result.addProperty("remoteUrl=" + item.getRemoteUrl()); result.addProperty("storedLocally=" + item.getStoredLocally()); result.addProperty("isExpired=" + item.isExpired()); result.addProperty("readable=" + item.isReadable()); result.addProperty("writable=" + item.isWritable()); result.addProperty("virtual=" + item.isVirtual()); sortedAttributes.putAll(item.getRepositoryItemAttributes().asMap()); for (Map.Entry<String, String> entry : sortedAttributes.entrySet()) { result.addAttribute(entry.toString()); StorageCompositeItem composite = (StorageCompositeItem) item; for (StorageItem source : composite.getSources()) { if (!source.isVirtual()) {
@SuppressWarnings("unchecked") @Override public void processItem(final WalkerContext context, final StorageItem item) throws Exception { final Set<String> mirrored = (Set<String>) context.getContext().get("mirrored"); if (item.getRepositoryItemUid().getBooleanAttributeValue(IsHiddenAttribute.class)) { return; } if (item instanceof StorageFileItem && !mirrored.contains(item.getPath().substring(1))) { deleteItem(false, new ResourceStoreRequest(item.getPath())); } } });
@Override protected StorageLinkItem createLink( final StorageItem item ) throws UnsupportedStorageOperationException, IllegalOperationException, StorageException { String shadowPath = null; shadowPath = transformMaster2Shadow( item.getPath() ); if ( shadowPath != null ) { ResourceStoreRequest req = new ResourceStoreRequest( shadowPath ); req.getRequestContext().putAll( item.getItemContext() ); DefaultStorageLinkItem link = new DefaultStorageLinkItem( this, req, true, true, item.getRepositoryItemUid() ); storeItem( false, link ); return link; } else { return null; } }
+ item.getPath() + "\" item's content for expanding custom attributes. This should NOT happen, but is left in as \"fallback\"!" ); File.createTempFile( "px-" + item.getName(), ".tmp", applicationConfiguration.getTemporaryDirectory() ); getLogger().warn( "Could not create file from " + item.getRepositoryItemUid(), ex ); + item.getRepositoryItemUid() + ", continuing...", ex ); + item.getRepositoryItemUid() + ", continuing...", ex );
getLogger().debug( getId() + ".storeItem() :: " + item.getRepositoryItemUid().toString() ); final RepositoryItemUid uid = createUid( item.getPath() ); item.setRepositoryItemUid( uid ); final RepositoryItemUid uploaderUid = createUid( item.getPath() + ".storeItem()" ); final Action action = getResultingActionOnWrite( item.getResourceStoreRequest() ); removeFromNotFoundCache( item.getResourceStoreRequest() );
/** * Gets the item uid. Shortcut for item.getRepositoryItemUid(). * * @return the item uid */ public RepositoryItemUid getItemUid() { return item.getRepositoryItemUid(); }
private boolean shouldProcessItem(final StorageItem item) { if (item != null && p2MetadataGenerator.get().getConfiguration(item.getRepositoryId()) != null) { try { final File file = retrieveFile( item.getRepositoryItemUid().getRepository(), item.getPath() ); return getP2Type(file) != null; } catch (final Exception e) { LOG.debug( "Could not determine if p2 metadata should be generated for '{}'. No metadata will be generated", item.getPath(), e ); } } return false; } }
shadowPath = transformMaster2Shadow( item.getPath() ); request.getRequestContext().putAll( item.getItemContext() ); request.getRequestPath().substring( 0, request.getRequestPath().lastIndexOf( item.getName() ) ); ResourceStoreRequest parentRequest = new ResourceStoreRequest( parentPath ); "Failed to delete shadow parent: " + this.getId() + ":" + parentItem.getPath() + " Access Denied", e ); "Failed to delete shadow parent: " + this.getId() + ":" + parentItem.getPath() + " does not exist", e );
protected Object renderItem(Context context, Request req, Response res, Variant variant, ResourceStore store, StorageItem item) throws IOException, AccessDeniedException, NoSuchResourceStoreException, IllegalOperationException, ItemNotFoundException, StorageException, ResourceException { if (isDescribe(req)) { return renderDescribeItem(context, req, res, variant, store, item.getResourceStoreRequest(), item, null); } if (!item.isVirtual()) { if (!item.getRepositoryItemUid().getBooleanAttributeValue(IsRemotelyAccessibleAttribute.class)) { getLogger().debug( String.format("Request for remotely non-accessible UID %s is made and refused", item.getRepositoryItemUid().toString())); throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "Resource is not found."); } } if (item instanceof StorageFileItem) { return renderStorageFileItem(req, (StorageFileItem) item); } else if (item instanceof StorageLinkItem) { return renderStorageLinkItem(context, req, res, variant, store, (StorageLinkItem) item); } else if (item instanceof StorageCollectionItem) { return renderStorageCollectionItem(context, req, res, variant, store, (StorageCollectionItem) item); } return null; }
@Override public void storeItem(Repository repository, StorageItem item) throws UnsupportedStorageOperationException, LocalStorageException { if (!item.getPath().startsWith("/.nexus")) { RubygemsFile file = fileSystem.file(item.getResourceStoreRequest()); if (file.type() != FileType.NOT_FOUND) { item.getResourceStoreRequest().setRequestPath(file.storagePath()); ((AbstractStorageItem) item).setPath(file.storagePath()); } } super.storeItem(repository, item); }
if ( !item.isVirtual() && !StorageCollectionItem.class.isAssignableFrom( item.getClass() ) ) item.getPath() ); && releaseExistsForSnapshot( gav, item.getItemContext() ) ) item.getItemContext().put( Gav.class.getName(), gav );
@Override public void processItem(WalkerContext context, StorageItem item) { if (item instanceof StorageFileItem) { try { if (item.getName().endsWith(ApiV1DependenciesCuba.RUBY)) { try(InputStream is = ((StorageFileItem) item).getInputStream()) { rubygems.newDependencyHelper().add(is); } catch(Exception e){ repository.deleteItem(true, new ResourceStoreRequest(item)); } } else if (item.getName().endsWith(QuickMarshalCuba.GEMSPEC_RZ)) { try(InputStream is = ((StorageFileItem) item).getInputStream()) { rubygems.newGemspecHelper(is); } catch(Exception e){ repository.deleteItem(true, new ResourceStoreRequest(item)); } } else if (item.getName().endsWith(".gems")) { repository.deleteItem(true, new ResourceStoreRequest(item)); } } catch (Exception e) { logger.warn("Error occurred while processing item '" + item.getPath() + "'.", e); } } } }
final ProxyRepository repository = itemEvent.getRepository().adaptToFacet(ProxyRepository.class); StorageItem item = itemEvent.getItem(); if (repository != null && item.getPath().toLowerCase().equals("/" + Yum.PATH_OF_REPOMD_XML)) { try { log.debug("Resetting processed flag... ({}:{} cached)", repository.getId(), item.getPath()); item.getRepositoryItemAttributes().remove(YumProxy.PROCESSED); repository.getAttributesHandler().storeAttributes(item); log.warn("Failed to reset processing flag for {}:{}", repository.getId(), item.getPath(), e); log.debug("Marking group repositories as dirty... ({}:{} cached)", repository.getId(), item.getPath()); List<GroupRepository> groups = repositoryRegistryProvider.get().getGroupsOfRepository(repository); for (GroupRepository group : groups) { log.debug("Removing obsolete metadata files... ({}:{} cached)", repository.getId(), item.getPath()); RepoMD repoMD = new RepoMD(((StorageFileItem) item).getInputStream()); final Collection<String> locations = repoMD.getLocations();