Package org.apache.hadoop.chukwa.datastore

Examples of org.apache.hadoop.chukwa.datastore.ViewStore


  protected static final Log log = LogFactory.getLog(ViewResource.class);

  @GET
  @Path("vid/{vid}")
  public ViewBean getView(@Context HttpServletRequest request, @PathParam("vid") String vid) {
    ViewStore view;
    ViewBean vr;
    String uid = request.getRemoteUser();
    try {
      view = new ViewStore(uid, vid);
      vr = view.get();
      if(request.getRemoteUser().intern()!=vr.getOwner().intern() && vr.getPermissionType().intern()!="public".intern()) {
        throw new WebApplicationException(Response.status(Response.Status.FORBIDDEN).entity("permission denied.").build());
      }
    } catch (IllegalAccessException e) {
      throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
View Full Code Here


  @PUT
  @Consumes("application/json")
  public ReturnCodeBean setView(@Context HttpServletRequest request, ViewBean view) {
    try {
      if(request.getRemoteUser().intern()==view.getOwner().intern()) {
        ViewStore vs = new ViewStore(view.getOwner(), view.getName());
        vs.set(view);
      } else {
          throw new WebApplicationException(Response.status(Response.Status.FORBIDDEN)
              .entity("Permission denied.").build());       
      }
    } catch (IllegalAccessException e) {
View Full Code Here

  @POST
  @Path("permission")
  public ReturnCodeBean changeViewPermission(@Context HttpServletRequest request, @FormParam("owner") String owner, @FormParam("view_vid") String vid, @FormParam("permission") String permission) {
    try {
      if(owner.intern()==request.getRemoteUser().intern()) {
        ViewStore vs = new ViewStore(owner, vid);
        ViewBean view = vs.get();
        vs.delete();
        view.setPermissionType(permission);
        vs.set(view);
      } else {
        throw new Exception("Permission denied.");
      }
    } catch (Exception e) {
      log.error(ExceptionUtil.getStackTrace(e));
View Full Code Here

  }

  @POST
  public ReturnCodeBean changeView(@Context HttpServletRequest request, @FormParam("owner") String owner, @FormParam("view_vid") String oldVid, @FormParam("view_name") String name) {
    try {
      ViewStore vs;
      if(oldVid!=null) {
        vs = new ViewStore(owner, oldVid);
      } else {
        vs = new ViewStore(null, "default");
      }
      ViewBean view = vs.get();
      view.setOwner(request.getRemoteUser());
      view.setName(name);
      view.setDescription(name);
      if(oldVid==null) {
        view.setPermissionType("private");
      }
      vs = new ViewStore(request.getRemoteUser(), name);
      vs.set(view);
    } catch (Exception e) {
      log.error(ExceptionUtil.getStackTrace(e));
      throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR)
          .entity("View save failed.").build());     
    }
View Full Code Here

  @DELETE
  @Path("delete/{owner}/vid/{vid}")
  public ReturnCodeBean deleteView(@Context HttpServletRequest request, @PathParam("owner") String owner, @PathParam("vid") String vid) {
    try {
      if(owner.intern()==request.getRemoteUser().intern()) {
        ViewStore vs = new ViewStore(owner, vid);
        vs.delete();
      } else {
        throw new WebApplicationException(Response.status(Response.Status.FORBIDDEN)
            .entity("View delete failed.").build());             
      }
    } catch (Exception e) {
View Full Code Here

  protected static Log log = LogFactory.getLog(ViewResource.class);

  @GET
  @Path("vid/{vid}")
  public ViewBean getView(@Context HttpServletRequest request, @PathParam("vid") String vid) {
    ViewStore view;
    ViewBean vr;
    String uid = request.getRemoteUser();
    try {
      view = new ViewStore(uid, vid);
      vr = view.get();
      if(request.getRemoteUser().intern()!=vr.getOwner().intern() && vr.getPermissionType().intern()!="public".intern()) {
        throw new WebApplicationException(Response.status(Response.Status.FORBIDDEN).entity("permission denied.").build());
      }
    } catch (IllegalAccessException e) {
      throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND)
View Full Code Here

  @PUT
  @Consumes("application/json")
  public ReturnCodeBean setView(@Context HttpServletRequest request, ViewBean view) {
    try {
      if(request.getRemoteUser().intern()==view.getOwner().intern()) {
        ViewStore vs = new ViewStore(view.getOwner(), view.getName());
        vs.set(view);
      } else {
          throw new WebApplicationException(Response.status(Response.Status.FORBIDDEN)
              .entity("Permission denied.").build());       
      }
    } catch (IllegalAccessException e) {
View Full Code Here

  @POST
  @Path("permission")
  public ReturnCodeBean changeViewPermission(@Context HttpServletRequest request, @FormParam("owner") String owner, @FormParam("view_vid") String vid, @FormParam("permission") String permission) {
    try {
      if(owner.intern()==request.getRemoteUser().intern()) {
        ViewStore vs = new ViewStore(owner, vid);
        ViewBean view = vs.get();
        view.setPermissionType(permission);
        vs.set(view);
      } else {
        throw new Exception("Permission denied.");
      }
    } catch (Exception e) {
      log.error(ExceptionUtil.getStackTrace(e));
View Full Code Here

  }

  @POST
  public ReturnCodeBean changeView(@Context HttpServletRequest request, @FormParam("owner") String owner, @FormParam("view_vid") String oldVid, @FormParam("view_name") String name) {
    try {
      ViewStore vs;
      if(oldVid!=null) {
        vs = new ViewStore(owner, oldVid);
      } else {
        vs = new ViewStore(null, "default");
      }
      ViewBean view = vs.get();
      view.setOwner(request.getRemoteUser());
      view.setName(name);
      view.setDescription(name);
      if(oldVid==null) {
        view.setPermissionType("private");
      }
      vs = new ViewStore(request.getRemoteUser(), name);
      vs.set(view);
    } catch (Exception e) {
      log.error(ExceptionUtil.getStackTrace(e));
      throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR)
          .entity("View save failed.").build());     
    }
View Full Code Here

  @Path("delete/{owner}/vid/{vid}")
  public ReturnCodeBean deleteView(@Context HttpServletRequest request, @PathParam("owner") String owner, @PathParam("vid") String vid) {
    try {
      if(owner.intern()==request.getRemoteUser().intern()) {
        log.info("owner: "+owner+" vid: "+vid);
        ViewStore vs = new ViewStore(owner, vid);
        vs.delete();
      } else {
        throw new WebApplicationException(Response.status(Response.Status.FORBIDDEN)
            .entity("View delete failed.").build());             
      }
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.apache.hadoop.chukwa.datastore.ViewStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.