Package org.myphotodiary.json

Examples of org.myphotodiary.json.JsonArray


        rsp.addParameter(Configuration.groupParam,
            (directory.getGroup() == null ? Configuration.publicGroup : directory.getGroup().getGroupName()));

        List<Attribute> dirAttributes = directory.getAttributes();
        if (dirAttributes != null) {
          JsonArray attributes = new JsonArray();
          for (Attribute attribute: dirAttributes) {
            attributes.addItem(attribute.getName());
          }
          rsp.addParameter(Configuration.attrParam, attributes);
        }
      }
      else {
View Full Code Here


        rsp.addParameter(Configuration.descParam, img.getDescription())
        .addParameter(Configuration.ratingParam, img.getRating())
        .addParameter(Configuration.dateParam, img.getDate().toString());
        List<Attribute> imgAttributes = img.getAttributes();
        if (imgAttributes != null) {
          JsonArray attributes = new JsonArray();
          for (Attribute attribute: imgAttributes) {
            attributes.addItem(attribute.getName());
          }
          rsp.addParameter(Configuration.attrParam, attributes);
        }
      }
      else {
View Full Code Here

        getServletContext().log(
            "No attribute.", ex);
      }

      // Create Json response
      JsonArray rsp = new JsonArray();
      for (Attribute attribute: attributes) {
        rsp.addItem(attribute.getName());
      }
      getServletContext().log("Json response: " + rsp.toString());
      // Reply the Json response
      response.setContentType(Configuration.jsonContentType);
      response.setCharacterEncoding(Configuration.contentEncoding);
      PrintWriter out = response.getWriter();
      out.print(rsp.toString());
      out.flush();
    } catch (Exception ex) {
      getServletContext().log("Cannot GET image data", ex);
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      return;
View Full Code Here

        images = new LinkedList<Image>();
      }

      // Create Json response
      JsonObject rsp = new JsonObject();
      JsonArray imgList = new JsonArray();
      JsonArray thumbList = new JsonArray();
      // Get the image specific data
      for (Image img : images) {
        JsonObject im = new JsonObject();
        JsonObject th = new JsonObject();
        im.addParameter(Configuration.urlParam, cfg.getImageRootUrl(request)
            + img.getDirectory().getPath() + "/" + img.getName());
        imgList.addItem(im);
        th.addParameter(Configuration.urlParam, cfg.getImageRootUrl(request)
            + img.getDirectory().getPath() + "/"
            + Configuration.thumbDirName + "/" + img.getName());
        thumbList.addItem(th);
      }
      rsp.addParameter(Configuration.imgListParam, imgList);
      rsp.addParameter(Configuration.thumbListParam, thumbList);
      getServletContext().log("Json response: " + rsp.toString());
      // Reply the Json response
View Full Code Here

        getServletContext().log(
            "No attribute.", ex);
      }

      // Create Json response
      JsonArray rsp = new JsonArray();
      for (Attribute attribute: attributes) {
        rsp.addItem(attribute.getName());
      }
      getServletContext().log("Json response: " + rsp.toString());
      // Reply the Json response
      response.setContentType(Configuration.jsonContentType);
      response.setCharacterEncoding(Configuration.contentEncoding);
      PrintWriter out = response.getWriter();
      out.print(rsp.toString());
      out.flush();
    } catch (Exception ex) {
      getServletContext().log("Cannot GET image data", ex);
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      return;
View Full Code Here

        images = new LinkedList<Image>();
      }

      // Create Json response
      JsonObject rsp = new JsonObject();
      JsonArray imgList = new JsonArray();
      JsonArray thumbList = new JsonArray();
      // Get the image specific data
      for (Image img : images) {
        JsonObject im = new JsonObject();
        JsonObject th = new JsonObject();
        im.addParameter(Configuration.urlParam, cfg.imageRootUrl
            + img.getDirectory().getPath() + "/" + img.getName());
        imgList.addItem(im);
        th.addParameter(Configuration.urlParam, cfg.imageRootUrl
            + img.getDirectory().getPath() + "/"
            + Configuration.thumbDirName + "/" + img.getName());
        thumbList.addItem(th);
      }
      rsp.addParameter(Configuration.imgListParam, imgList);
      rsp.addParameter(Configuration.thumbListParam, thumbList);
      getServletContext().log("Json response: " + rsp.toString());
      // Reply the Json response
View Full Code Here

        if (directory.getDate() != null) {
          rsp.addParameter(Configuration.dirDateParam, directory.getDate());
        }
        List<Attribute> dirAttributes = directory.getAttributes();
        if (dirAttributes != null) {
          JsonArray attributes = new JsonArray();
          for (Attribute attribute: dirAttributes) {
            attributes.addItem(attribute.getName());
          }
          rsp.addParameter(Configuration.attrParam, attributes);
        }
      }
      else {
View Full Code Here

        rsp.addParameter(Configuration.descParam, img.getDescription())
        .addParameter(Configuration.ratingParam, img.getRating())
        .addParameter(Configuration.dateParam, img.getDate().toString());
        List<Attribute> imgAttributes = img.getAttributes();
        if (imgAttributes != null) {
          JsonArray attributes = new JsonArray();
          for (Attribute attribute: imgAttributes) {
            attributes.addItem(attribute.getName());
          }
          rsp.addParameter(Configuration.attrParam, attributes);
        }
      }
      else {
View Full Code Here

        getServletContext().log(
            "No group.", ex);
      }

      // Create Json response
      JsonArray rsp = new JsonArray();
      for (Group group: groups) {
        try {
          // RBAC on the group
          AccessController.checkAuthorization(group, request, Action.browse, null);
          rsp.addItem(group.getGroupName());
        }
        catch (AuthorizationException ex) {
          // Group access not allowed, check the next one
        }
      }
      getServletContext().log("Json response: " + rsp.toString());
      // Reply the Json response
      response.setContentType(Configuration.jsonContentType);
      response.setCharacterEncoding(Configuration.contentEncoding);
      PrintWriter out = response.getWriter();
      out.print(rsp.toString());
      out.flush();
    } catch (AuthenticationException ex) {
      getServletContext().log("Unauthenticated", ex);
      response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
      return;
View Full Code Here

        getServletContext().log(
            "No group.", ex);
      }

      // Create Json response
      JsonArray rsp = new JsonArray();
      for (Group group: groups) {
        // RBAC on the group
        AccessController.checkAuthorization(group, request, Action.browse, null);

        rsp.addItem(group.getGroupName());
      }
      getServletContext().log("Json response: " + rsp.toString());
      // Reply the Json response
      response.setContentType(Configuration.jsonContentType);
      response.setCharacterEncoding(Configuration.contentEncoding);
      PrintWriter out = response.getWriter();
      out.print(rsp.toString());
      out.flush();
    } catch (Exception ex) {
      getServletContext().log("Cannot GET group list", ex);
      response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      return;
View Full Code Here

TOP

Related Classes of org.myphotodiary.json.JsonArray

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.