Search in sources :

Example 1 with TRACKING_ID

use of org.commonjava.indy.model.core.ArtifactStore.TRACKING_ID in project indy by Commonjava.

the class ProxyResponseHelper method doGetArtifactStore.

private ArtifactStore doGetArtifactStore(String trackingId, final URL url) throws IndyDataException {
    int port = getPort(url);
    if (trackingId != null) {
        String groupName = repoCreator.formatId(url.getHost(), port, 0, trackingId, StoreType.group);
        ArtifactStoreQuery<Group> query = storeManager.query().storeType(Group.class);
        Group group = query.getGroup(GENERIC_PKG_KEY, groupName);
        logger.debug("Get httproxy group, group: {}", group);
        if (group == null) {
            logger.debug("Creating repositories (group, hosted, remote) for HTTProx request: {}, trackingId: {}", url, trackingId);
            ProxyCreationResult result = createRepo(trackingId, url, null);
            group = result.getGroup();
        }
        return group;
    } else {
        RemoteRepository remote;
        final String baseUrl = getBaseUrl(url, false);
        ArtifactStoreQuery<RemoteRepository> query = storeManager.query().storeType(RemoteRepository.class);
        remote = query.getAllRemoteRepositories(GENERIC_PKG_KEY).stream().filter(store -> store.getUrl().equals(baseUrl) && store.getMetadata(TRACKING_ID) == null).findFirst().orElse(null);
        logger.debug("Get httproxy remote, remote: {}", remote);
        if (remote == null) {
            logger.debug("Creating remote repository for HTTProx request: {}", url);
            String name = getRemoteRepositoryName(url);
            ProxyCreationResult result = createRepo(null, url, name);
            remote = result.getRemote();
        }
        return remote;
    }
}
Also used : ProxyCreationResult(org.commonjava.indy.httprox.handler.ProxyCreationResult) URL(java.net.URL) ChangeSummary(org.commonjava.indy.audit.ChangeSummary) LoggerFactory(org.slf4j.LoggerFactory) PATH(org.commonjava.indy.util.RequestContextHelper.PATH) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) StringUtils(org.apache.commons.lang3.StringUtils) PACKAGE_TYPE(org.commonjava.indy.util.RequestContextHelper.PACKAGE_TYPE) Group(org.commonjava.indy.model.core.Group) Transfer(org.commonjava.maven.galley.model.Transfer) TrackingKey(org.commonjava.indy.folo.model.TrackingKey) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) NameUtils.name(org.commonjava.o11yphant.metrics.util.NameUtils.name) TraceManager.addFieldToActiveSpan(org.commonjava.o11yphant.trace.TraceManager.addFieldToActiveSpan) FoloConstants(org.commonjava.indy.folo.ctl.FoloConstants) AbstractProxyRepositoryCreator(org.commonjava.indy.httprox.handler.AbstractProxyRepositoryCreator) ApplicationHeader(org.commonjava.indy.util.ApplicationHeader) MetricsManager(org.commonjava.o11yphant.metrics.MetricsManager) GENERIC_PKG_KEY(org.commonjava.indy.model.core.GenericPackageTypeDescriptor.GENERIC_PKG_KEY) ApplicationStatus(org.commonjava.indy.util.ApplicationStatus) TRACKING_ID(org.commonjava.indy.model.core.ArtifactStore.TRACKING_ID) ArtifactStoreQuery(org.commonjava.indy.data.ArtifactStoreQuery) Logger(org.slf4j.Logger) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) ProxyRepositoryCreator(org.commonjava.indy.httprox.handler.ProxyRepositoryCreator) Predicate(java.util.function.Predicate) TraceManager(org.commonjava.o11yphant.trace.TraceManager) StoreType(org.commonjava.indy.model.core.StoreType) AccessChannel(org.commonjava.indy.model.core.AccessChannel) IOException(java.io.IOException) CONTENT_ENTRY_POINT(org.commonjava.indy.util.RequestContextHelper.CONTENT_ENTRY_POINT) METADATA_CONTENT(org.commonjava.indy.util.RequestContextHelper.METADATA_CONTENT) HttpRequest(org.apache.http.HttpRequest) IndyMetricsConfig(org.commonjava.indy.subsys.metrics.conf.IndyMetricsConfig) Collectors(java.util.stream.Collectors) PKG_TYPE_GENERIC_HTTP(org.commonjava.maven.galley.io.SpecialPathConstants.PKG_TYPE_GENERIC_HTTP) RequestContextHelper.setContext(org.commonjava.indy.util.RequestContextHelper.setContext) Timer(org.commonjava.o11yphant.metrics.api.Timer) List(java.util.List) HttproxConfig(org.commonjava.indy.httprox.conf.HttproxConfig) ContentController(org.commonjava.indy.core.ctl.ContentController) HostedRepository(org.commonjava.indy.model.core.HostedRepository) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) UserPass(org.commonjava.indy.subsys.http.util.UserPass) IndyDataException(org.commonjava.indy.data.IndyDataException) StoreDataManager(org.commonjava.indy.data.StoreDataManager) UrlInfo(org.commonjava.indy.util.UrlInfo) TransferException(org.commonjava.maven.galley.TransferException) Group(org.commonjava.indy.model.core.Group) ProxyCreationResult(org.commonjava.indy.httprox.handler.ProxyCreationResult) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository)

Aggregations

IOException (java.io.IOException)1 URL (java.net.URL)1 List (java.util.List)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang3.StringUtils)1 HttpRequest (org.apache.http.HttpRequest)1 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)1 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)1 ContentController (org.commonjava.indy.core.ctl.ContentController)1 ArtifactStoreQuery (org.commonjava.indy.data.ArtifactStoreQuery)1 IndyDataException (org.commonjava.indy.data.IndyDataException)1 StoreDataManager (org.commonjava.indy.data.StoreDataManager)1 FoloConstants (org.commonjava.indy.folo.ctl.FoloConstants)1 TrackingKey (org.commonjava.indy.folo.model.TrackingKey)1 HttproxConfig (org.commonjava.indy.httprox.conf.HttproxConfig)1 AbstractProxyRepositoryCreator (org.commonjava.indy.httprox.handler.AbstractProxyRepositoryCreator)1 ProxyCreationResult (org.commonjava.indy.httprox.handler.ProxyCreationResult)1 ProxyRepositoryCreator (org.commonjava.indy.httprox.handler.ProxyRepositoryCreator)1 AccessChannel (org.commonjava.indy.model.core.AccessChannel)1