use of co.cask.cdap.common.security.AuditPolicy in project cdap by caskdata.
the class NamespaceHttpHandler method create.
@PUT
@Path("/namespaces/{namespace-id}")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void create(FullHttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId) throws Exception {
NamespaceId namespace;
try {
namespace = new NamespaceId(namespaceId);
} catch (IllegalArgumentException e) {
throw new BadRequestException("Namespace id can contain only alphanumeric characters or '_'.");
}
NamespaceMeta metadata = getNamespaceMeta(request);
if (isReserved(namespaceId)) {
throw new BadRequestException(String.format("Cannot create the namespace '%s'. '%s' is a reserved namespace.", namespaceId, namespaceId));
}
NamespaceMeta.Builder builder = metadata == null ? new NamespaceMeta.Builder() : new NamespaceMeta.Builder(metadata);
builder.setName(namespace);
NamespaceMeta finalMetadata = builder.build();
try {
namespaceAdmin.create(finalMetadata);
responder.sendString(HttpResponseStatus.OK, String.format("Namespace '%s' created successfully.", namespaceId));
} catch (AlreadyExistsException e) {
responder.sendString(HttpResponseStatus.OK, String.format("Namespace '%s' already exists.", namespaceId));
}
}
use of co.cask.cdap.common.security.AuditPolicy in project cdap by caskdata.
the class MetadataHttpHandler method addStreamProperties.
@POST
@Path("/namespaces/{namespace-id}/streams/{stream-id}/metadata/properties")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void addStreamProperties(FullHttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("stream-id") String streamId) throws BadRequestException, NotFoundException {
StreamId stream = new StreamId(namespaceId, streamId);
metadataAdmin.addProperties(stream, readMetadata(request));
responder.sendString(HttpResponseStatus.OK, "Metadata added successfully to " + stream);
}
use of co.cask.cdap.common.security.AuditPolicy in project cdap by caskdata.
the class MetadataHttpHandler method addAppTags.
@POST
@Path("/namespaces/{namespace-id}/apps/{app-id}/metadata/tags")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void addAppTags(FullHttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId) throws BadRequestException, NotFoundException {
ApplicationId app = new ApplicationId(namespaceId, appId);
metadataAdmin.addTags(app, readArray(request));
responder.sendString(HttpResponseStatus.OK, String.format("Added tags to application %s successfully.", app));
}
use of co.cask.cdap.common.security.AuditPolicy in project cdap by caskdata.
the class MetadataHttpHandler method addArtifactProperties.
@POST
@Path("/namespaces/{namespace-id}/artifacts/{artifact-name}/versions/{artifact-version}/metadata/properties")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void addArtifactProperties(FullHttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("artifact-name") String artifactName, @PathParam("artifact-version") String artifactVersionStr) throws BadRequestException, NotFoundException {
ArtifactId artifactId = new ArtifactId(namespaceId, artifactName, artifactVersionStr);
metadataAdmin.addProperties(artifactId, readMetadata(request));
responder.sendString(HttpResponseStatus.OK, "Metadata added successfully to " + artifactId);
}
use of co.cask.cdap.common.security.AuditPolicy in project cdap by caskdata.
the class MetadataHttpHandler method addProgramTags.
@POST
@Path("/namespaces/{namespace-id}/apps/{app-id}/{program-type}/{program-id}/metadata/tags")
@AuditPolicy(AuditDetail.REQUEST_BODY)
public void addProgramTags(FullHttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @PathParam("app-id") String appId, @PathParam("program-type") String programType, @PathParam("program-id") String programId) throws BadRequestException, NotFoundException {
ProgramId program = new ProgramId(namespaceId, appId, ProgramType.valueOfCategoryName(programType), programId);
metadataAdmin.addTags(program, readArray(request));
responder.sendString(HttpResponseStatus.OK, String.format("Added tags to program %s successfully.", program));
}
Aggregations