/** * This method deletes the TerminationReasons record from database based on TerminationReasons * record Id * * @param resourceRequest * @param resourceResponse * @throws IOException * @throws PortletException * @throws SystemException * @throws PortalException * @throws NumberFormatException */ public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws IOException { if (resourceRequest.getResourceID().equals("deleteTerminationReasons")) { System.out.println("deleting thes TerminationReasons"); String[] idsArray = ParamUtil.getParameterValues(resourceRequest, "terminationreasonsIds"); System.out.println(idsArray.length); for (int i = 0; i <= idsArray.length - 1; i++) { try { try { TerminationReasonsLocalServiceUtil.deleteTerminationReasons( Long.parseLong(idsArray[i])); } catch (PortalException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (NumberFormatException e) { } } } }
/* * Processes resource bundle for specified locale * */ private static void saveProperties( Locale locale, Hashtable<String, String> bundle, String bundleName) { for (Map.Entry property : bundle.entrySet()) { String key = (String) property.getKey(); String value = (String) property.getValue(); try { MessageSourcePK messageSourcePK = new MessageSourcePK(key, locale.toString()); MessageSource messageSource = MessageSourceLocalServiceUtil.fetchMessageSource(messageSourcePK); if (messageSource == null) { messageSource = MessageSourceUtil.create(messageSourcePK); messageSource.setValue(value); messageSource.setBundle(bundleName); MessageSourceLocalServiceUtil.updateMessageSource(messageSource); } } catch (SystemException ex) { ex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } } }
private void update() { if (!IConstants.CFG_NOTIFY_OLD_USERS) return; DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(User.class, PortalClassLoaderUtil.getClassLoader()); dynamicQuery.add(RestrictionsFactoryUtil.eq("jobTitle", "mail-not-sent")); try { @SuppressWarnings("unchecked") List<User> users = UserLocalServiceUtil.dynamicQuery(dynamicQuery); int cnt = 0; for (User user : users) { // notifyUser thru email and SMS user.setJobTitle(StringPool.BLANK); user.setLastName(StringPool.BLANK); user = UserLocalServiceUtil.updateUser(user); cnt++; if (cnt == 200) break; } } catch (SystemException e) { e.printStackTrace(); } }
public void updateBook(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { String bookTitle = ParamUtil.getString(actionRequest, "asuid"); String author = ParamUtil.getString(actionRequest, "email"); System.out.println("Your inputs ==> " + bookTitle + ", " + author); LMSBook book = new LMSBookImpl(); // set primary key long bookId = 0L; try { bookId = CounterLocalServiceUtil.increment(this.getClass().getName()); } catch (SystemException e) { e.printStackTrace(); } book.setBookId(bookId); // set UI fields book.setAsuid(bookTitle); book.setEmail(author); // set audit field(s) book.setDateAdded(new Date()); try { LMSBookLocalServiceUtil.addLMSBook(book); } catch (SystemException e) { e.printStackTrace(); } }
public Books getBooksInstance() { try { return booksPersistence.create(counterLocalService.increment(Books.class.getName())); } catch (SystemException e) { e.printStackTrace(); return null; } }
public DLFileEntry updateFileEntry(DLFileEntry file) { try { return fileService.updateDLFileEntry(file); } catch (SystemException ex) { ex.printStackTrace(); return file; } }
public List<Books> getAllBooks(long companyId) { try { return booksPersistence.findByCompanyId(companyId); } catch (SystemException e) { e.printStackTrace(); return Collections.emptyList(); } }
public List<Books> getAllBooks(long groupId, String title) { try { return booksPersistence.findByGroup_Title(groupId, title); } catch (SystemException e) { e.printStackTrace(); return Collections.emptyList(); } }
public List<Books> getBooksByUserId(long userId) { try { return booksPersistence.findByUserId(userId); } catch (SystemException e) { e.printStackTrace(); return null; } }
public List<Books> getAllBooks() { try { return booksPersistence.findAll(); } catch (SystemException e) { e.printStackTrace(); return Collections.emptyList(); } }
/** * This method inserts new TerminationReason record into the database table * * @param actionRequest * @param actionResponse * @throws IOException * @throws PortletException * @throws SystemException */ public void saveTerminationReasons(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException, SystemException { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); try { TerminationReasons terminationReasons = TerminationReasonsLocalServiceUtil.createTerminationReasons( CounterLocalServiceUtil.increment()); String id = ParamUtil.getString(actionRequest, "terminationreasonsId"); String name = ParamUtil.getString(actionRequest, "terminationreasonsName"); String terminationReason = name.trim(); if (terminationReason.equals("") || terminationReason == null) { System.out.println("Empty value in TerminationReason..."); SessionMessages.add(actionRequest.getPortletSession(), "termination-form-error"); actionResponse.setRenderParameter("mvcPath", "/html/terminationreasons/add.jsp"); } else { System.out.println("id == " + id + "Name = " + name); if (id == "" || id == null) { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( TerminationReasons.class, PortalClassLoaderUtil.getClassLoader()); dynamicQuery.add(RestrictionsFactoryUtil.eq("terminationreasonsName", name)); List<TerminationReasons> list = TerminationReasonsLocalServiceUtil.dynamicQuery(dynamicQuery); if (list.size() > 0) { TerminationReasons terminationReasons2 = list.get(0); if (terminationReasons2 != null) { SessionMessages.add( actionRequest.getPortletSession(), "termination-form-duplicate-error"); actionResponse.setRenderParameter("mvcPath", "/html/terminationreasons/add.jsp"); } } else { terminationReasons.setTerminationreasonsName( ParamUtil.getString(actionRequest, "terminationreasonsName")); terminationReasons.setCreateDate(date); terminationReasons.setModifiedDate(date); terminationReasons.setCompanyId(themeDisplay.getCompanyId()); terminationReasons.setGroupId(themeDisplay.getCompanyGroupId()); terminationReasons.setUserId(themeDisplay.getUserId()); terminationReasons = TerminationReasonsLocalServiceUtil.addTerminationReasons(terminationReasons); } } } } catch (SystemException e) { e.printStackTrace(); } }
public Long getCitizenId() { try { return CounterLocalServiceUtil.increment(Citizen.class.getName()); } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } return 0L; }
public Long getAutoIncrement() { try { return CounterLocalServiceUtil.increment("CMON_HOSOTTHCCONG_AUTO_INCREMENT"); } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
public DLFileEntry getFileEntry(long fileId) { try { return fileService.getDLFileEntry(fileId); } catch (PortalException ex) { ex.printStackTrace(); return null; } catch (SystemException ex) { ex.printStackTrace(); return null; } }
public DLFileEntry getFileEntry(String processUUID, String title) { try { return fileService.getFileEntryByTitle( processBaseGroup.getGroupId(), getFolder(processUUID).getFolderId(), title); } catch (PortalException ex) { ex.printStackTrace(); return null; } catch (SystemException ex) { ex.printStackTrace(); return null; } }
@Override protected University returnedModelObject(String value) { try { return UniversityLocalServiceUtil.getUniversity(Long.valueOf(value)); } catch (NumberFormatException e) { e.printStackTrace(); } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); } return null; }
@RenderMapping public ModelAndView handleRenderRequest( RenderRequest request, RenderResponse response, ModelMap modelMap) { List<VoloDTO> listVolo = null; try { listVolo = voloService.findAll(); } catch (SystemException e) { e.printStackTrace(); } modelMap.put("listVolo", listVolo); return new ModelAndView("view", modelMap); }
public boolean isAssetPresent(String id_isin, String security_ticker) { boolean present = false; try { Asset asset = assetPersistence.fetchByIdISIN_Ticker(id_isin, security_ticker); present = Validator.isNotNull(asset); } catch (SystemException e) { e.printStackTrace(); } return present; }
public void deleteBooks(long booksId, long companyId) { Books books; try { books = booksPersistence.findByPrimaryKey(booksId); } catch (SystemException e) { e.printStackTrace(); return; } catch (NoSuchooksException e) { e.printStackTrace(); return; } deleteBooks(books, companyId); }
/** * Entfernt einen Favoriten aus der DB * * @param event */ public void deleteFavorite(ActionEvent event) { try { FavoriteLocalServiceUtil.deleteFavorite(Long.valueOf(currentFav)); } catch (NumberFormatException e) { System.out.println("Beim lšschen eines Favoriten " + "ist ein Fehler aufgetreten!"); e.printStackTrace(); } catch (PortalException e) { System.out.println("Beim lšschen eines Favoriten " + "ist ein Fehler aufgetreten!"); e.printStackTrace(); } catch (SystemException e) { System.out.println("Beim lšschen eines Favoriten " + "ist ein Fehler aufgetreten!"); e.printStackTrace(); } moveToFavoriteSelection(event); }
/** * Verfolgt Aenderungen in der Favoriten-Auswahl Fuer die aktuelle Auswahl wird eine Vorschau * angezeigt * * @param vcEvent */ public void favoritePreviewListener(ValueChangeEvent vcEvent) { try { slideBackingBean.showPreview( SlideLocalServiceUtil.getSlide( FavoriteLocalServiceUtil.getFavorite( Long.valueOf(vcEvent.getNewValue().toString())) .getSlideId()) .getIndex()); } catch (NumberFormatException e) { e.printStackTrace(); } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); } }
/** * Zeigt den aktuellen Favoriten als Folie im slideViewer an * * @param event */ public void moveToFavorite(ActionEvent event) { navigationBackingBean.setFavoriteSelectionStatus(false); navigationBackingBean.setSlideViewerStatus(true); try { slideBackingBean.showSlide( "" + FavoriteLocalServiceUtil.getFavorite(Long.valueOf(currentFav)).getSlideId()); } catch (NumberFormatException e) { System.out.println("Beim navigieren zu einem Favoriten " + "ist ein Fehler aufgetreten!"); e.printStackTrace(); } catch (PortalException e) { System.out.println("Beim navigieren zu einem Favoriten " + "ist ein Fehler aufgetreten!"); e.printStackTrace(); } catch (SystemException e) { System.out.println("Beim navigieren zu einem Favoriten " + "ist ein Fehler aufgetreten!"); e.printStackTrace(); } }
/** * Laedt ein einzelnes Modul aus der Datenbank und belegt die ModuleModelBean * * @param moduleId */ public void fetchModule(long moduleId) { try { Module module = ModuleLocalServiceUtil.getModule(moduleId); moduleModelBean.setLecturerUserId(module.getLecturerUserId()); moduleModelBean.setModuleTitle(module.getModuleTitle()); moduleModelBean.setDate(module.getCreateDate()); moduleModelBean.setAdditionalInfo(module.getAdditionalInfo()); } catch (NumberFormatException e) { System.out.println("Beim fetchen eines Moduls " + "ist ein Fehler aufgetreten!"); e.printStackTrace(); } catch (PortalException e) { System.out.println("Beim fetchen eines Moduls " + "ist ein Fehler aufgetreten!"); e.printStackTrace(); } catch (SystemException e) { System.out.println("Beim fetchen eines Moduls " + "ist ein Fehler aufgetreten!"); e.printStackTrace(); } }
@SuppressWarnings("unchecked") public List<Asset> getAssets(String pattern, boolean ticker) { List<Asset> results = new ArrayList<Asset>(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(AssetImpl.class); dynamicQuery.add( RestrictionsFactoryUtil.like( ticker ? "security_ticker" : "id_isin", StringPool.PERCENT + pattern + StringPool.PERCENT)); dynamicQuery.addOrder(OrderFactoryUtil.asc(ticker ? "security_ticker" : "id_isin")); try { results = assetLocalService.dynamicQuery(dynamicQuery); } catch (SystemException e) { e.printStackTrace(); } return results; }
/** * The search redirection. * * @return an empty string. */ public String search() { FacesContext facesContext = FacesContext.getCurrentInstance(); Object responseObject = facesContext.getExternalContext().getResponse(); if (responseObject != null && responseObject instanceof ActionResponse) { ActionResponse actionResponse = (ActionResponse) responseObject; Query query = new Query(); query.getTags().add(selectedTag); actionResponse.setEvent( new QName("http://fokus.fraunhofer.de/odplatform", "querydatasets"), query); String location = LiferayFacesContext.getInstance().getThemeDisplay().getPortalURL(); Layout layout = LiferayFacesContext.getInstance().getThemeDisplay().getLayout(); try { if (layout.isPublicLayout()) { location += LiferayFacesContext.getInstance().getThemeDisplay().getPathFriendlyURLPublic(); } location += layout.hasScopeGroup() ? layout.getScopeGroup().getFriendlyURL() : layout.getGroup().getFriendlyURL(); location += "/suchen"; } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); } try { facesContext.getExternalContext().redirect(location); } catch (IOException e) { e.printStackTrace(); } } return ""; }
public byte[] getFileBody(String processUUID, long fileId) { byte[] result = null; try { DLFileEntry file = getFileEntry(fileId); result = new byte[Long.valueOf(file.getSize()).intValue()]; InputStream is = fileService.getFileAsStream( currentUser.getCompanyId(), currentUser.getUserId(), processBaseGroup.getGroupId(), getFolder(processUUID).getFolderId(), file.getName()); is.read(result); } catch (PortalException ex) { ex.printStackTrace(); } catch (SystemException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } return result; }
public void render(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { if (!_processed) { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletConfig portletConfig = (PortletConfig) renderRequest.getAttribute("javax.portlet.config"); _portletName = portletConfig.getPortletName(); PortletURL pURL = PortletURLFactoryUtil.create( renderRequest, _portletName + "_WAR_" + _portletName + "portlet", themeDisplay.getPlid(), PortletRequest.ACTION_PHASE); pURL.setParameter(ActionRequest.ACTION_NAME, ProxyConstant.ACTION_LINK); _portletURL = pURL.toString(); // read portlet config; PortletPreferences preferences = renderRequest.getPreferences(); String portletResource = ParamUtil.getString(renderRequest, "portletResource"); if (Validator.isNotNull(portletResource)) { try { preferences = PortletPreferencesFactoryUtil.getPortletSetup(renderRequest, portletResource); } catch (PortalException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } _proxyURL = preferences.getValue("url", ""); log.info("proxyurl=" + _proxyURL); defaultProxyRequest(); renderResponse.getWriter().print(_result); } else renderResponse.getWriter().print("processed"); }
private void getPortletInfo(ActionRequest actionRequest) { log.info("getPortletInfo"); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletConfig portletConfig = (PortletConfig) actionRequest.getAttribute("javax.portlet.config"); _portletName = portletConfig.getPortletName(); PortletURL pURL = PortletURLFactoryUtil.create( actionRequest, _portletName + "_WAR_" + _portletName + "portlet", themeDisplay.getPlid(), PortletRequest.ACTION_PHASE); /*try { pURL.setWindowState(WindowState.NORMAL ); } catch (WindowStateException e1) { // TODO Auto-generated catch block e1.printStackTrace(); }*/ pURL.setParameter(ActionRequest.ACTION_NAME, ProxyConstant.ACTION_LINK); _portletURL = pURL.toString(); // read portlet config; PortletPreferences preferences = actionRequest.getPreferences(); String portletResource = ParamUtil.getString(actionRequest, "portletResource"); if (Validator.isNotNull(portletResource)) { try { preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource); } catch (PortalException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } _proxyURL = preferences.getValue("url", ""); } /*
/** * Navigationsmethode mit Ziel questionViewer.xhtml Zeigt die gewaehlte Frage und die * dazugehoerige Antwort an * * @param event */ public void moveToQuestionViewer(ActionEvent event) { navigationBackingBean.setQuestionSelectionStatus(false); navigationBackingBean.setQuestionViewerStatus(true); try { Question question = QuestionLocalServiceUtil.fetchQuestion(Long.valueOf(currentQuest)); questionModelBean.setAnswer(question.getAnswer()); if (questionModelBean.getAnswer() == null || questionModelBean.getAnswer() == "") { questionModelBean.setAnswer("Diese Frage wurde leider noch nicht beantwortet!"); } questionModelBean.setModuleId(question.getModuleId()); questionModelBean.setQuestionId(question.getQuestionId()); questionModelBean.setQuestionText(question.getQuestionText()); questionModelBean.setUserId(question.getUserId()); } catch (NumberFormatException e) { e.printStackTrace(); System.out.println( "Beim generieren des Question Modell " + "Objektes ist ein Fehler aufgetreten!"); } catch (SystemException e) { System.out.println( "Beim generieren des Question Modell " + "Objektes ist ein Fehler aufgetreten!"); e.printStackTrace(); } }
public void run(String[] arg0) throws ActionException { File file = new File("old-users.csv"); _log.debug("file ==> " + file.getAbsolutePath()); InputStream inputStream = null; try { inputStream = new FileInputStream(file); } catch (FileNotFoundException e) { _log.debug("File not found...Existing...."); return; } BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); long companyId = PortalUtil.getDefaultCompanyId(); long creatorUserId = 0l; try { creatorUserId = UserLocalServiceUtil.getDefaultUserId(companyId); } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); } try { String line = StringPool.BLANK; while (Validator.isNotNull(line = br.readLine())) { insertOldUser(companyId, creatorUserId, line); } } catch (IOException e) { e.printStackTrace(); } file.delete(); }