/** * Deletes item and regenerates Maven metadata, if repository is a hosted repository and * maven-metadata.xml file is present. * * @since 2.5 */ @Override protected void doDeleteItem(final ResourceStoreRequest request) throws UnsupportedStorageOperationException, ItemNotFoundException, StorageException { try { super.doDeleteItem(request); } catch (ItemNotFoundException ex) { // NEXUS-5773, NEXUS-5418 // Since Nx 2.5, checksum are not stored on disk // but are stored as attributes. Still, upgraded systems // might have them on disk, so delete is attempted // but INFex on Checksum file in general can be neglected here. if (!shouldNeglectItemNotFoundExOnDelete(request, ex)) { throw ex; } } // regenerate maven metadata for parent of this item if is a hosted maven repo and it contains // maven-metadata.xml if (request.isExternal() && getRepositoryKind().isFacetAvailable(MavenHostedRepository.class)) { String parentPath = request.getRequestPath(); parentPath = parentPath.substring(0, parentPath.lastIndexOf(RepositoryItemUid.PATH_SEPARATOR)); final String parentMetadataPath = parentPath + "/maven-metadata.xml"; try { if (getLocalStorage().containsItem(this, new ResourceStoreRequest(parentMetadataPath))) { recreateMavenMetadata(new ResourceStoreRequest(parentPath)); } } catch (Exception e) { getLogger().warn("Could not maintain Maven metadata '{}'", parentMetadataPath, e); } } }
@Override protected void shouldTryRemote(final ResourceStoreRequest request) throws IllegalOperationException, ItemNotFoundException { // do super first super.shouldTryRemote(request); // if here, super did not throw any exception, so let's continue // apply autorouting filter to "normal" requests only, not hidden (which is meta or plain // hidden) final RepositoryItemUid uid = createUid(request.getRequestPath()); if (!uid.getBooleanAttributeValue(IsHiddenAttribute.class)) { // but filter it only if request is not marked as NFS if (!request.getRequestContext().containsKey(Manager.ROUTING_REQUEST_NFS_FLAG_KEY)) { final boolean proxyFilterAllowed = getProxyRequestFilter().allowed(this, request); if (!proxyFilterAllowed) { throw new ItemNotFoundException( ItemNotFoundException.reasonFor( request, this, "Automatic routing filter rejected remote request for path %s from %s", request.getRequestPath(), this)); } } } }
@Override public void storeItem(boolean fromTask, StorageItem item) throws UnsupportedStorageOperationException, IllegalOperationException, StorageException { final ResourceStoreRequest request = new ResourceStoreRequest(item); // this is local only request if (shouldServeByPolicies(request)) { if (getRepositoryKind().isFacetAvailable(ProxyRepository.class) && item instanceof StorageFileItem && !item.getPath().startsWith("/.")) { try { if (item.getPath().endsWith(SUFFIX_SHA1)) { doStoreSHA1(this, doRetrieveArtifactItem(request, SUFFIX_SHA1), (StorageFileItem) item); } else if (item.getPath().endsWith(SUFFIX_MD5)) { doStoreMD5(this, doRetrieveArtifactItem(request, SUFFIX_MD5), (StorageFileItem) item); } else { super.storeItem(fromTask, item); } } catch (ItemNotFoundException e) { // ignore storeItem request // this is a maven2 proxy repository, it is requested to store .sha1/.md5 file // and not there is not corresponding artifact } } else { 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); } }
@Override public void expireCaches(ResourceStoreRequest request) { super.expireCaches(request); this.overwriteRemoteUrl = null; }
@Override public void initialize() throws InitializationException { super.initialize(); p2.initializeP2(P2Util.getPluginCoordinates()); }