Example #1
0
 @Override
 public void initMenus() {
   List<SelectItem> sortMenu = new ArrayList<SelectItem>();
   sortMenu.add(new SelectItem(null, "--"));
   sortMenu.add(
       new SelectItem(SearchIndex.names.created, sb.getLabel(SearchIndex.names.created.name())));
   sortMenu.add(
       new SelectItem(SearchIndex.names.modified, sb.getLabel(SearchIndex.names.modified.name())));
   setSortMenu(sortMenu);
 }
 /**
  * Change the language of imeji
  *
  * @param languageString
  */
 private void changeLanguage(String languageString) {
   if (isSupported(languageString)) {
     currentLanguage = languageString;
   } else {
     currentLanguage = getRequestedLocale().getLanguage();
   }
   session.setLocale(new Locale(currentLanguage));
   CookieUtils.updateCookieValue(SessionBean.langCookieName, session.getLocale().getLanguage());
   internationalizeLanguages();
 }
Example #3
0
 /**
  * Withdraw the current {@link CollectionImeji}
  *
  * @return
  * @throws Exception
  */
 public String withdraw() throws Exception {
   CollectionController cc = new CollectionController();
   try {
     cc.withdraw(collection, sb.getUser());
     BeanHelper.info(sb.getMessage("success_collection_withdraw"));
   } catch (Exception e) {
     BeanHelper.error(sb.getMessage("error_collection_withdraw"));
     BeanHelper.error(e.getMessage());
     logger.error("Error discarding collection", e);
   }
   return "pretty:";
 }
Example #4
0
 /**
  * Delete the current {@link CollectionImeji}
  *
  * @return
  */
 public String delete() {
   CollectionController cc = new CollectionController();
   try {
     cc.delete(collection, sb.getUser());
     BeanHelper.info(sb.getMessage("success_collection_delete"));
   } catch (Exception e) {
     BeanHelper.error(sb.getMessage("success_collection_delete"));
     BeanHelper.error(e.getMessage());
     logger.error("Error deleting collection", e);
   }
   return "pretty:collections";
 }
Example #5
0
 /**
  * Release the current {@link CollectionImeji}
  *
  * @return
  */
 public String release() {
   CollectionController cc = new CollectionController();
   try {
     cc.release(collection, sb.getUser());
     BeanHelper.info(sb.getMessage("success_collection_release"));
   } catch (Exception e) {
     BeanHelper.error(sb.getMessage("error_collection_release"));
     BeanHelper.error(e.getMessage());
     logger.error("Error releasing collection", e);
   }
   return "pretty:";
 }
Example #6
0
 /** Load the collection */
 public void loadCollection() {
   if (id != null) {
     collection =
         ObjectLoader.loadCollectionLazy(
             ObjectHelper.getURI(CollectionImeji.class, id), sessionBean.getUser());
     if (collection != null && getCollection().getId() != null) {
       ItemController ic = new ItemController(sessionBean.getUser());
       collectionSize = ic.countContainerSize(collection.getId());
     }
   } else {
     BeanHelper.error(sessionBean.getLabel("error") + "No ID in URL");
   }
 }
Example #7
0
 /**
  * Initialize the elements of the page
  *
  * @return
  */
 @Override
 public String getInitPage() {
   uri = ObjectHelper.getURI(CollectionImeji.class, id);
   collection = ObjectLoader.loadCollectionLazy(uri, sb.getUser());
   browseInit();
   browseContext = getNavigationString() + id;
   return "";
 }
 /** Initialize the bean */
 public void init() {
   try {
     Iso639_1Helper iso639_1Helper = new Iso639_1Helper();
     isolanguages = iso639_1Helper.getList();
     initLanguagesMenu();
     changeLanguage(session.getLocale().getLanguage());
   } catch (Exception e) {
     LOGGER.error("Error Intializing InternationalitationBean:", e);
   }
 }
Example #9
0
 /**
  * Throws an {@link Exception} if the file ca be upload. Works only if the file has an extension
  * (therefore, for file without extension, the validation will only occur when the file has been
  * stored locally)
  */
 private void validateName() {
   if (StorageUtils.hasExtension(title)) {
     if (checkNameUnique) {
       // if the checkNameUnique is checked, check that two files with the same name is not
       // possible
       if ((importImageToFile || uploadFileToItem) && filenameExistsInCurrentUpload())
         throw new RuntimeException("There is already at least one item with the filename ");
       else if (!((importImageToFile || uploadFileToItem)) && filenameExistsInCollection(title)
           || filenameExistsInCurrentUpload())
         throw new RuntimeException(
             "There is already at least one item with the filename "
                 + FilenameUtils.getBaseName(title));
     }
     if (!isAllowedFormat(FilenameUtils.getExtension(title)))
       throw new RuntimeException(
           sessionBean.getMessage("upload_format_not_allowed")
               + " ("
               + FilenameUtils.getExtension(title)
               + ")");
   }
 }
Example #10
0
 @Override
 public SearchResult search(SearchQuery searchQuery, SortCriterion sortCriterion) {
   ItemController controller = new ItemController(sb.getUser());
   return controller.search(uri, searchQuery, sortCriterion, null);
 }
Example #11
0
 @Override
 public boolean isDeletable() {
   Security security = new Security();
   return security.check(OperationsType.DELETE, sb.getUser(), collection);
 }
Example #12
0
 @Override
 public boolean isVisible() {
   Security security = new Security();
   return security.check(OperationsType.READ, sb.getUser(), collection);
 }
Example #13
0
 /**
  * true if current {@link User} can UPDATE the {@link CollectionImeji}
  *
  * @return
  */
 public boolean isEditable() {
   Security security = new Security();
   return security.check(OperationsType.UPDATE, sessionBean.getUser(), collection);
 }
Example #14
0
 public User getUser() {
   return sessionBean.getUser();
 }