Examples of ViewBean


Examples of org.apache.hadoop.chukwa.rest.bean.ViewBean

  }
 
  public void testViewSave() {
    client = Client.create();
    resource = client.resource("http://localhost:"+restPort);
    ViewBean view = resource.path("/hicc/v1/view/vid/test").header("Authorization", authorization).get(ViewBean.class);
    view.setPermissionType("private");
    client = Client.create();
    resource = client.resource("http://localhost:"+restPort);
    ReturnCodeBean result = (ReturnCodeBean) resource.path("/hicc/v1/view").
    header("Content-Type","application/json").
    header("Authorization", authorization).
View Full Code Here

Examples of org.apache.hadoop.chukwa.rest.bean.ViewBean

  }
 
  public void testViewLoad() {
    client = Client.create();
    resource = client.resource("http://localhost:"+restPort);
    ViewBean view = resource.path("/hicc/v1/view/vid/test").header("Authorization", authorization).get(ViewBean.class);
    assertEquals("test", view.getName());
    assertEquals("admin", view.getOwner());
    assertEquals("private", view.getPermissionType());
  }
View Full Code Here

Examples of org.apache.hadoop.chukwa.rest.bean.ViewBean

  @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)
          .entity("View does not exist.").build());
View Full Code Here

Examples of org.apache.hadoop.chukwa.rest.bean.ViewBean

  @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) {
View Full Code Here

Examples of org.apache.hadoop.chukwa.rest.bean.ViewBean

      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));
View Full Code Here

Examples of org.apache.hadoop.chukwa.rest.bean.ViewBean

        FSDataInputStream viewStream = fs.open(viewFile);
        byte[] buffer = new byte[(int)size];
        viewStream.readFully(buffer);
        viewStream.close();
        try {
          view = new ViewBean(buffer);
          view.update();
        } catch (Exception e) {
          log.error(ExceptionUtil.getStackTrace(e));
          throw new IllegalAccessException("Unable to access view: "+vid);
        }
View Full Code Here

Examples of org.apache.hadoop.chukwa.rest.bean.ViewBean

            FSDataInputStream viewStream = fs.open(fstatus[i].getPath());
            byte[] buffer = new byte[(int)size];
            viewStream.readFully(buffer);
            viewStream.close();
            try {
              ViewBean view = new ViewBean(buffer);
              Map<String, String> json=new LinkedHashMap<String, String>();
              json.put("name", view.getName());
              json.put("type", view.getPermissionType());
              json.put("owner", view.getOwner());
              if(uid.intern()==view.getOwner().intern()) {
                json.put("editable","true");
              } else {
                json.put("editable","false");
              }
              list.add(json);
View Full Code Here

Examples of org.apache.hadoop.chukwa.rest.bean.ViewBean

        FSDataInputStream viewStream = fs.open(viewFile);
        byte[] buffer = new byte[(int)size];
        viewStream.readFully(buffer);
        viewStream.close();
        try {
          view = new ViewBean(new JSONObject(new String(buffer)));
          view.update();
        } catch (Exception e) {
          log.error(ExceptionUtil.getStackTrace(e));
          throw new IllegalAccessException("Unable to access view: "+vid);
        }
View Full Code Here

Examples of org.apache.hadoop.chukwa.rest.bean.ViewBean

            FSDataInputStream viewStream = fs.open(fstatus[i].getPath());
            byte[] buffer = new byte[(int)size];
            viewStream.readFully(buffer);
            viewStream.close();
            try {
              ViewBean view = new ViewBean(new JSONObject(new String(buffer)));
              JSONObject json = new JSONObject();
              json.put("name", view.getName());
              json.put("type", view.getPermissionType());
              json.put("owner", view.getOwner());
              if(uid.intern()==view.getOwner().intern()) {
                json.put("editable","true");
              } else {
                json.put("editable","false");
              }
              list.put(json);
View Full Code Here

Examples of org.apache.hadoop.chukwa.rest.bean.ViewBean

  @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)
          .entity("View does not exist.").build());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.