use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class NfcResource method deprecatedGetStore.
@Path("/{type: (hosted|group|remote)}/{name}")
@ApiOperation("[Deprecated] Retrieve all not-found cache entries currently tracked for a given store")
@ApiResponses({ @ApiResponse(code = 200, response = NotFoundCacheDTO.class, message = "The not-found cache for the specified artifact store") })
@GET
@Produces(ApplicationContent.application_json)
public Response deprecatedGetStore(@ApiParam(allowableValues = "hosted,group,remote", name = "type", required = true, value = "The type of store") @PathParam("type") final String t, @ApiParam(name = "name", value = "The name of the store") @PathParam("name") final String name) {
Response response;
final StoreType type = StoreType.get(t);
String altPath = Paths.get("/api/nfc", MAVEN_PKG_KEY, type.singularEndpointName(), name).toString();
final StoreKey key = new StoreKey(type, name);
try {
final NotFoundCacheDTO dto = controller.getMissing(key);
response = formatOkResponseWithJsonEntity(dto, serializer, rb -> markDeprecated(rb, altPath));
} catch (final IndyWorkflowException e) {
response = formatResponse(e, (rb) -> markDeprecated(rb, altPath));
}
return response;
}
use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class SetBackSettingsResource method delete.
@ApiOperation("DELETE the settings.xml simulation corresponding to the specified Indy group/repository")
@ApiResponses({ @ApiResponse(code = 400, message = "Requested repository is hosted on Indy and cannot be simulated via settings.xml"), @ApiResponse(code = 404, message = "No such repository or group, or the settings.xml has not been generated."), @ApiResponse(code = 204, message = "Deletion succeeded") })
@Path("/{type: (remote|group)}/{name}")
@DELETE
public Response delete(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String t, @PathParam("name") final String n) {
final StoreType type = StoreType.get(t);
if (StoreType.hosted == type) {
return Response.status(Status.BAD_REQUEST).build();
}
Response response;
final StoreKey key = new StoreKey(type, n);
try {
final boolean found = controller.deleteSetBackSettings(key);
if (found) {
response = Response.status(Status.NO_CONTENT).build();
} else {
response = Response.status(Status.NOT_FOUND).build();
}
} catch (final IndyWorkflowException e) {
response = ResponseUtils.formatResponse(e);
}
return response;
}
use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class InfinispanStoreDataManager method initByPkgMap.
public void initByPkgMap() {
// re-fill the stores by package cache each time when reboot
if (storesByPkg != null) {
logger.info("Clean the stores-by-pkg cache");
storesByPkg.clear();
}
final Set<ArtifactStore> allStores = getAllArtifactStores();
logger.info("There are {} stores need to fill in stores-by-pkg cache", allStores.size());
for (ArtifactStore store : allStores) {
final Map<StoreType, Set<StoreKey>> typedKeys = storesByPkg.computeIfAbsent(store.getKey().getPackageType(), k -> new HashMap<>());
final Set<StoreKey> keys = typedKeys.computeIfAbsent(store.getKey().getType(), k -> new HashSet<>());
keys.add(store.getKey());
}
}
use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class IndexingContentManagerDecorator method retrieve.
@Override
public Transfer retrieve(final ArtifactStore store, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
if (!indexCfg.isEnabled()) {
return delegate.retrieve(store, path, eventMetadata);
}
if (store == null) {
return null;
}
logger.trace("Looking for indexed path: {} in: {}", path, store.getKey());
Transfer transfer = getIndexedTransfer(store.getKey(), null, path, TransferOperation.DOWNLOAD, eventMetadata);
if (transfer != null) {
logger.debug("Found indexed transfer: {}. Returning.", transfer);
return transfer;
} else if (isAuthoritativelyMissing(store)) {
logger.debug("Not found indexed transfer: {} and authoritative index switched on. Considering not found and return null.", transfer);
return null;
}
StoreType type = store.getKey().getType();
if (StoreType.group == type) {
ConcreteResource resource = new ConcreteResource(LocationUtils.toLocation(store), path);
if (nfc.isMissing(resource)) {
logger.debug("{} is marked as missing. Returning null.", resource);
return null;
}
logger.debug("No group index hits. Devolving to member store indexes.");
KeyedLocation location = LocationUtils.toLocation(store);
SpecialPathInfo specialPathInfo = specialPathManager.getSpecialPathInfo(location, path, store.getPackageType());
if (specialPathInfo == null || !specialPathInfo.isMergable()) {
if (PathMaskChecker.checkMask(store, path)) {
transfer = getTransferFromConstituents(((Group) store).getConstituents(), resource, path, store, memberKey -> {
try {
ArtifactStore member = storeDataManager.getArtifactStore(memberKey);
if (member == null) {
logger.trace("Cannot find store for key: {}", memberKey);
} else {
return retrieve(member, path, eventMetadata);
}
} catch (IndyDataException e) {
logger.error(String.format("Failed to lookup store: %s (in membership of: %s). Reason: %s", memberKey, store.getKey(), e.getMessage()), e);
}
return null;
});
nfcForGroup(store, transfer, resource);
return transfer;
} else {
return null;
}
} else {
logger.debug("Merged content. Delegating to main content manager for: {} in: {}", path, store);
transfer = delegate.retrieve(store, path, eventMetadata);
if (!exists(transfer)) {
Boolean metadataGenerated = (Boolean) eventMetadata.get(GROUP_METADATA_GENERATED);
Boolean metadataExists = (Boolean) eventMetadata.get(GROUP_METADATA_EXISTS);
if (Boolean.TRUE.equals(metadataGenerated) || Boolean.TRUE.equals(metadataExists)) {
// metadata generated/exists but missing due to membership change, not add to nfc so next req can retry
;
} else // don't track NFC for hosted repos
{
nfc.addMissing(resource);
}
}
return transfer;
}
}
logger.trace("Delegating retrieve call for concrete repository: {}/{}", store, path);
transfer = delegate.retrieve(store, path, eventMetadata);
if (exists(transfer) && indexCfg.isEnabled()) {
logger.debug("Got transfer from delegate: {} (will index)", transfer);
indexManager.indexTransferIn(transfer, store.getKey());
}
logger.debug("Returning transfer: {}", transfer);
return transfer;
}
use of org.commonjava.indy.model.core.StoreType in project indy by Commonjava.
the class SettingsURIMatcher method getStoreType.
/* (non-Javadoc)
* @see org.commonjava.indy.dotmaven.util.URIMatcher#getStoreType()
*/
@Override
public StoreType getStoreType() {
if (!matches()) {
return null;
}
final String typePart = matcher.group(TYPE_GRP);
if (typePart == null) {
return null;
}
final StoreType type = StoreType.get(typePart);
return type;
}
Aggregations