Search in sources :

Example 36 with QueryParam

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;
}
Also used : TaggedEntity(com.hortonworks.registries.tag.TaggedEntity) QueryParam(com.hortonworks.registries.common.QueryParam) ArrayList(java.util.ArrayList) TagStorableMapping(com.hortonworks.registries.tag.TagStorableMapping)

Example 37 with QueryParam

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);
}
Also used : UnsupportedMediaTypeException(com.hortonworks.streamline.common.exception.service.exception.request.UnsupportedMediaTypeException) QueryParam(com.hortonworks.registries.common.QueryParam) Permission(com.hortonworks.streamline.streams.security.Permission) MediaType(javax.ws.rs.core.MediaType) Notifier(com.hortonworks.streamline.streams.catalog.Notifier) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Timed(com.codahale.metrics.annotation.Timed)

Example 38 with QueryParam

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;
}
Also used : QueryParam(com.hortonworks.registries.common.QueryParam) ArrayList(java.util.ArrayList)

Example 39 with QueryParam

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;
}
Also used : QueryParam(com.hortonworks.registries.common.QueryParam) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) NamespaceServiceClusterMap(com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap) HashSet(java.util.HashSet)

Example 40 with QueryParam

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;
}
Also used : QueryParam(com.hortonworks.registries.common.QueryParam) ArrayList(java.util.ArrayList)

Aggregations

QueryParam (com.hortonworks.registries.common.QueryParam)72 ArrayList (java.util.ArrayList)42 WSUtils.buildEdgesFromQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesFromQueryParam)22 WSUtils.buildEdgesToQueryParam (com.hortonworks.streamline.common.util.WSUtils.buildEdgesToQueryParam)22 WSUtils.currentVersionQueryParam (com.hortonworks.streamline.common.util.WSUtils.currentVersionQueryParam)22 WSUtils.versionIdQueryParam (com.hortonworks.streamline.common.util.WSUtils.versionIdQueryParam)22 IOException (java.io.IOException)8 SchemaNotFoundException (com.hortonworks.registries.schemaregistry.errors.SchemaNotFoundException)7 StorableKey (com.hortonworks.registries.storage.StorableKey)7 OrderByField (com.hortonworks.registries.storage.OrderByField)6 HashSet (java.util.HashSet)6 SchemaVersionLifecycleContext (com.hortonworks.registries.schemaregistry.state.SchemaVersionLifecycleContext)5 TopologyComponentBundle (com.hortonworks.streamline.streams.catalog.topology.TopologyComponentBundle)5 Timed (com.codahale.metrics.annotation.Timed)4 Preconditions (com.google.common.base.Preconditions)4 SchemaBranchNotFoundException (com.hortonworks.registries.schemaregistry.errors.SchemaBranchNotFoundException)4 StorageException (com.hortonworks.registries.storage.exception.StorageException)4 TopologyTestRunCaseSource (com.hortonworks.streamline.streams.catalog.TopologyTestRunCaseSource)4 InputStream (java.io.InputStream)4 HashMap (java.util.HashMap)4