Package com.skyline.wo.model

Examples of com.skyline.wo.model.Photo


    }

  }

  private void addPhotoShare(Long sharerId, String sharerNickname, String sharerPortrait, Long resourceId) {
    Photo photo = albumService.getPhotoDetailById(resourceId, sharerId, true);// (resourceId);
    if (photo != null) {
      Map<String, Object> valueMap = new HashMap<String, Object>();
      valueMap.put("middlefile", photo.getMiddleFile());
      valueMap.put("ext", photo.getExt());
      String digest = FreeMarkerUtils.getShare(ShareType.PHOTO, valueMap);
      shareDao.insertShare(sharerId, sharerNickname, sharerPortrait, ShareType.PHOTO, resourceId, photo.getAlbumName(), digest,
          photo.getOwnerId(), photo.getOwnerNickname(), photo.getOwnerPortrait(), photo.getAlbumId(), photo.getAlbumName());
    }
  }
View Full Code Here


      viewerId = user.getId();
      // 此处不增加浏览数,统一在通过ajax方式获取图片信息是处理
    }
    int authority = AuthorityUtil.getAuthority(null, viewerId);

    Photo photo = albumService.getPhotoDetailById(photoId, viewerId, addVisitCount);
    // 判断权限
    if (photo != null) {
      int albumAuth = photo.getAuthority();
      if (authority < albumAuth) {
        throw new NoVisitPermissionException("ID为:" + viewerId + "的用户没有访问ID为:"
            + photo.getId() + "图片的权限");
      }
    } else {
      throw new NoResourceException("ID为:" + photoId + "的图片不存在");
    }
    List<Photo> photos = albumService.listPhotoFilesOfAlbum(photo.getAlbumId(), authority);

    ModelAndView mav = new ModelAndView(ViewPaths.ALBUM_VIEWPHOTO);
    mav.addObject("photo", photo);
    mav.addObject("photos", photos);
View Full Code Here

      throw new NotLoginException("编辑照片信息必须登录");
    }
    long userId = user.getId();

    List<Album> albums = albumService.listAlbumNamesOfUser(userId);
    Photo photo = albumService.getPhotoForChange(userId, photoId);

    ModelAndView mav = new ModelAndView(ViewPaths.ALBUM_EDITPHOTO);
    mav.addObject("photo", photo);
    mav.addObject("albums", albums);

    Long curAlbumId = photo.getAlbumId();
    for (Album album : albums) {
      if (album.getId().equals(curAlbumId)) {
        mav.addObject("cover", album.getCover());
      }
    }
View Full Code Here

      ModelAndView returnMav = editPhoto(photoId);
      return processValidationErrors("errMsg", errMsg, returnMav);
    }

    long userId = user.getId();
    Photo photo = albumService.getPhotoForChange(userId, photoId);
    Album origAlbum = albumService.getAlbumForChange(photo.getAlbumId(), userId);
    if (setCover == null) {
      if (!photo.getAlbumId().equals(toAlbum)) {
        albumService.changePhotoAlbum(userId, photoId, photo.getAlbumId(), toAlbum);
        if (origAlbum.getCover().equals(photo.getSmallFile())) {// 取消原有封面
          albumService.changeAlbumCover(userId, photo.getAlbumId(), cover, ext);
        }
      }
    } else {
      albumService.changeAlbumCover(userId, photo.getAlbumId(), photo.getSmallFile(),
          photo.getExt());
    }
    String oldDesc = CommonUtils.nullStringToEmpty(photo.getDescription());
    if (!oldDesc.equals(description)) {
      albumService.changePhotoDescription(photo.getAlbumId(), photoId, description);
    }

    String url = buildRecirectPath(URL_PREFIX + "/photo/" + photoId);
    ModelAndView mav = new ModelAndView(new RedirectView(url));
    return mav;
View Full Code Here

      result.put("errmsg", errorMsgs[0]);
      return result;
    }

    try {
      Photo photo = albumService.getPhotoForChange(user.getId(), photoId);
      String oldDesc = CommonUtils.nullStringToEmpty(photo.getDescription());
      if (!oldDesc.equals(description)) {
        albumService.changePhotoDescription(photo.getAlbumId(), photoId, description);
      }
      result.put("success", Boolean.TRUE);
      result.put("errmsg", "修改照片描述成功");
      return result;
    } catch (Exception e) {
View Full Code Here

      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

      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

    }
    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

      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

    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

TOP

Related Classes of com.skyline.wo.model.Photo

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.