Examples of Photo


Examples of models.Photo

 
  public static void add(Upload data) throws IOException {
    //TO-DO Security control check.
    String key = GAEFileService.createFile(MimeTypes.getContentType(data.getFileName()), data.getFileName(),data.asBytes());
    User currentUser = getCurrentUser();
    Photo photo = new Photo();
    photo.filename = data.getFileName();
    photo.owner = currentUser;
    response.status = StatusCode.CREATED;
    Map map = new HashMap();
    map.put("key", key);
    String url = Router.reverse("api.Files.serve", map).url;
    Image original = photo.new Image();
    original.key = key;
    original.source = url;
    original.height = 100;
    original.width = 50;
    photo.original = original;
    photo.insert();
    map = new HashMap();
    map.put("id", photo.id);
    url = Router.reverse("api.Photos.get", map).url;
    response.setHeader("location", url);
    renderJSON(gson().toJson(photo));
View Full Code Here

Examples of models.Photo

    response.setHeader("location", url);
    renderJSON(gson().toJson(photo));
    }
 
  public static void get(Long id) {
    Photo photo = Photo.findById(id);
    if(photo == null) {
      notFound();
    }
    User currentUser = getCurrentUser();
    if(photo.owner.id!=currentUser.id &&
View Full Code Here

Examples of models.Photo

    renderJSON(gson().toJson(photo));
  }
 
  public static void delete(Long id) {
    User currentUser = getCurrentUser();
    Photo photo = Photo.findById(id);
    if(photo == null) notFound();
    if(photo.owner.id!=currentUser.id) forbidden();
    photo.delete();
    response.status = StatusCode.NO_RESPONSE;
  }
View Full Code Here

Examples of models.Photo

      String[] imageData = image.split(",");
      try {
      byte[] imageBytes = Base64.decode(imageData[imageData.length-1]);
      String key = GAEFileService.createFile(MimeTypes.getContentType("me-"+System.currentTimeMillis()), "me-"+System.currentTimeMillis(),imageBytes);
      User currentUser = getCurrentUser();
      Photo photo = new Photo();
      photo.filename = "me-"+System.currentTimeMillis();
      photo.owner = currentUser;
      response.status = StatusCode.CREATED;
      Map map = new HashMap();
      map.put("key", key);
      String url = Router.reverse("api.Files.serve", map).url;
      Image original = photo.new Image();
      original.key = key;
      original.source = url;
      original.height = 100;
      original.width = 50;
      photo.original = original;
      photo.insert();
      map = new HashMap();
      map.put("id", photo.id);
      url = Router.reverse("api.Photos.get", map).url;
      response.setHeader("location", url);
      renderJSON(gson().toJson(photo));
View Full Code Here

Examples of models.Photo

    response = GET(location);
    assertStatus(StatusCode.OK, response);
    dataType = new TypeToken<Photo>(){}.getType();
    is = new ByteArrayInputStream(response.out.toByteArray());
    reader = new InputStreamReader(is);
    Photo photo = new Gson().fromJson(reader, dataType);
    response = GET(photo.original.source);
    assertStatus(StatusCode.OK, response);
    is = new ByteArrayInputStream(response.out.toByteArray());
    File newFile =new File("atom-returned.jpeg");
    FileOutputStream fos = new FileOutputStream(newFile);
View Full Code Here

Examples of org.albertsanso.web20.core.model.Photo

    art.setName("article3");
    art.setSummary("Aquest es l'article 3");
    em.persist(art);

   
    Photo photo = new Photo();
    photo.setComment("vaya fotito...");
    photo.setName("foto borracho");
    em.persist(photo);


    NominalAttribute wineColor = new NominalAttribute();
    wineColor.setName("color");
View Full Code Here

Examples of org.apache.olingo.odata2.annotation.processor.core.model.Photo

  @Test
  public void readBinaryData() throws Exception {
    EdmEntitySet entitySet = createMockedEdmEntitySet("Photos");

    DataStore<Photo> photoDataStore = datasource.getDataStore(Photo.class);
    Photo photo = new Photo();
    photo.setName("SomePic");
    photo.setType("PNG");
    byte[] image = "binary".getBytes(Charset.defaultCharset());
    photo.setImage(image);
    photo.setImageType("image/png");
    photoDataStore.create(photo);

    Map<String, Object> keys = new HashMap<String, Object>();
    keys.put("Name", "SomePic");
    keys.put("ImageFormat", "PNG");
    Photo toReadPhoto = (Photo) datasource.readData(entitySet, keys);

    // execute
    BinaryData readBinaryData = datasource.readBinaryData(entitySet, toReadPhoto);

    // validate
View Full Code Here

Examples of org.apache.olingo.odata2.annotation.processor.ref.model.Photo

    b.setName(buildingName);
    return b;
  }

  private static Photo createPhoto(final String name, final ResourceHelper.Format format) {
    Photo p = new Photo();
    p.setName(name);
    p.setImageUri("http://localhost/image/" + name);
    p.setType(format.name());
    p.setImageType("image/" + format.name().toLowerCase());
    p.setImage(ResourceHelper.generateImage(format));
    return p;
  }
View Full Code Here

Examples of org.apache.olingo.odata2.ref.model.Photo

    field.setAccessible(true);
    DataContainer dataContainer = (DataContainer) field.get(dataSource);
    // Add a new Photo where the "Type" property is set to, space-separated,
    // a literal percent character, all gen-delims, and all sub-delims
    // as specified by RFC 3986.
    dataContainer.getPhotos().add(new Photo(42, "strange Photo", "% :/?#[]@ !$&'()*+,;="));

    // Check that percent-decoding and -encoding works as expected.
    final String url =
        "Container2.Photos(Id=42,Type='%25%20%3A%2F%3F%23%5B%5D%40%20%21%24%26%27%28%29%2A%2B%2C%3B%3D')";
    final String expected = url.replace("%27", "''");
View Full Code Here

Examples of org.brickred.socialauth.Photo

    if (root != null) {
      NodeList photoList = root.getElementsByTagName("entry");
      if (photoList != null && photoList.getLength() > 0) {
        LOG.info("Found photos : " + photoList.getLength());
        for (int i = 0; i < photoList.getLength(); i++) {
          Photo photo = new Photo();
          Element pl = (Element) photoList.item(i);

          NodeList pid = pl.getElementsByTagNameNS(ALBUM_NAMESPACE,
              "id");
          String photoId = XMLParseUtil.getElementData(pid.item(0));
          photo.setId(photoId);

          photo.setTitle(XMLParseUtil.getElementData(pl, "title"));

          NodeList mediaGroup = pl.getElementsByTagNameNS(
              MEDIA_NAMESPACE, "group");
          String urlLarge = null;
          String urlMedium = null;
          String urlSmall = null;
          String urlThumb = null;
          int width = 0;

          if (mediaGroup != null && mediaGroup.getLength() > 0) {
            Element el = (Element) mediaGroup.item(0);
            if (el != null) {
              NodeList content = el.getElementsByTagNameNS(
                  MEDIA_NAMESPACE, "content");
              if (content != null) {
                Element cl = (Element) content.item(0);
                if (cl != null) {
                  urlLarge = cl.getAttribute("url");
                }
              }

              NodeList thumbnail = el.getElementsByTagNameNS(
                  MEDIA_NAMESPACE, "thumbnail");
              if (thumbnail != null && thumbnail.getLength() > 0) {
                for (int k = 0; k < thumbnail.getLength(); k++) {
                  Element thumb = (Element) thumbnail.item(k);
                  if (thumb != null) {
                    width = Integer.parseInt(thumb
                        .getAttribute("width"));
                    if (width == 288) {
                      urlMedium = thumb
                          .getAttribute("url");
                    } else if (width == 144) {
                      urlSmall = thumb
                          .getAttribute("url");
                    } else if (width == 72) {
                      urlThumb = thumb
                          .getAttribute("url");
                    }
                  }
                }
              }
            }
          }
          photo.setLargeImage(urlLarge);
          photo.setMediumImage(urlMedium);
          photo.setSmallImage(urlSmall);
          photo.setThumbImage(urlThumb);

          photos.add(photo);
        }
      } else {
        LOG.info("No photos were obtained from : " + PHOTOS_URL);
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.