private void doPromoteByPath(PathsPromoteRequest req, boolean setReadonly) throws RepositoryManagerException {
        IndyPromoteClientModule promoter;
        try {
            promoter = serviceAccountIndy.module(IndyPromoteClientModule.class);
        } catch (IndyClientException e) {
            throw new RepositoryManagerException("Failed to retrieve Indy promote client module. Reason: %s", e, e.getMessage());
        }

        try {
            PathsPromoteResult result = promoter.promoteByPath(req);
            if (result.getError() == null) {
                if (setReadonly && !isTempBuild) {
                    HostedRepository hosted = serviceAccountIndy.stores().load(req.getTarget(), HostedRepository.class);
                    hosted.setReadonly(true);
                    try {
                        serviceAccountIndy.stores().update(hosted, "Setting readonly after successful build and promotion.");
                    } catch (IndyClientException ex) {
                        try {
                            promoter.rollbackPathPromote(result);
                        } catch (IndyClientException ex2) {
                            logger.error("Failed to set readonly flag on repo: %s. Reason given was: %s.", ex, req.getTarget(), ex.getMessage());
                            throw new RepositoryManagerException(
                                    "Subsequently also failed to rollback the promotion of paths from %s to %s. Reason given was: %s",
                                    ex2, req.getSource(), req.getTarget(), ex2.getMessage());
                        }
                        throw new RepositoryManagerException("Failed to set readonly flag on repo: %s. Reason given was: %s",
                                ex, req.getTarget(), ex.getMessage());
                    }
                }
            } else {
                String addendum = "";
                try {
                    PathsPromoteResult rollback = promoter.rollbackPathPromote(result);
                    if (rollback.getError() != null) {
                        addendum = "\nROLLBACK WARNING: Promotion rollback also failed! Reason given: " + result.getError();
                    }

                } catch (IndyClientException e) {
                    throw new RepositoryManagerException("Rollback failed for promotion of: %s. Reason: %s", e, req,
                            e.getMessage());
                }

                throw new RepositoryManagerException("Failed to promote: %s. Reason given was: %s%s", req, result.getError(),
                        addendum);
            }
        } catch (IndyClientException e) {
            throw new RepositoryManagerException("Failed to promote: %s. Reason: %s", e, req, e.getMessage());
        }
    }
private void doPromoteByPath(PathsPromoteRequest req, boolean setReadonly) throws RepositoryManagerException {
        IndyPromoteClientModule promoter;
        try {
            promoter = serviceAccountIndy.module(IndyPromoteClientModule.class);
        } catch (IndyClientException e) {
            throw new RepositoryManagerException("Failed to retrieve Indy promote client module. Reason: %s", e, e.getMessage());
        }

        try {
            PathsPromoteResult result = promoter.promoteByPath(req);
            if (result.getError() == null) {
                if (setReadonly && !isTempBuild) {
                    HostedRepository hosted = serviceAccountIndy.stores().load(req.getTarget(), HostedRepository.class);
                    hosted.setReadonly(true);
                    try {
                        serviceAccountIndy.stores().update(hosted, "Setting readonly after successful build and promotion.");
                    } catch (IndyClientException ex) {
                        try {
                            promoter.rollbackPathPromote(result);
                        } catch (IndyClientException ex2) {
                            logger.error("Failed to set readonly flag on repo: %s. Reason given was: %s.", ex, req.getTarget(), ex.getMessage());
                            throw new RepositoryManagerException(
                                    "Subsequently also failed to rollback the promotion of paths from %s to %s. Reason given was: %s",
                                    ex2, req.getSource(), req.getTarget(), ex2.getMessage());
                        }
                        throw new RepositoryManagerException("Failed to set readonly flag on repo: %s. Reason given was: %s",
                                ex, req.getTarget(), ex.getMessage());
                    }
                }
            } else {
                String addendum = "";
                try {
                    PathsPromoteResult rollback = promoter.rollbackPathPromote(result);
                    if (rollback.getError() != null) {
                        addendum = "\nROLLBACK WARNING: Promotion rollback also failed! Reason given: " + result.getError();
                    }

                } catch (IndyClientException e) {
                    throw new RepositoryManagerException("Rollback failed for promotion of: %s. Reason: %s", e, req,
                            e.getMessage());
                }

                throw new RepositoryManagerException("Failed to promote: %s. Reason given was: %s%s", req, result.getError(),
                        addendum);
            }
        } catch (IndyClientException e) {
            throw new RepositoryManagerException("Failed to promote: %s. Reason: %s", e, req, e.getMessage());
        }
    }
private void doPromoteByPath ( PathsPromoteRequest req , boolean setReadonly ) throws RepositoryManagerException { IndyPromoteClientModule promoter ; try { promoter = serviceAccountIndy . module ( IndyPromoteClientModule . class ) ; } catch ( IndyClientException e ) { throw new RepositoryManagerException ( "Failed to retrieve Indy promote client module. Reason: %s" , e , e . getMessage ( ) ) ; } try { PathsPromoteResult result = promoter . promoteByPath ( req ) ; if ( result . getError ( ) == null ) { if ( setReadonly && ! isTempBuild ) { HostedRepository hosted = serviceAccountIndy . stores ( ) . load ( req . getTarget ( ) , HostedRepository . class ) ; hosted . setReadonly ( true ) ; try { serviceAccountIndy . stores ( ) . update ( hosted , "Setting readonly after successful build and promotion." ) ; } catch ( IndyClientException ex ) { try { promoter . rollbackPathPromote ( result ) ; } catch ( IndyClientException ex2 ) { logger . error ( "Failed to set readonly flag on repo: %s. Reason given was: %s." , ex , req . getTarget ( ) , ex . getMessage ( ) ) ; throw new RepositoryManagerException ( "Subsequently also failed to rollback the promotion of paths from %s to %s. Reason given was: %s" , ex2 , req . getSource ( ) , req . getTarget ( ) , ex2 . getMessage ( ) ) ; } throw new RepositoryManagerException ( "Failed to set readonly flag on repo: %s. Reason given was: %s" , ex , req . getTarget ( ) , ex . getMessage ( ) ) ; } } } else { String addendum = "" ; try { PathsPromoteResult rollback = promoter . rollbackPathPromote ( result ) ; if ( rollback . getError ( ) != null ) { addendum = "\nROLLBACK WARNING: Promotion rollback also failed! Reason given: " + result . getError ( ) ; } } catch ( IndyClientException e ) { throw new RepositoryManagerException ( "Rollback failed for promotion of: %s. Reason: %s" , e , req , e . getMessage ( ) ) ; } throw new RepositoryManagerException ( "Failed to promote: %s. Reason given was: %s%s" , req , result . getError ( ) , addendum ) ; } } catch ( IndyClientException e ) { throw new RepositoryManagerException ( "Failed to promote: %s. Reason: %s" , e , req , e . getMessage ( ) ) ; } }
Promotes a set of artifact paths (or everything, if the path-set is missing) from a particular Indy artifact store to
another, and handle the various error conditions that may arise. If the promote call fails, attempt to rollback before
throwing an exception.

@param req The promotion request to process, which contains source and target store keys, and (optionally) the set of
paths to promote
@param setReadonly flag telling if the target repo should be set to readOnly
@throws RepositoryManagerException When either the client API throws an exception due to something unexpected in
transport, or if the promotion process results in an error.
Promotes a set of artifact paths ( or everything if the path - set is missing ) from a particular Indy artifact store to another and handle the various error conditions that may arise . If the promote call fails attempt to rollback before throwing an exception .