Examples of Photo


Examples of com.skyline.wo.model.Photo

      return result;
    }
    result.put("logined", Boolean.TRUE);

    try {
      Photo photo = albumService.getPhotoForChange(user.getId(), photoId);
      albumService.changeAlbumCover(user.getId(), photo.getAlbumId(), photo.getSmallFile(),
          photo.getExt());
      result.put("success", Boolean.TRUE);
      result.put("errmsg", "设置相册封面成功");
      return result;
    } catch (Exception e) {
      LOGGER.error("设置相册封面失败", e);
View Full Code Here

Examples of com.skyline.wo.model.Photo

      if (user != null) {
        viewerId = user.getId();
        // FIXME 判断是否需要增加访问量
      }
      int authority = AuthorityUtil.getAuthority(null, viewerId);
      Photo photo = albumService.getPhotoDetailById(photoId, viewerId, addVisitCount);
      // 判断权限
      if (photo != null) {
        int albumAuth = photo.getAuthority();
        if (authority < albumAuth) {
          LOGGER.warn("用户ID" + viewerId + "没有访问ID为" + photo.getId() + "图片的权限");
          result.put("success", Boolean.FALSE);
          result.put("errmsg", "您没有查看该图片的权限");
          return result;
        }
      }
View Full Code Here

Examples of com.skyline.wo.model.Photo

    }
    result.put("logined", Boolean.TRUE);

    try {
      Long ownerId = user.getId();
      Photo photo = albumService.getPhotoForChange(ownerId, photoId);
      Album portraitAlbum = albumService.getUserPortraitAlbum(ownerId);
      Long albumId = portraitAlbum.getId();
      String photoExt = photo.getExt();
      String remoteFileKey = photo.getSmallFile() + '.' + photoExt;
      if (SkylineImagineUtils.isExtMultiFrame(photoExt)) {// 如果是动态图,需要压缩成单帧图
        remoteFileKey = photo.getMiddleFile() + '.' + photoExt;
        String filename = FilenameUtils.getName(remoteFileKey);
        String fileKey = SkylineImagineUtils.generateFileKey(ownerId.toString(),
            albumId.toString(), filename);
        String localFile = SkylineImagineUtils.generateFilePath(localStorePath, ownerId,
            albumId, fileKey + '.' + photoExt);
        File destFile = new File(localFile);

        File dir = destFile.getParentFile();
        if (!dir.exists()) {
          boolean success = dir.mkdirs();
          if (!success && !dir.exists()) {
            LOGGER.warn("mkdirs :" + dir + " failed");
          }
        }
        // 保存服务器上的图片到本地目标文件
        if (fileOperator == null) {
          String srcFile = localStorePath + '/' + remoteFileKey;
          FileUtils.copyFile(new File(srcFile), destFile);
        } else {
          fileOperator.downloadFile(remoteFileKey, localFile);
        }
        // 压缩该目标图片
        LocalImageResizeTask task = new LocalImageResizeTask(localFile, baseSizes);
        task.setAlbumId(albumId);
        task.setUserId(ownerId);
        task.setSupportMulitFrame(false);
        ImageResizeResult resizeResult = imagine.processSingleImage(localStorePath, task);
        Photo portrait = albumService
            .createPortraitPhoto(user, portraitAlbum, resizeResult);
        remoteFileKey = portrait.getSmallFile() + '.' + portrait.getExt();
      } else {
        albumService.copyPhotoToPortraitAlbum(portraitAlbum, photo);
      }

      SkylineImageCropTask cropTask = new SkylineImageCropTask(remoteFileKey, portraitSize);
View Full Code Here

Examples of com.skyline.wo.model.Photo

      return v;
    }
    Spot spot = spotService.getSpot(spotId);
    if (spot.getAdministratorId().equals(user.getId())) {
      Album portraitAlbum = albumService.getUserPortraitAlbum(spotId);
      Photo portraitPhoto = albumService.getCurrentPortraitPhotoFromAlbum(portraitAlbum);
      v.addObject("portraitAlbumId", portraitAlbum.getId());
      v.addObject("portrait", portraitPhoto);
      v.addObject("spotInfo", spot);
      v.setViewName(ViewPaths.SPOT_EDITPORTRAIT);
    }
View Full Code Here

