@Override
    @Measure( timers = @MetricNamed( DEFAULT ) )
    public Transfer store( final ArtifactStore store, final String path, final InputStream stream,
                           final TransferOperation op, final EventMetadata eventMetadata )
            throws IndyWorkflowException
    {
        if ( store.getKey().getType() == StoreType.group )
        {
            //FIXME: Why is this null? Investigate.
            return null;
        }

        if ( store.getKey().getType() != hosted )
        {
            throw new IndyWorkflowException( ApplicationStatus.BAD_REQUEST.code(),
                                             "Cannot deploy to non-deploy point artifact store: {}.", store.getKey() );
        }

        if ( !isIgnoreReadonly( eventMetadata ) && storeManager.isReadonly( store ) )
        {
            throw new IndyWorkflowException( ApplicationStatus.METHOD_NOT_ALLOWED.code(),
                                             "The store {} is readonly. If you want to store any content to this store, please modify it to non-readonly",
                                             store.getKey() );
        }


        if ( store instanceof HostedRepository )
        {
            final HostedRepository deploy = (HostedRepository) store;

//            final ArtifactPathInfo pathInfo = ArtifactPathInfo.parse( path );
            final ContentQuality quality = getQuality( path );
            if ( quality != null && quality == ContentQuality.SNAPSHOT )
            {
                if ( !deploy.isAllowSnapshots() )
                {
                    logger.error( "Cannot store snapshot in non-snapshot deploy point: {}", deploy.getName() );
                    throw new IndyWorkflowException( ApplicationStatus.BAD_REQUEST.code(),
                                                     "Cannot store snapshot in non-snapshot deploy point: {}",
                                                     deploy.getName() );
                }
            }
            else if ( !deploy.isAllowReleases() )
            {
                logger.error( "Cannot store release in snapshot-only deploy point: {}", deploy.getName() );
                throw new IndyWorkflowException( ApplicationStatus.BAD_REQUEST.code(),
                                                 "Cannot store release in snapshot-only deploy point: {}",
                                                 deploy.getName() );
            }
        }

        //        final Transfer target = getStorageReference( deploy, path );

        // TODO: Need some protection for released files!
        // if ( target.exists() )
        // {
        // throw new WebApplicationException(
        // Response.status( Status.BAD_REQUEST ).entity( "Deployment path already exists." ).build() );
        // }

        try
        {
            KeyedLocation loc = LocationUtils.toLocation( store );
            if ( isIgnoreReadonly( eventMetadata ) && loc instanceof CacheOnlyLocation )
            {
                ( (CacheOnlyLocation) loc ).setReadonly( false );
            }
            final ConcreteResource resource = new ConcreteResource( loc, path );
            Transfer txfr = transfers.store( resource, stream, eventMetadata );
            nfc.clearMissing( resource );
            return txfr;
        }
        catch ( final BadGatewayException e )
        {
            fireIndyStoreErrorEvent( e );
            logger.warn( "Bad gateway: " + e.getMessage(), e );
            throw new IndyWorkflowException( "Failed to store path: {} in: {}. Reason: {}", e, path, store,
                                             e.getMessage() );
        }
        catch ( final TransferTimeoutException e )
        {
            fireIndyStoreErrorEvent( e );
            logger.warn( "Timeout: " + e.getMessage(), e );
            throw new IndyWorkflowException( "Failed to store path: {} in: {}. Reason: {}", e, path, store,
                                             e.getMessage() );
        }
        catch ( final TransferLocationException e )
        {
            fireIndyStoreErrorEvent( e );
            logger.warn( "Location Error: " + e.getMessage(), e );
            throw new IndyWorkflowException( "Failed to store path: {} in: {}. Reason: {}", e, path, store,
                                             e.getMessage() );
        }
        catch ( TransferException e )
        {
            logger.error(
                    String.format( "Failed to store: %s in: %s. Reason: %s", path, store.getKey(), e.getMessage() ),
                    e );

            throw new IndyWorkflowException( "Failed to store: %s in: %s. Reason: %s", e, path, store.getKey(),
                                             e.getMessage() );
        }
    }
