Search in sources :

Example 1 with DoesNotExistException

use of com.blackducksoftware.integration.hub.exception.DoesNotExistException in project hub-detect by blackducksoftware.

the class HubManager method manageExistingCodeLocations.

public void manageExistingCodeLocations(final List<String> codeLocationNames) {
    if (!detectConfiguration.getHubOfflineMode()) {
        final CodeLocationService codeLocationService = hubServiceWrapper.createCodeLocationService();
        for (final String codeLocationName : codeLocationNames) {
            try {
                final CodeLocationView codeLocationView = codeLocationService.getCodeLocationByName(codeLocationName);
                if (detectConfiguration.getProjectCodeLocationDeleteOldNames()) {
                    try {
                        codeLocationService.deleteCodeLocation(codeLocationView);
                        logger.info(String.format("Deleted code location '%s'", codeLocationName));
                    } catch (final IntegrationException e) {
                        logger.error(String.format("Not able to delete the code location '%s': %s", codeLocationName, e.getMessage()));
                    }
                } else {
                    logger.warn(String.format("Found a code location with a naming pattern that is no longer supported: %s. This code location may need to be removed to avoid duplicate entries in the Bill of Materials. You can run with --detect.project.codelocation.delete.old.names=true which will automatically delete these code locations, but please USE CAUTION.", codeLocationName));
                }
            } catch (final DoesNotExistException e) {
                logger.debug(String.format("Didn't find the code location %s - this is a good thing!", codeLocationName));
            } catch (final IntegrationException e) {
                logger.error(String.format("Error finding the code location name %s: %s", codeLocationName, e.getMessage()));
            }
        }
    }
}
Also used : CodeLocationService(com.blackducksoftware.integration.hub.service.CodeLocationService) CodeLocationView(com.blackducksoftware.integration.hub.api.generated.view.CodeLocationView) DoesNotExistException(com.blackducksoftware.integration.hub.exception.DoesNotExistException) IntegrationException(com.blackducksoftware.integration.exception.IntegrationException)

Aggregations

IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)1 CodeLocationView (com.blackducksoftware.integration.hub.api.generated.view.CodeLocationView)1 DoesNotExistException (com.blackducksoftware.integration.hub.exception.DoesNotExistException)1 CodeLocationService (com.blackducksoftware.integration.hub.service.CodeLocationService)1