Examples of com.skyline.wo.model.Photo

    String errMsg = this.validateForm("portraitUploadForm", submitToken);
    if (errMsg != null) {
      return processValidationErrors("errMsg", errMsg, photoUploadRequest());
    }
    Photo portrait = albumService.getUserCurrentPortraitPhoto(spotId);
    if (portrait == null) {
      throw new OperateFailedException("不存在当前图片,无法剪切");
    }
    long albumId = portrait.getAlbumId();

    String smallFile = portrait.getSmallFile();
    String ext = portrait.getExt();
    String remoteFileKey = smallFile + '.' + ext;

    SkylineImageCropTask cropTask = new SkylineImageCropTask(remoteFileKey, portraitSize);
    cropTask.setAlbumId(albumId);
    cropTask.setUserId(spotId);
View Full Code Here

Examples of com.skyline.wo.model.Photo

      throw new NotLoginException("上传头像必须登录");
    }

    long ownerId = user.getId();
    Album portraitAlbum = albumService.getUserPortraitAlbum(ownerId);
    Photo portraitPhoto = albumService.getCurrentPortraitPhotoFromAlbum(portraitAlbum);

    ModelAndView view = new ModelAndView();
    view.addObject("portraitAlbum", portraitAlbum);
    view.addObject("portrait", portraitPhoto);
    // view.setViewName(photoUploadView);
View Full Code Here

Examples of com.skyline.wo.model.Photo

  @Override
  public Photo getPhotoDetailById(long photoId, long viewerId, boolean addVisit) {
    if (photoId == 0) {
      throw new NoResourceException("Id为0的图片不存在");
    }
    Photo photo = photoDao.queryPhotoDetailById(photoId);
    if (photo == null) {
      throw new NoResourceException("Id为" + photoId + "的图片不存在");
    }
    Activity act = photo.getActivity();
    if (act == Activity.DELETED || act == Activity.FREEZED) {
      throw new NoResourceException("Id为" + photoId + "的照片已删除或者已被屏蔽");
    }
    if (addVisit && photo.getOwnerId() != viewerId) {
      photoDao.updateVisitCount(photo.getAlbumId(), photoId, 1);
    }
    return photo;
  }
View Full Code Here

Examples of com.skyline.wo.model.Photo

      ImageResizeResult result = filesInfo.get(i);
      String[] keys = result.getFileKeys();
      if(ids.get(i) == null) {//返回为空,表示插入失败
        continue;
      }
      Photo photo = new Photo();
      photo.setId(ids.get(i));
      photo.setOwnerId(userId);
      photo.setOwnerNickname(userNickname);
      photo.setOwnerPortrait(userPortrait);
      photo.setAlbumId(albumId);
      photo.setAlbumName(albumName);
      photo.setAuthority(authority);
      photo.setActivity(activity);
      photo.setFile(keys[0]);
      photo.setMiddleFile(keys[1]);
      photo.setSmallFile(keys[2]);
      photo.setExt(result.getExt());
      photo.setSize(result.getFileSize());
      photos.add(photo);
    }
    return photos;
  }
View Full Code Here

Examples of com.skyline.wo.model.Photo

    albumDao.updatePhotoCount(ownerId, fromAlbumId, -1);
  }

  @Override
  public Long deletePhoto(long userId, long photoId) {
    Photo photo = photoDao.queryPhotoById(photoId);
    if (photo.getOwnerId() == userId) {
      Activity oldActivity = photo.getActivity();
      if (oldActivity == Activity.NORMAL) {// 只能删除普通相册
        Long albumId = photo.getAlbumId();
        String file = photo.getSmallFile();
        Album album = albumDao.queryAlbumById(albumId);
        if (album.getOwnerId() != userId) {
          throw new NoOperatePermissionException("ID为" + userId + "的用户没有修改ID为" + albumId
              + "相册的权限");
        }
View Full Code Here

Examples of com.skyline.wo.model.Photo

    }
  }

  @Override
  public Photo getPhotoForChange(long userId, long photoId) {
    Photo photo = photoDao.queryPhotoDetailById(photoId);
    if(photo == null) {
      throw new NoResourceException("Id为" + photoId + "的图片不存在!");
    }
    if (photo.getOwnerId() != userId) {
      throw new NoOperatePermissionException("Id为" + userId + "的用户没有修改Id为" + photoId
          + "图片的权限");
    }
    return photo;
  }
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.