/** * Returns true if the request is conditional. * * @return true if this request is conditional. */ public boolean isConditional() { return containsKey( CTX_CONDITION_IF_MODIFIED_SINCE ) || containsKey( CTX_CONDITION_IF_NONE_MATCH ); }
public boolean containsKey( Object key ) { return containsKey( key, true ); }
/** * Checks if is request local only. * * @return true, if is request local only */ public boolean isRequestLocalOnly() { if ( containsKey( CTX_LOCAL_ONLY_FLAG ) ) { return (Boolean) get( CTX_LOCAL_ONLY_FLAG ); } else { return false; } }
/** * Checks if is request remote only. * * @return true, if is request remote only */ public boolean isRequestRemoteOnly() { if ( containsKey( CTX_REMOTE_ONLY_FLAG ) ) { return (Boolean) get( CTX_REMOTE_ONLY_FLAG ); } else { return false; } }
/** * Returns the timestamp to check against. * * @return */ public long getIfModifiedSince() { if ( containsKey( CTX_CONDITION_IF_MODIFIED_SINCE ) ) { return (Long) get( CTX_CONDITION_IF_MODIFIED_SINCE ); } else { return 0; } }
/** * Checks if is request group local only. * * @return true, if is request group local only */ public boolean isRequestGroupLocalOnly() { if ( containsKey( CTX_GROUP_LOCAL_ONLY_FLAG ) ) { return (Boolean) get( CTX_GROUP_LOCAL_ONLY_FLAG ); } else { return false; } }
protected boolean isForceAttributeRecreation( final WalkerContext ctx ) { final RequestContext reqestContext = ctx.getResourceStoreRequest().getRequestContext(); if ( reqestContext.containsKey( FORCE_ATTRIBUTE_RECREATION, false ) ) { // obey the "hint" return Boolean.parseBoolean( String.valueOf( reqestContext.get( FORCE_ATTRIBUTE_RECREATION, false ) ) ); } else { // fallback to default behavior: do force it return true; } }
protected synchronized void setHash() throws IOException { if ( !context.containsKey( contextKey, false ) ) { context.put( contextKey, DigesterUtils.getDigestAsString( getMessageDigest().digest() ) ); } } }
public boolean containsKey( Object key, boolean fallBackToParent ) { boolean result = super.containsKey( key ); if ( fallBackToParent && !result && getParentContext() != null && getParentContext() != this ) { result = getParentContext().containsKey( key ); } return result; }
protected boolean isLegacyAttributesOnly( final WalkerContext ctx ) { final RequestContext reqestContext = ctx.getResourceStoreRequest().getRequestContext(); if ( reqestContext.containsKey( LEGACY_ATTRIBUTES_ONLY, false ) ) { // obey the "hint" return Boolean.parseBoolean( String.valueOf( reqestContext.get( LEGACY_ATTRIBUTES_ONLY, false ) ) ); } else { // fallback to default behavior: all of them return false; } } }
public Object get( Object key, boolean fallBackToParent ) { if ( containsKey( key, false ) ) { return super.get( key ); } else if ( fallBackToParent && getParentContext() != null && getParentContext() != this ) { return getParentContext().get( key ); } else { return null; } }
public DefaultWalkerContext( Repository store, ResourceStoreRequest request, WalkerFilter filter, boolean localOnly ) { super(); this.resourceStore = store; this.request = request; this.walkerFilter = filter; this.running = true; if ( request.getRequestContext().containsKey( WalkerThrottleController.CONTEXT_KEY, false ) ) { this.throttleController = (WalkerThrottleController) request.getRequestContext().get( WalkerThrottleController.CONTEXT_KEY, false ); } else { this.throttleController = WalkerThrottleController.NO_THROTTLING; } }
@Override protected StorageItem doRetrieveItem( ResourceStoreRequest request ) throws IllegalOperationException, ItemNotFoundException, StorageException { StorageItem result = super.doRetrieveItem( request ); List<String> wf = getWelcomeFiles(); boolean useWelcomeFiles = !request.getRequestContext().containsKey( WebSiteRepository.USE_WELCOME_FILES_KEY ) || Boolean.TRUE.equals( request.getRequestContext().get( WebSiteRepository.USE_WELCOME_FILES_KEY ) ); if ( useWelcomeFiles && result instanceof StorageCollectionItem && wf.size() > 0 ) { // it is a collection, check for one of the "welcome" files Collection<StorageItem> collItems = list( false, (StorageCollectionItem) result ); for ( StorageItem item : collItems ) { if ( item instanceof StorageFileItem && wf.contains( item.getName() ) ) { // it is a file, it's name is in welcomeFiles list, so return it instead parent collection return item; } } } return result; }
public void decide( Repository repository, ResourceStoreRequest request, Action action ) throws AccessDeniedException { //only bother checking item authorizer if there is no flag in request stating authorization //has been taken care of if ( !request.getRequestContext().containsKey( AccessManager.REQUEST_AUTHORIZED ) && !nexusItemAuthorizer.authorizePath( repository, request, action ) ) { // deny the access throw new AccessDeniedException( "Access denied on repository ID='" + repository.getId() + "', path='" + request.getRequestPath() + "', action='" + action + "'!" ); } } }
@Override public void delete( final LocalRepositoryStorage ls, final Repository repository, final ResourceStoreRequest request ) throws LocalStorageException { final DeleteOperation operation; if ( request.getRequestContext().containsKey( DeleteOperation.DELETE_OPERATION_CTX_KEY ) ) { operation = (DeleteOperation) request.getRequestContext().get( DeleteOperation.DELETE_OPERATION_CTX_KEY ); } else { operation = getDeleteOperation(); } delete( ls, repository, request, operation ); }
/** * Save it only 1st time. Meaning, a newly proxied/cached item will have not set these attributes, but when it comes * from cache, it will. By storing it only once, at first time, we have the record of who did it initally requested. * * @param item * @param contextKey */ private void addIfExistsButDontContains( StorageFileItem item, String contextKey ) { if ( item.getItemContext().containsKey( contextKey ) && !item.getRepositoryItemAttributes().containsKey( contextKey ) ) { Object val = item.getItemContext().get( contextKey ); if ( val != null ) { item.getRepositoryItemAttributes().put( contextKey, val.toString() ); } } }
public boolean isHandled( StorageItem item ) { if ( item instanceof StorageFileItem ) { if ( item.getItemContext().containsKey( StorageFileItem.DIGEST_SHA1_KEY ) ) { item.getRepositoryItemAttributes().put( DIGEST_SHA1_KEY, String.valueOf( item.getItemContext().get( StorageFileItem.DIGEST_SHA1_KEY ) ) ); // do this one "blindly" item.getRepositoryItemAttributes().put( DIGEST_MD5_KEY, String.valueOf( item.getItemContext().get( StorageFileItem.DIGEST_MD5_KEY ) ) ); // we did our job, we "lifted" the digest from context return false; } } // handling all files otherwise return true; }
public StorageFileItemRepresentation(StorageFileItem file) { super(MediaType.valueOf(file.getMimeType()), file); setSize(file.getLength()); if (file.getRepositoryItemAttributes().containsKey(DigestCalculatingInspector.DIGEST_SHA1_KEY)) { // Shield SHA1 // {SHA1{xxxx}} final String tag = String.format("{SHA1{%s}}", file.getRepositoryItemAttributes().get(DigestCalculatingInspector.DIGEST_SHA1_KEY)); setTag(new Tag(tag, false)); } if (file.getItemContext().containsKey(AbstractResourceStoreContentPlexusResource.OVERRIDE_FILENAME_KEY)) { String filename = file.getItemContext().get(AbstractResourceStoreContentPlexusResource.OVERRIDE_FILENAME_KEY).toString(); setDownloadable(true); setDownloadName(filename); } }
public StorageFileItemRepresentation( StorageFileItem file ) { super( MediaType.valueOf( file.getMimeType() ), file ); setSize( file.getLength() ); if ( file.getRepositoryItemAttributes().containsKey( DigestCalculatingInspector.DIGEST_SHA1_KEY ) ) { // Shield SHA1 // {SHA1{xxxx}} final String tag = String.format( "{SHA1{%s}}", file.getRepositoryItemAttributes().get( DigestCalculatingInspector.DIGEST_SHA1_KEY ) ); setTag( new Tag( tag, false ) ); } if ( file.getItemContext().containsKey( AbstractResourceStoreContentPlexusResource.OVERRIDE_FILENAME_KEY ) ) { String filename = file.getItemContext().get( AbstractResourceStoreContentPlexusResource.OVERRIDE_FILENAME_KEY ).toString(); setDownloadable( true ); setDownloadName( filename ); } }
if (request.getRequestContext().containsKey(REQUEST_RECEIVED_KEY)) { long received = (Long) request.getRequestContext().get(REQUEST_RECEIVED_KEY);