/** * Gets the item uid. Shortcut for item.getRepositoryItemUid(). * * @return the item uid */ public RepositoryItemUid getItemUid() { return item.getRepositoryItemUid(); }
/** * Gets the item uid. Shortcut for item.getRepositoryItemUid(). * * @return the item uid */ public RepositoryItemUid getItemUid() { return item.getRepositoryItemUid(); }
protected boolean isHidden( WalkerContext context, StorageItem item ) { return item.getRepositoryItemUid().getBooleanAttributeValue( IsHiddenAttribute.class ); } }
@Override public String extractItemPath( StorageItem item ) { return item.getRepositoryItemUid().getPath(); }
@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() ); }
public String toString() { return String.format( "%s(sender=%s, %s)", getClass().getSimpleName(), RepositoryStringUtils.getHumanizedNameString( getRepository() ), getItem().getRepositoryItemUid().toString() ); }
/** * Creates a request for a given item. * * @param item */ public ResourceStoreRequest( StorageItem item ) { this( item.getRepositoryItemUid().getPath(), true, false ); this.requestContext = item.getItemContext(); }
@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 storeAttributes( final StorageItem item ) throws IOException { if ( item instanceof StorageCollectionItem ) { // not storing attributes of directories return; } getAttributeStorage().putAttributes( item.getRepositoryItemUid(), item.getRepositoryItemAttributes() ); }
@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())); } } });
private boolean isRpmItemEvent(RepositoryItemEvent itemEvent) { return yumRegistryProvider.get().isRegistered(itemEvent.getRepository().getId()) && !itemEvent.getItem().getRepositoryItemUid().getBooleanAttributeValue(IsHiddenAttribute.class) && itemEvent.getItem().getPath().toLowerCase().endsWith(".rpm"); }
@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); }
public boolean shouldProcess( WalkerContext context, StorageItem item ) { return target.isPathContained( item.getRepositoryItemUid().getRepository().getRepositoryContentClass(), item .getPath() ); }
public StorageFileItem retrieveArtifact( ArtifactStoreRequest gavRequest ) throws IllegalOperationException, ItemNotFoundException, StorageException, AccessDeniedException { checkRequest( gavRequest ); Gav gav = resolveArtifact( gavRequest ); gavRequest.setRequestPath( repository.getGavCalculator().gavToPath( gav ) ); StorageItem item = repository.retrieveItem( gavRequest ); if ( StorageFileItem.class.isAssignableFrom( item.getClass() ) ) { return (StorageFileItem) item; } else { throw new LocalStorageException( "The Artifact retrieval returned non-file, path:" + item.getRepositoryItemUid().toString() ); } }
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; } }
@Override public void storeItem( boolean fromTask, StorageItem item ) throws UnsupportedStorageOperationException, IllegalOperationException, StorageException { if ( shouldServeByPolicies( new ResourceStoreRequest( item ) ) ) { super.storeItem( fromTask, item ); } else { String msg = "Storing of item " + item.getRepositoryItemUid().toString() + " is forbidden by Maven Repository policy. Because " + getId() + " is a " + getRepositoryPolicy().name() + " repository"; getLogger().info( msg ); throw new UnsupportedStorageOperationException( msg ); } }
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); }
@Override public void processItem(WalkerContext context, StorageItem item) throws Exception { // just process the POM files if (item instanceof StorageFileItem && !item.getRepositoryItemUid().getPath().endsWith(".pom")) { return; } try { Gav gav = this.gavCalculator.pathToGav(item.getPath()); // make sure we've really got a POM file if (gav != null && !gav.isHash() && !gav.isSignature() && gav.getExtension().equals("pom")) { // and then calculate the artifact usage calculateArtifactUsage((StorageFileItem) item); } } catch (Exception e) { getLogger().warn( "Error processing POM file for artifact usage data: " + item.getPath(), ExceptionUtils.getRootCause(e)); } } }
@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; } }
@Override public void touchItemCheckedRemotely( final long timestamp, final StorageItem storageItem ) throws IOException { if ( storageItem instanceof StorageCollectionItem ) { // not storing attributes of directories return; } final RepositoryItemUid uid = storageItem.getRepositoryItemUid(); final Attributes attributes = getAttributeStorage().getAttributes( uid ); if ( attributes != null ) { attributes.setRepositoryId( uid.getRepository().getId() ); attributes.setPath( uid.getPath() ); attributes.setCheckedRemotely( timestamp ); attributes.setExpired( false ); getAttributeStorage().putAttributes( uid, attributes ); } }