示例#1
0
 public ImageBean() throws Exception {
   image = new Image();
   sessionBean = (SessionBean) BeanHelper.getSessionBean(SessionBean.class);
   navigation = (Navigation) BeanHelper.getApplicationBean(Navigation.class);
   prettyLink = "pretty:editImage";
   labels = (MetadataLabels) BeanHelper.getSessionBean(MetadataLabels.class);
 }
示例#2
0
 public String select() {
   if (!selected) {
     ((SessionBean) BeanHelper.getSessionBean(SessionBean.class))
         .getSelected()
         .remove(image.getId());
   } else {
     ((SessionBean) BeanHelper.getSessionBean(SessionBean.class)).getSelected().add(image.getId());
   }
   return "";
 }
示例#3
0
 public void loadImage() {
   try {
     image = ObjectLoader.loadImage(ObjectHelper.getURI(Image.class, id), sessionBean.getUser());
   } catch (NotFoundException e) {
     image = new Image();
     BeanHelper.error(
         sessionBean.getLabel("image") + " " + id + sessionBean.getLabel("not_found"));
   } catch (Exception e) {
     BeanHelper.error(sessionBean.getMessage("error_image_load"));
     logger.error(sessionBean.getMessage("error_image_load"), e);
   }
 }
示例#4
0
 public ImageBean(Image img) throws Exception {
   image = img;
   sessionBean = (SessionBean) BeanHelper.getSessionBean(SessionBean.class);
   navigation = (Navigation) BeanHelper.getApplicationBean(Navigation.class);
   prettyLink = "pretty:editImage";
   labels = (MetadataLabels) BeanHelper.getSessionBean(MetadataLabels.class);
   if (sessionBean.getSelected().contains(image.getId())) {
     setSelected(true);
   }
   loadProfile();
   removeDeadMetadata();
   sortMetadataAccordingtoProfile();
 }
示例#5
0
 public String removeFromAlbum() throws Exception {
   AlbumImagesBean aib = (AlbumImagesBean) BeanHelper.getSessionBean(AlbumImagesBean.class);
   AlbumController ac = new AlbumController(sessionBean.getUser());
   aib.getAlbum().getAlbum().getImages().remove(image.getId());
   ac.update(aib.getAlbum().getAlbum());
   if (getIsInActiveAlbum())
     sessionBean.getActiveAlbum().getAlbum().getImages().remove(image.getId());
   BeanHelper.info(
       sessionBean.getLabel("image")
           + " "
           + image.getFilename()
           + " "
           + sessionBean.getMessage("success_album_remove_from"));
   return "pretty:";
 }
示例#6
0
 public void loadProfile() {
   try {
     profile = sessionBean.getProfileCached().get(image.getMetadataSet().getProfile());
     if (profile == null) {
       profile =
           ObjectLoader.loadProfile(image.getMetadataSet().getProfile(), sessionBean.getUser());
     }
     if (profile == null) {
       profile = new MetadataProfile();
     }
   } catch (Exception e) {
     BeanHelper.error(
         sessionBean.getMessage("error_profile_load")
             + " "
             + image.getMetadataSet().getProfile()
             + "  "
             + sessionBean.getLabel("of")
             + " "
             + image.getId());
     profile = new MetadataProfile();
     logger.error(
         "Error load profile "
             + image.getMetadataSet().getProfile()
             + " of image "
             + image.getId(),
         e);
   }
 }
示例#7
0
 public void loadCollection() {
   try {
     collection = ObjectLoader.loadCollection(getImage().getCollection(), sessionBean.getUser());
   } catch (Exception e) {
     BeanHelper.error(e.getMessage());
     e.printStackTrace();
     collection = null;
   }
 }
示例#8
0
  public String getEmailSubject(boolean newAccount) {
    SessionBean session = (SessionBean) BeanHelper.getSessionBean(SessionBean.class);
    String emailsubject = "";

    if (newAccount) {
      emailsubject = session.getMessage("email_new_user_subject");
    } else {
      emailsubject = session.getMessage("email_new_password_subject");
    }

    return emailsubject;
  }
示例#9
0
  private String getEmailMessage(
      String password, String email, String username, String message_bundle) {
    Navigation navigation = (Navigation) BeanHelper.getApplicationBean(Navigation.class);
    SessionBean session = (SessionBean) BeanHelper.getSessionBean(SessionBean.class);
    String userPage = navigation.getApplicationUrl() + "user?id=" + email;

    String emailMessage = session.getMessage(message_bundle);

    if ("email_new_user".equals(message_bundle)) {
      emailMessage =
          emailMessage.replace("XXX_LINK_TO_APPLICATION_XXX", navigation.getApplicationUrl());
    }

    emailMessage =
        emailMessage
            .replace("XXX_USER_NAME_XXX,", username)
            .replace("XXX_LOGIN_XXX", email)
            .replace("XXX_PASSWORD_XXX", password)
            .replace("XXX_LINK_TO_USER_PAGE_XXX", userPage);

    return emailMessage;
  }
示例#10
0
  public void selectedChanged(ValueChangeEvent event) {
    sessionBean = (SessionBean) BeanHelper.getSessionBean(SessionBean.class);

    if (event.getNewValue().toString().equals("true")
        && !sessionBean.getSelected().contains(image.getId())) {
      setSelected(true);
      select();
    } else if (event.getNewValue().toString().equals("false")
        && sessionBean.getSelected().contains(image.getId())) {
      setSelected(false);
      select();
    }
  }
示例#11
0
 public String addToActiveAlbum() throws Exception {
   AlbumBean activeAlbum = sessionBean.getActiveAlbum();
   AlbumController ac = new AlbumController(sessionBean.getUser());
   if (activeAlbum.getAlbum().getImages().contains(image.getId())) {
     BeanHelper.error(
         ((SessionBean) BeanHelper.getSessionBean(SessionBean.class)).getLabel("image")
             + " "
             + image.getFilename()
             + " "
             + ((SessionBean) BeanHelper.getSessionBean(SessionBean.class))
                 .getMessage("already_in_active_album"));
   } else {
     activeAlbum.getAlbum().getImages().add(image.getId());
     ac.update(activeAlbum.getAlbum());
     BeanHelper.info(
         ((SessionBean) BeanHelper.getSessionBean(SessionBean.class)).getLabel("image")
             + " "
             + image.getFilename()
             + " "
             + ((SessionBean) BeanHelper.getSessionBean(SessionBean.class))
                 .getMessage("added_to_active_album"));
   }
   return "";
 }
示例#12
0
 private String getBundle(String messageBundle) {
   SessionBean session = (SessionBean) BeanHelper.getSessionBean(SessionBean.class);
   return session.getMessage(messageBundle);
 }
示例#13
0
 public boolean getSelected() {
   sessionBean = (SessionBean) BeanHelper.getSessionBean(SessionBean.class);
   if (image != null && sessionBean.getSelected().contains(image.getId())) selected = true;
   else selected = false;
   return selected;
 }
示例#14
0
 public void initBrowsing() {
   browse = new SingleImageBrowse((ImagesBean) BeanHelper.getSessionBean(ImagesBean.class), image);
 }