@Override
    @Measure( timers = @MetricNamed( DEFAULT ) )
    public Transfer store( final ArtifactStore store, final String path, final InputStream stream,
                           final TransferOperation op, final EventMetadata eventMetadata )
            throws IndyWorkflowException
    {
        if ( store.getKey().getType() == StoreType.group )
        {
            
            return null;
        }

        if ( store.getKey().getType() != hosted )
        {
            throw new IndyWorkflowException( ApplicationStatus.BAD_REQUEST.code(),
                                             "Cannot deploy to non-deploy point artifact store: {}.", store.getKey() );
        }

        if ( !isIgnoreReadonly( eventMetadata ) && storeManager.isReadonly( store ) )
        {
            throw new IndyWorkflowException( ApplicationStatus.METHOD_NOT_ALLOWED.code(),
                                             "The store {} is readonly. If you want to store any content to this store, please modify it to non-readonly",
                                             store.getKey() );
        }


        if ( store instanceof HostedRepository )
        {
            final HostedRepository deploy = (HostedRepository) store;


            final ContentQuality quality = getQuality( path );
            if ( quality != null && quality == ContentQuality.SNAPSHOT )
            {
                if ( !deploy.isAllowSnapshots() )
                {
                    logger.error( "Cannot store snapshot in non-snapshot deploy point: {}", deploy.getName() );
                    throw new IndyWorkflowException( ApplicationStatus.BAD_REQUEST.code(),
                                                     "Cannot store snapshot in non-snapshot deploy point: {}",
                                                     deploy.getName() );
                }
            }
            else if ( !deploy.isAllowReleases() )
            {
                logger.error( "Cannot store release in snapshot-only deploy point: {}", deploy.getName() );
                throw new IndyWorkflowException( ApplicationStatus.BAD_REQUEST.code(),
                                                 "Cannot store release in snapshot-only deploy point: {}",
                                                 deploy.getName() );
            }
        }

        

        
        
        
        
        
        

        try
        {
            KeyedLocation loc = LocationUtils.toLocation( store );
            if ( isIgnoreReadonly( eventMetadata ) && loc instanceof CacheOnlyLocation )
            {
                ( (CacheOnlyLocation) loc ).setReadonly( false );
            }
            final ConcreteResource resource = new ConcreteResource( loc, path );
            Transfer txfr = transfers.store( resource, stream, eventMetadata );
            nfc.clearMissing( resource );
            return txfr;
        }
        catch ( final BadGatewayException e )
        {
            fireIndyStoreErrorEvent( e );
            logger.warn( "Bad gateway: " + e.getMessage(), e );
            throw new IndyWorkflowException( "Failed to store path: {} in: {}. Reason: {}", e, path, store,
                                             e.getMessage() );
        }
        catch ( final TransferTimeoutException e )
        {
            fireIndyStoreErrorEvent( e );
            logger.warn( "Timeout: " + e.getMessage(), e );
            throw new IndyWorkflowException( "Failed to store path: {} in: {}. Reason: {}", e, path, store,
                                             e.getMessage() );
        }
        catch ( final TransferLocationException e )
        {
            fireIndyStoreErrorEvent( e );
            logger.warn( "Location Error: " + e.getMessage(), e );
            throw new IndyWorkflowException( "Failed to store path: {} in: {}. Reason: {}", e, path, store,
                                             e.getMessage() );
        }
        catch ( TransferException e )
        {
            logger.error(
                    String.format( "Failed to store: %s in: %s. Reason: %s", path, store.getKey(), e.getMessage() ),
                    e );

            throw new IndyWorkflowException( "Failed to store: %s in: %s. Reason: %s", e, path, store.getKey(),
                                             e.getMessage() );
        }
    }
