Package models

Examples of models.Photo$Image


        }

        System.out.println(" =========  images ======== ");
        List<Image> images = artist.getImages();
        for (int i = 0; i < images.size(); i++) {
            Image image = images.get(i);
            image.dump();
        }

        System.out.println(" =========  news ======== ");
        List<News> newsList = artist.getNews();
        for (int i = 0; i < newsList.size(); i++) {
View Full Code Here


    request = newRequest();
    request.cookies.putAll(cookies);
    response =  POST(request, "/api/me/photos", parameters, files);
    String location = response.getHeader("location");
    assertNotNull(location);
    Photo photo = JsonParserHelper.toPhoto(response.out.toByteArray());
    assertTrue("El propietario de la foto tiene que ser Eva perez.", photo.owner.username.equals(from));
   
    //Se verifica que Juan Gomez a subida una imagen a batzen
    request = newRequest();
    request.cookies.putAll(cookies);
View Full Code Here

    request = newRequest();
        request.cookies.putAll(cookies);
    response =  POST(request, "/api/me/photos", parameters, files);
    String location = response.getHeader("location");
    assertNotNull(location);
    Photo photo = JsonParserHelper.toPhoto(response.out.toByteArray());
    assertTrue("El propietario de la foto tiene que ser Juan Gomez.", photo.owner.username.equals(from));
   
    //Se verifica que Juan Gomez a subida una imagen a batzen
    request = newRequest();
        request.cookies.putAll(cookies);
View Full Code Here

 
  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

    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

    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

      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

    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

        String fileName = System.currentTimeMillis() + "_" + Filedata.getName();
        User user = User.filter("_id", new ObjectId(userId)).first();
        // 存储到数据库
        Marker marker = Marker.filter("_id", new ObjectId(markerId)).first();
        if (marker != null && user != null) {
            Photo photo = new Photo(marker, fileName);
            photo.save();
            // 存储文件
            File file = new File(FileUtils.getApplicationPath("data") + fileName);
            Images.resize(Filedata, file, -1, 550);
            Filedata.delete();
        } else {
View Full Code Here

    }

    @Secure(login = true)
    public static void delete(String name, String markerId) {
        Marker m = Marker.filter("_id", new ObjectId(markerId)).first();
        Photo p = Photo.filter("name", name).first();
        new File(FileUtils.getApplicationPath("data") + name).delete();
        String nextImage = "";
        Photo next = Photo.filter("marker", m).filter("name > ", name).order("name").first();
        Photo prev = Photo.filter("marker", m).filter("name < ", name).order("-name").first();
        if (next != null) {
            nextImage = next.name;
        } else if (prev != null) {
            nextImage = prev.name;
        }
View Full Code Here

TOP

Related Classes of models.Photo$Image

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.