public MdProfileBean() { collectionSession = (CollectionSessionBean) BeanHelper.getSessionBean(CollectionSessionBean.class); sessionBean = (SessionBean) BeanHelper.getSessionBean(SessionBean.class); if (collectionSession.getProfile() == null) { collectionSession.setProfile(new MetadataProfile()); } profile = collectionSession.getProfile(); statements = new ArrayList<StatementWrapper>(); pc = new ProfileController(sessionBean.getUser()); initMenus(); }
/** * 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:"; }
/** * 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:"; }
/** * 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"; }
/** * Method called when the user changed the language. The new language is setted via the listener. * The method reload the current page * * @return * @throws IOException */ public String changeLanguage() throws IOException { HistorySession history = (HistorySession) BeanHelper.getSessionBean(HistorySession.class); FacesContext.getCurrentInstance() .getExternalContext() .redirect(history.getCurrentPage().getCompleteUrl()); return "pretty:"; }
/** Method checking the url parameters and triggering then the {@link UploadBean} methods */ public void status() { if (UrlHelper.getParameterBoolean("init")) { importImageToFile = false; uploadFileToItem = false; checkNameUnique = true; removeFiles(); loadCollection(); ((AuthorizationBean) BeanHelper.getSessionBean(AuthorizationBean.class)).init(collection); totalNum = ""; sNum = 0; fNum = 0; sFiles = new ArrayList<String>(); fFiles = new ArrayList<String>(); externalUrl = ""; } else if (UrlHelper.getParameterBoolean("start")) { try { upload(); } catch (Exception e) { logger.error("Error upload", e); } } else if (UrlHelper.getParameterBoolean("done")) { try { if (importImageToFile || uploadFileToItem) updateItemForFiles(); else createItemForFiles(); totalNum = UrlHelper.getParameterValue("totalNum"); loadCollection(); report(); } catch (Exception e) { logger.error("Error upload", e); e.printStackTrace(); } } super.setCollection(collection); }
public void initMenus() { mdTypesMenu = new ArrayList<SelectItem>(); mdTypesMenu.add(new SelectItem(null, sessionBean.getLabel("select"))); for (Metadata.Types t : Metadata.Types.values()) { mdTypesMenu.add( new SelectItem( t.getClazzNamespace(), ((SessionBean) BeanHelper.getSessionBean(SessionBean.class)) .getLabel("facet_" + t.name().toLowerCase()))); } }
public boolean validateProfile(MetadataProfile profile) { List<String> statementNames = new ArrayList<String>(); if (profile.getStatements() == null) { BeanHelper.error(sessionBean.getLabel("profile_empty")); return false; } int i = 0; for (Statement s : profile.getStatements()) { for (LocalizedString ls : s.getLabels()) { if (ls.getLang() == null) { BeanHelper.error(sessionBean.getMessage("error_profile_label_no_lang")); return false; } } if (s.getType() == null) { BeanHelper.error(sessionBean.getMessage("error_profile_select_metadata_type")); return false; } else if (s.getId() == null || !s.getId().isAbsolute()) { BeanHelper.error(s.getId() + " " + sessionBean.getMessage("error_profile_name_not_valid")); return false; } else if (statementNames.contains(s.getId())) { BeanHelper.error(sessionBean.getMessage("error_profile_name_not_unique")); return false; } else if (s.getLabels().isEmpty() || "".equals(((List<LocalizedString>) s.getLabels()).get(0).toString())) { BeanHelper.error(sessionBean.getMessage("error_profile_name_required")); return false; } else { statementNames.add(s.getId().toString()); } s.setPos(i); i++; } return true; }
public void loadtemplates() { profilesMenu = new ArrayList<SelectItem>(); profilesMenu.add(new SelectItem(null, sessionBean.getLabel("profile_select_template"))); try { for (MetadataProfile mdp : pc.search()) { if (mdp.getId().toString() != profile.getId().toString()) { profilesMenu.add(new SelectItem(mdp.getId().toString(), mdp.getTitle())); } } } catch (Exception e) { BeanHelper.error(sessionBean.getMessage("error_profile_template_load")); } }
/** 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"); } }
/** Initialize the bean */ public CollectionImagesBean() { super(); sb = (SessionBean) BeanHelper.getSessionBean(SessionBean.class); this.navigation = (Navigation) BeanHelper.getApplicationBean(Navigation.class); }
/** Constructor */ public InternationalizationBean() { session = (SessionBean) BeanHelper.getSessionBean(SessionBean.class); init(); internationalizeLanguages(); }
/** * Construct the Bean and initalize the pages * * @throws URISyntaxException * @throws IOException */ public UploadBean() throws IOException, URISyntaxException { sessionBean = (SessionBean) BeanHelper.getSessionBean(SessionBean.class); storageController = new StorageController("internal"); formatBlackList = PropertyReader.getProperty("imeji.upload.blacklist"); formatWhiteList = PropertyReader.getProperty("imeji.upload.whitelist"); }