use of com.hortonworks.registries.common.QueryParam in project registry by hortonworks.
the class CatalogTagService method getTaggedEntities.
private List<TaggedEntity> getTaggedEntities(Long tagId) {
List<TaggedEntity> taggedEntities = new ArrayList<>();
QueryParam qp1 = new QueryParam(TagStorableMapping.FIELD_TAG_ID, String.valueOf(tagId));
for (TagStorableMapping mapping : listTagStorableMapping(ImmutableList.of(qp1))) {
taggedEntities.add(new TaggedEntity(mapping.getStorableNamespace(), mapping.getStorableId()));
}
return taggedEntities;
}
use of com.hortonworks.registries.common.QueryParam in project streamline by hortonworks.
the class NotifierInfoCatalogResource method addNotifier.
/**
* Sample request :
* <pre>
* curl -X POST 'http://localhost:8080/api/v1/catalog/notifiers' -F notifierJarFile=/tmp/email-notifier.jar
* -F notifierConfig='{
* "name":"email_notifier",
* "description": "testing",
* "className":"com.hortonworks.streamline.streams.notifiers.EmailNotifier",
* "properties": {
* "username": "hwemailtest@gmail.com",
* "password": "testing12",
* "host": "smtp.gmail.com",
* "port": "587",
* "starttls": "true",
* "debug": "true"
* },
* "fieldValues": {
* "from": "hwemailtest@gmail.com",
* "to": "hwemailtest@gmail.com",
* "subject": "Testing email notifications",
* "contentType": "text/plain",
* "body": "default body"
* }
* };type=application/json'
* </pre>
*/
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/notifiers")
@Timed
public Response addNotifier(@FormDataParam("notifierJarFile") final InputStream inputStream, @FormDataParam("notifierJarFile") final FormDataContentDisposition contentDispositionHeader, @FormDataParam("notifierConfig") final FormDataBodyPart notifierConfig, @Context SecurityContext securityContext) throws IOException {
SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_NOTIFIER_ADMIN);
MediaType mediaType = notifierConfig.getMediaType();
LOG.debug("Media type {}", mediaType);
if (!mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
throw new UnsupportedMediaTypeException(mediaType.toString());
}
Notifier notifier = notifierConfig.getValueAs(Notifier.class);
Collection<Notifier> existing = null;
existing = catalogService.listNotifierInfos(Collections.singletonList(new QueryParam(Notifier.NOTIFIER_NAME, notifier.getName())));
if (existing != null && !existing.isEmpty()) {
LOG.warn("Received a post request for an already registered notifier. Not creating entity for " + notifier);
return WSUtils.respondEntity(notifier, CONFLICT);
}
String jarFileName = uploadJar(inputStream, notifier.getName());
notifier.setJarFileName(jarFileName);
Notifier createdNotifier = catalogService.addNotifierInfo(notifier);
SecurityUtil.addAcl(authorizer, securityContext, Notifier.NAMESPACE, createdNotifier.getId(), EnumSet.allOf(Permission.class));
return WSUtils.respondEntity(createdNotifier, CREATED);
}
use of com.hortonworks.registries.common.QueryParam in project streamline by hortonworks.
the class ServiceCatalogResource method buildClusterIdAwareQueryParams.
private List<QueryParam> buildClusterIdAwareQueryParams(Long clusterId, UriInfo uriInfo) {
List<QueryParam> queryParams = new ArrayList<>();
queryParams.add(new QueryParam("clusterId", clusterId.toString()));
if (uriInfo != null) {
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
if (!params.isEmpty()) {
queryParams.addAll(WSUtils.buildQueryParameters(params));
}
}
return queryParams;
}
use of com.hortonworks.registries.common.QueryParam in project streamline by hortonworks.
the class EnvironmentService method importClusterServices.
public Cluster importClusterServices(ServiceNodeDiscoverer serviceNodeDiscoverer, Cluster cluster) throws Exception {
Cluster newCluster = clusterImporter.importCluster(serviceNodeDiscoverer, cluster);
// invalidate all containers' elements which is associated to the cluster
Long clusterId = newCluster.getId();
List<QueryParam> queryParams = Collections.singletonList(new QueryParam("clusterId", String.valueOf(clusterId)));
Set<Long> namespaceIdSet = new HashSet<>();
for (NamespaceServiceClusterMap namespaceServiceClusterMapping : listServiceClusterMapping(queryParams)) {
Long namespaceId = namespaceServiceClusterMapping.getNamespaceId();
namespaceIdSet.add(namespaceId);
}
containers.forEach(container -> {
namespaceIdSet.forEach(container::invalidateInstance);
});
return newCluster;
}
use of com.hortonworks.registries.common.QueryParam in project streamline by hortonworks.
the class ServiceConfigurationCatalogResource method buildServiceIdAwareQueryParams.
private List<QueryParam> buildServiceIdAwareQueryParams(Long serviceId, UriInfo uriInfo) {
List<QueryParam> queryParams = new ArrayList<QueryParam>();
queryParams.add(new QueryParam("serviceId", serviceId.toString()));
if (uriInfo != null) {
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
if (!params.isEmpty()) {
queryParams.addAll(WSUtils.buildQueryParameters(params));
}
}
return queryParams;
}
Aggregations