Search in sources :

Example 21 with MethodArgument

use of co.cask.cdap.common.internal.remote.MethodArgument in project cdap by caskdata.

the class AbstractRemoteSystemOpsHandler method deserializeNext.

@Nullable
<T> T deserializeNext(Iterator<MethodArgument> arguments, @Nullable Type typeOfT) throws ClassNotFoundException, BadRequestException {
    if (!arguments.hasNext()) {
        throw new BadRequestException("Expected additional elements.");
    }
    MethodArgument argument = arguments.next();
    if (argument == null) {
        return null;
    }
    JsonElement value = argument.getValue();
    if (value == null) {
        return null;
    }
    if (typeOfT != null) {
        return GSON.fromJson(value, typeOfT);
    }
    return GSON.<T>fromJson(value, Class.forName(argument.getType()));
}
Also used : MethodArgument(co.cask.cdap.common.internal.remote.MethodArgument) JsonElement(com.google.gson.JsonElement) BadRequestException(co.cask.cdap.common.BadRequestException) Nullable(javax.annotation.Nullable)

Example 22 with MethodArgument

use of co.cask.cdap.common.internal.remote.MethodArgument in project cdap by caskdata.

the class RemotePrivilegesHandler method listPrivileges.

@POST
@Path("/listPrivileges")
public void listPrivileges(FullHttpRequest request, HttpResponder responder) throws Exception {
    Iterator<MethodArgument> arguments = parseArguments(request);
    Principal principal = deserializeNext(arguments);
    LOG.trace("Listing privileges for principal {}", principal);
    Set<Privilege> privileges = privilegesManager.listPrivileges(principal);
    LOG.debug("Returning privileges for principal {} as {}", principal, privileges);
    responder.sendJson(HttpResponseStatus.OK, GSON.toJson(privileges));
}
Also used : MethodArgument(co.cask.cdap.common.internal.remote.MethodArgument) Privilege(co.cask.cdap.proto.security.Privilege) AuthorizationPrivilege(co.cask.cdap.proto.security.AuthorizationPrivilege) Principal(co.cask.cdap.proto.security.Principal) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 23 with MethodArgument

use of co.cask.cdap.common.internal.remote.MethodArgument in project cdap by caskdata.

the class RemoteRuntimeStoreHandler method updateWorkflowToken.

@POST
@Path("/updateWorkflowToken")
public void updateWorkflowToken(FullHttpRequest request, HttpResponder responder) throws Exception {
    Iterator<MethodArgument> arguments = parseArguments(request);
    ProgramRunId workflowRunId = deserializeNext(arguments);
    WorkflowToken token = deserializeNext(arguments);
    store.updateWorkflowToken(workflowRunId, token);
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : MethodArgument(co.cask.cdap.common.internal.remote.MethodArgument) WorkflowToken(co.cask.cdap.api.workflow.WorkflowToken) ProgramRunId(co.cask.cdap.proto.id.ProgramRunId) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 24 with MethodArgument

use of co.cask.cdap.common.internal.remote.MethodArgument in project cdap by caskdata.

the class RemoteUsageRegistryHandler method registerDataset.

@POST
@Path("/registerDataset")
public void registerDataset(FullHttpRequest request, HttpResponder responder) throws Exception {
    Iterator<MethodArgument> arguments = parseArguments(request);
    ProgramId programId = deserializeNext(arguments);
    DatasetId datasetInstance = deserializeNext(arguments);
    usageRegistry.register(programId, datasetInstance);
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : MethodArgument(co.cask.cdap.common.internal.remote.MethodArgument) ProgramId(co.cask.cdap.proto.id.ProgramId) DatasetId(co.cask.cdap.proto.id.DatasetId) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 25 with MethodArgument

use of co.cask.cdap.common.internal.remote.MethodArgument in project cdap by caskdata.

the class RemoteUsageRegistryHandler method registerStream.

@POST
@Path("/registerStream")
public void registerStream(FullHttpRequest request, HttpResponder responder) throws Exception {
    Iterator<MethodArgument> arguments = parseArguments(request);
    ProgramId programId = deserializeNext(arguments);
    StreamId streamId = deserializeNext(arguments);
    usageRegistry.register(programId, streamId);
    responder.sendStatus(HttpResponseStatus.OK);
}
Also used : StreamId(co.cask.cdap.proto.id.StreamId) MethodArgument(co.cask.cdap.common.internal.remote.MethodArgument) ProgramId(co.cask.cdap.proto.id.ProgramId) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

MethodArgument (co.cask.cdap.common.internal.remote.MethodArgument)25 POST (javax.ws.rs.POST)24 Path (javax.ws.rs.Path)24 ProgramId (co.cask.cdap.proto.id.ProgramId)8 ProgramRunId (co.cask.cdap.proto.id.ProgramRunId)8 EntityId (co.cask.cdap.proto.id.EntityId)6 Principal (co.cask.cdap.proto.security.Principal)6 AccessType (co.cask.cdap.data2.metadata.lineage.AccessType)4 DatasetId (co.cask.cdap.proto.id.DatasetId)4 NamespacedEntityId (co.cask.cdap.proto.id.NamespacedEntityId)4 StreamId (co.cask.cdap.proto.id.StreamId)4 Action (co.cask.cdap.proto.security.Action)4 WorkflowToken (co.cask.cdap.api.workflow.WorkflowToken)2 WorkflowNodeStateDetail (co.cask.cdap.proto.WorkflowNodeStateDetail)2 AuthorizationPrivilege (co.cask.cdap.proto.security.AuthorizationPrivilege)2 Privilege (co.cask.cdap.proto.security.Privilege)2 BadRequestException (co.cask.cdap.common.BadRequestException)1 BasicThrowable (co.cask.cdap.proto.BasicThrowable)1 ProgramRunStatus (co.cask.cdap.proto.ProgramRunStatus)1 JsonElement (com.google.gson.JsonElement)1