RepositoryListResource repoRes;
TemplateSet repoTemplates = getRepositoryTemplates();
for (Template tmp : repoTemplates) {
RepositoryTemplate template = (RepositoryTemplate) tmp;
repoRes = new RepositoryListResource();
repoRes.setResourceURI(createChildReference(request, this, template.getId()).toString());
repoRes.setId(template.getId());
repoRes.setName(template.getDescription());
if (ProxyRepository.class.isAssignableFrom(template.getMainFacet())) {
repoRes.setRepoType("proxy");
}
else if (HostedRepository.class.isAssignableFrom(template.getMainFacet())) {
repoRes.setRepoType("hosted");
}
else if (ShadowRepository.class.isAssignableFrom(template.getMainFacet())) {
repoRes.setRepoType("virtual");
}
else if (GroupRepository.class.isAssignableFrom(template.getMainFacet())) {
repoRes.setRepoType("group");
}
else {
// huh?
repoRes.setRepoType(template.getMainFacet().getName());
}
// policy
// another hack
if (template.getCoreConfiguration().getExternalConfiguration()
.getConfiguration(false) instanceof AbstractMavenRepositoryConfiguration) {
repoRes.setRepoPolicy(((AbstractMavenRepositoryConfiguration) template.getCoreConfiguration()
.getExternalConfiguration().getConfiguration(false)).getRepositoryPolicy().toString());
}
// format
repoRes.setFormat(template.getContentClass().getId());
// userManaged
repoRes.setUserManaged(template.getConfigurableRepository().isUserManaged());
// exposed
repoRes.setExposed(template.getConfigurableRepository().isExposed());
// ==
// below are not used for templates (and does not make any sense)
// effectiveLocalStorageUrl
// remoteUri