use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class ValidationRuleSetTest method matchesHostedRepoWithDotStarPattern.
@Test
public void matchesHostedRepoWithDotStarPattern() {
ValidationRuleSet ruleSet = new ValidationRuleSet("test", ".*", Collections.emptyList(), Collections.emptyMap());
assertThat(ruleSet.matchesKey(new StoreKey(StoreType.hosted, "repo").toString()), equalTo(true));
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class RelateGenerationManager method generateRelationshipFile.
/**
* Generate relationship file for pom transfer.
* @param transfer
* @param op
* @return transfer pointing to the generated rel file.
*/
public Transfer generateRelationshipFile(Transfer transfer, TransferOperation op) {
final Logger logger = LoggerFactory.getLogger(getClass());
logger.debug("Relate generation for {}", transfer);
if (transfer == null) {
logger.debug("No transfer. No .rel generation performed.");
return null;
}
String txfrPath = transfer.getPath();
if (!txfrPath.endsWith(".pom")) {
logger.debug("This is not a pom transfer.");
return null;
}
ArtifactPathInfo artPathInfo = ArtifactPathInfo.parse(txfrPath);
if (artPathInfo == null) {
logger.debug("Not an artifact download ({}). No .rel generation performed.", txfrPath);
return null;
}
ConcreteResource pomResource = transfer.getResource();
StoreKey storeKey = StoreKey.fromString(transfer.getLocation().getName());
ArtifactStore store;
try {
store = storeManager.getArtifactStore(storeKey);
} catch (final IndyDataException ex) {
logger.error("Error retrieving artifactStore with key " + storeKey, ex);
return null;
}
logger.debug("Generate .rel corresponding to associated POM download: {}/{}", storeKey, pomResource.getPath());
try {
URI source = new URI(pomResource.getLocation().getUri() + REL_SUFFIX);
ProjectVersionRef ref = artPathInfo.getProjectId();
// get all groups that this store is a member of
Set<ArtifactStore> stores = new HashSet<>();
stores.add(store);
stores.addAll(storeManager.query().getGroupsContaining(store.getKey()));
List<? extends Location> supplementalLocations = LocationUtils.toLocations(stores.toArray(new ArtifactStore[0]));
MavenPomView pomView = mavenPomReader.read(ref, transfer, supplementalLocations, ALL_PROFILES);
EProjectDirectRelationships rel = mavenModelProcessor.readRelationships(pomView, source, new ModelProcessorConfig());
Transfer transferRel = transfer.getSiblingMeta(REL_SUFFIX);
writeRelationships(rel, transferRel, op);
return transferRel;
} catch (Exception e) {
logger.error("Error generating .rel file for " + txfrPath + " from store " + store, e);
return null;
}
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class ChangelogResource method getStoreChangelog.
@ApiOperation("Retrieve the changelog for the Indy group/repository definition with the start-index and number of results")
@ApiResponses({ @ApiResponse(code = 200, message = "JSON containing changelog entries", response = ChangeSummaryDTO.class), @ApiResponse(code = 400, message = "Requested group/repository type is not one of: {remote, hosted, group}") })
@Path("/store/{type}/{name}")
public Response getStoreChangelog(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String t, @PathParam("name") final String storeName, @QueryParam("start") int start, @QueryParam("count") int count) {
final StoreType storeType = StoreType.get(t);
if (storeType == null) {
return Response.status(Status.BAD_REQUEST).entity("Invalid store type: '" + t + "'").build();
}
final StoreKey key = new StoreKey(storeType, storeName);
if (start < 0) {
start = 0;
}
if (count < 1) {
count = DEFAULT_CHANGELOG_COUNT;
}
Response response;
try {
final List<ChangeSummary> dataChangeLog = revisions.getDataChangeLog(key, start, count);
response = formatOkResponseWithJsonEntity(new ChangeSummaryDTO(dataChangeLog), objectMapper);
logger.info("\n\n\n\n\n\n{} Sent changelog for: {}\n\n{}\n\n\n\n\n\n\n", new Date(), key, dataChangeLog);
} catch (final GitSubsystemException e) {
final String message = String.format("Failed to lookup changelog for: %s. Reason: %s", key, e.getMessage());
logger.error(message, e);
response = formatResponse(e);
}
return response;
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class PomUploadListenerTest method run.
@Test
public void run() throws Exception {
final String repo1 = "repo1";
HostedRepository hosted1 = new HostedRepository(repo1);
client.stores().create(hosted1, "adding hosted", HostedRepository.class);
StoreKey key = new StoreKey(hosted, repo1);
InputStream stream = new ByteArrayInputStream(content.getBytes());
client.content().store(key, path, stream);
waitForEventPropagation();
boolean exists = client.content().exists(hosted, repo1, pathRel, true);
assertThat(exists, equalTo(true));
}
use of org.commonjava.indy.model.core.StoreKey in project indy by Commonjava.
the class AbstractValidationRuleTest method getRuleSet.
protected ValidationRuleSet getRuleSet() {
ValidationRuleSet ruleSet = new ValidationRuleSet();
ruleSet.setName("test");
ruleSet.setStoreKeyPattern(new StoreKey(group, TARGET_NAME).toString());
ruleSet.setRuleNames(Collections.singletonList(getRuleScriptFile()));
return ruleSet;
}
Aggregations