@ Override @ Measure ( timers = @ MetricNamed ( DEFAULT ) ) public Transfer store ( final ArtifactStore store , final String path , final InputStream stream , final TransferOperation op , final EventMetadata eventMetadata ) throws IndyWorkflowException { if ( store . getKey ( ) . getType ( ) == StoreType . group ) { //FIXME: Why is this null? Investigate. return null ; } if ( store . getKey ( ) . getType ( ) != hosted ) { throw new IndyWorkflowException ( ApplicationStatus . BAD_REQUEST . code ( ) , "Cannot deploy to non-deploy point artifact store: {}." , store . getKey ( ) ) ; } if ( ! isIgnoreReadonly ( eventMetadata ) && storeManager . isReadonly ( store ) ) { throw new IndyWorkflowException ( ApplicationStatus . METHOD_NOT_ALLOWED . code ( ) , "The store {} is readonly. If you want to store any content to this store, please modify it to non-readonly" , store . getKey ( ) ) ; } if ( store instanceof HostedRepository ) { final HostedRepository deploy = ( HostedRepository ) store ; //            final ArtifactPathInfo pathInfo = ArtifactPathInfo.parse( path ); final ContentQuality quality = getQuality ( path ) ; if ( quality != null && quality == ContentQuality . SNAPSHOT ) { if ( ! deploy . isAllowSnapshots ( ) ) { logger . error ( "Cannot store snapshot in non-snapshot deploy point: {}" , deploy . getName ( ) ) ; throw new IndyWorkflowException ( ApplicationStatus . BAD_REQUEST . code ( ) , "Cannot store snapshot in non-snapshot deploy point: {}" , deploy . getName ( ) ) ; } } else if ( ! deploy . isAllowReleases ( ) ) { logger . error ( "Cannot store release in snapshot-only deploy point: {}" , deploy . getName ( ) ) ; throw new IndyWorkflowException ( ApplicationStatus . BAD_REQUEST . code ( ) , "Cannot store release in snapshot-only deploy point: {}" , deploy . getName ( ) ) ; } } //        final Transfer target = getStorageReference( deploy, path ); // TODO: Need some protection for released files! // if ( target.exists() ) // { // throw new WebApplicationException( // Response.status( Status.BAD_REQUEST ).entity( "Deployment path already exists." ).build() ); // } try { KeyedLocation loc = LocationUtils . toLocation ( store ) ; if ( isIgnoreReadonly ( eventMetadata ) && loc instanceof CacheOnlyLocation ) { ( ( CacheOnlyLocation ) loc ) . setReadonly ( false ) ; } final ConcreteResource resource = new ConcreteResource ( loc , path ) ; Transfer txfr = transfers . store ( resource , stream , eventMetadata ) ; nfc . clearMissing ( resource ) ; return txfr ; } catch ( final BadGatewayException e ) { fireIndyStoreErrorEvent ( e ) ; logger . warn ( "Bad gateway: " + e . getMessage ( ) , e ) ; throw new IndyWorkflowException ( "Failed to store path: {} in: {}. Reason: {}" , e , path , store , e . getMessage ( ) ) ; } catch ( final TransferTimeoutException e ) { fireIndyStoreErrorEvent ( e ) ; logger . warn ( "Timeout: " + e . getMessage ( ) , e ) ; throw new IndyWorkflowException ( "Failed to store path: {} in: {}. Reason: {}" , e , path , store , e . getMessage ( ) ) ; } catch ( final TransferLocationException e ) { fireIndyStoreErrorEvent ( e ) ; logger . warn ( "Location Error: " + e . getMessage ( ) , e ) ; throw new IndyWorkflowException ( "Failed to store path: {} in: {}. Reason: {}" , e , path , store , e . getMessage ( ) ) ; } catch ( TransferException e ) { logger . error ( String . format ( "Failed to store: %s in: %s. Reason: %s" , path , store . getKey ( ) , e . getMessage ( ) ) , e ) ; throw new IndyWorkflowException ( "Failed to store: %s in: %s. Reason: %s" , e , path , store . getKey ( ) , e . getMessage ( ) ) ; } }
/*
(non-Javadoc)
@see org.commonjava.indy.core.rest.util.FileManager#upload(org.commonjava.indy.core.model.DeployPoint,
java.lang.String, java.io.InputStream)
/ * ( non - Javadoc )