List of usage examples for com.liferay.portal.kernel.exception PortalException PortalException
public PortalException(Throwable cause)
From source file:com.bemis.portal.twofa.device.manager.service.impl.DeviceLocalServiceImpl.java
License:Open Source License
public Device registerDevice(DeviceInfo deviceInfo) throws PortalException { User portalUser = deviceInfo.getUser(); if (portalUser == null) { throw new PortalException(">>> No Such User exists with email address : " + deviceInfo.getUserEmail()); }/* www . j a v a2s .co m*/ String deviceIP = deviceInfo.getDeviceIP(); long portalUserId = portalUser.getUserId(); String portalUserFullName = portalUser.getFullName(); Device device = fetchDeviceByUserAndDeviceIP(portalUserId, deviceIP); if (device == null) { if (_log.isDebugEnabled()) { _log.debug( String.format(">>> No Device registered for %s for IP : %s", portalUserFullName, deviceIP)); } device = devicePersistence.create(counterLocalService.increment(Device.class.getName())); device.setCreateDate(new Date()); } long companyId = portalUser.getCompanyId(); long groupId = _bemisPortalService.getGlobalScopeGroupId(); User defaultUser = _bemisPortalService.getDefaultUser(); device.setCompanyId(companyId); device.setGroupId(groupId); device.setUserId(defaultUser.getUserId()); device.setUserName(defaultUser.getScreenName()); device.setModifiedDate(new Date()); device.setPortalUserId(portalUserId); device.setPortalUserName(portalUserFullName); device.setEmailAddress(portalUser.getEmailAddress()); device.setDeviceIP(deviceIP); device.setVerified(false); device.setTempDevice(false); devicePersistence.update(device); return device; }
From source file:com.beorn.paymentpluginapi.messaging.PaymentPluginSender.java
License:Open Source License
/** * Register the payment plugin into the payment system * /*from ww w . ja va 2 s . c o m*/ * @throws PortalException * @throws SystemException */ public void register() throws PortalException, SystemException { ServletContext servletContext = getServletContext(); try { Document pluginDescriptionDocument = SAXReaderUtil .read(PaymentPluginUtil.getPluginDescriptionStream(servletContext)); Message message = createMessage(); message.setStringProperty("method", "register"); message.setStringProperty("applicationId", servletContext.getServletContextName()); message.setStringProperty("data", pluginDescriptionDocument.compactString()); getAsynchronousMessenger().send(message); } catch (DocumentException e) { throw new SystemException(e); } catch (JMSException e) { throw new SystemException(e); } catch (IOException e) { throw new PortalException(e); } }
From source file:com.beorn.paymentpluginapi.util.PaymentPluginUtil.java
License:Open Source License
/** * Retrieve this plugin's name as defined in its payment-plugin.xml * /* ww w . ja v a 2s .c om*/ * @param servletContext * this webapp's servlet context * @return this plugin's name * @throws PortalException * @throws IOException */ public static String getPluginName(ServletContext servletContext) throws PortalException, IOException { InputStream is = getPluginDescriptionStream(servletContext); try { Document document = SAXReaderUtil.read(is); Node nameNode = document.selectSingleNode("/plugin/name"); return nameNode.getStringValue(); } catch (Exception e) { throw new PortalException(e); } finally { is.close(); } }
From source file:com.beorn.paymentpluginapi.util.PaymentPluginUtil.java
License:Open Source License
/** * Retrieve all the payment method handlers as defined in this plugin's * payment-plugin.xml// w ww. ja v a 2s.c o m * * @param servletContext * this webapp's servlet context * @return the supported payment method handlers * @throws PortalException * @throws SystemException */ public static Map<String, MethodHandler> getPluginMethodHandlers(ServletContext servletContext) throws PortalException, SystemException { try { InputStream is = getPluginDescriptionStream(servletContext); try { Document document = SAXReaderUtil.read(is); Map<String, MethodHandler> methodHandlers = new HashMap<String, MethodHandler>(); List<Node> methodNodes = document.selectNodes("/plugin/methods/method"); for (Node methodNode : methodNodes) { Node keyNode = methodNode.selectSingleNode("key"); Node classNameNode = methodNode.selectSingleNode("class"); String key = keyNode.getStringValue(); String className = classNameNode.getStringValue(); try { MethodHandler methodHandler = (MethodHandler) Class.forName(className).newInstance(); methodHandler.initialize(servletContext); methodHandlers.put(key, methodHandler); } catch (Exception e) { _log.error("Could not initialize method handler for {plugin:" + servletContext.getServletContextName() + ", key:" + key + ", classname:" + className + "}", e); } } return methodHandlers; } catch (Exception e) { throw new PortalException(e); } finally { is.close(); } } catch (IOException e1) { throw new SystemException(e1); } }
From source file:com.blogspot.jmelon.portlet.quiz.controller.QuizEditController.java
License:Open Source License
@ResourceMapping("checkArticle") public ModelAndView checkArticle(ResourceRequest request, ResourceResponse response, ModelAndView mav, @RequestBody QuizArticleQuery query) { mav.setView(JSON_VIEW);//from w w w . ja v a 2s. com ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); try { long groupId; if (GLOBAL.equals(query.getGroup())) { groupId = themeDisplay.getCompanyGroupId(); } else if (SCOPE.equals(query.getGroup())) { groupId = themeDisplay.getScopeGroupId(); } else { throw new PortalException("Unknown group"); } JournalArticle article = JournalArticleLocalServiceUtil.getArticle(groupId, query.getArticleId()); mav.addObject(TITLE, article.getTitle()); mav.addObject(TEMPLATES, JournalTemplateLocalServiceUtil.getStructureTemplates(groupId, article.getStructureId())); mav.addObject(RESOLUTION, SUCCESS); } catch (PortalException e) { mav.addObject(RESOLUTION, FAILED); LOGGER.error("Couldn't get templates for query: {}", query); } catch (SystemException e) { mav.addObject(RESOLUTION, FAILED); LOGGER.error("Couldn't get templates for query: {}", query); } return mav; }
From source file:com.cmc.gateway.domain.service.impl.AppDomainLocalServiceImpl.java
License:Open Source License
public AppDomain update(AppDomain appDomain, ServiceContext serviceContext) throws SystemException, PortalException { Date now = new Date(); if (Validator.isNull(appDomain.getDomainId()) && appDomain.isNew()) { long appDomainId = counterLocalService.increment(AppDomain.class.getName()); appDomain.setDomainId(appDomainId); appDomain.setCompanyId(serviceContext.getCompanyId()); appDomain.setGroupId(serviceContext.getScopeGroupId()); appDomain.setUserId(serviceContext.getUserId()); appDomain.setCreateDate(now);//from w w w. j a v a 2s . c o m appDomain.setModifiedDate(now); try { appDomainPersistence.findByCode(appDomain.getType(), appDomain.getCode()); throw new PortalException("code-and-type-has-bean-exist-on-the-system"); } catch (NoSuchAppDomainException e) { // everything is fine. } } else { appDomain.setModifiedDate(now); } validate(appDomain); return appDomainPersistence.update(appDomain, true); }
From source file:com.cmc.gateway.domain.service.impl.CommandEntryLocalServiceImpl.java
License:Open Source License
public CommandEntry update(CommandEntry commandEntry, ServiceContext serviceContext) throws PortalException, SystemException { Date now = new Date(); if (Validator.isNull(commandEntry.getCommandId()) && commandEntry.isNew()) { long commandId = counterLocalService.increment(CommandEntry.class.getName()); commandEntry.setCommandId(commandId); commandEntry.setUserId(serviceContext.getUserId()); commandEntry.setGroupId(serviceContext.getScopeGroupId()); commandEntry.setCompanyId(serviceContext.getCompanyId()); commandEntry.setCreateDate(now); commandEntry.setModifiedDate(now); try {/*from w w w . j a v a2s . c o m*/ commandEntryPersistence.findByCode(commandEntry.getCode()); throw new PortalException("a-command-entry-with-code-has-been-exist-on-the-system"); } catch (NoSuchCommandEntryException e) { // Good } } else { commandEntry.setModifiedDate(now); } validate(commandEntry); return commandEntryPersistence.update(commandEntry, true); }
From source file:com.cmc.gateway.domain.service.impl.ProductCategoryLocalServiceImpl.java
License:Open Source License
public void validateDelete(long categoryId) throws PortalException, SystemException { try {/*w w w . jav a2s . c o m*/ productCategoryPersistence.findByPrimaryKey(categoryId); } catch (NoSuchProductCategoryException e) { throw new PortalException("product-category-can-not-found"); } if (productEntryPersistence.countByCategory(categoryId) > 0) { throw new PortalException("can-not-delete-product-category-what-had-product-associate-with"); } }
From source file:com.cmc.gateway.domain.service.impl.ProductEntryLocalServiceImpl.java
License:Open Source License
public ProductEntry update(ProductEntry productEntry, ServiceContext serviceContext) throws PortalException, SystemException { Date now = new Date(); if (Validator.isNull(productEntry.getProductId()) && productEntry.isNew()) { long productId = counterLocalService.increment(ProductEntry.class.getName()); productEntry.setProductId(productId); productEntry.setUserId(serviceContext.getUserId()); productEntry.setGroupId(serviceContext.getScopeGroupId()); productEntry.setCompanyId(serviceContext.getCompanyId()); productEntry.setCreateDate(now); productEntry.setModifiedDate(now); try {//from w w w . j a va 2 s . c om productEntryPersistence.findByCode(productEntry.getCode()); throw new PortalException("code-has-been-exist-on-the-system"); } catch (NoSuchProductEntryException e) { // Happy } } else { productEntry.setModifiedDate(now); } validate(productEntry); return productEntryPersistence.update(productEntry, true); }
From source file:com.cmc.gateway.domain.service.impl.ProvisioningEntryLocalServiceImpl.java
License:Open Source License
public ProvisioningEntry update(ProvisioningEntry provisioningEntry, ServiceContext serviceContext) throws PortalException, SystemException { if (Validator.isNull(provisioningEntry.getProvisioningId()) && provisioningEntry.isNew()) { long provisioningId = counterLocalService.increment(ProvisioningEntry.class.getName()); provisioningEntry.setProvisioningId(provisioningId); provisioningEntry.setUserId(serviceContext.getUserId()); provisioningEntry.setGroupId(serviceContext.getScopeGroupId()); provisioningEntry.setCompanyId(serviceContext.getCompanyId()); provisioningEntry.setCreateDate(serviceContext.getCreateDate()); provisioningEntry.setModifiedDate(serviceContext.getModifiedDate()); try {//from w w w . j a v a 2 s. c o m provisioningEntryPersistence.findByCode(provisioningEntry.getCode()); throw new PortalException("code-has-been-exist-in-the-system"); } catch (NoSuchProvisioningEntryException e) { // GOOD } } else { provisioningEntry.setModifiedDate(serviceContext.getModifiedDate()); } validate(provisioningEntry); return provisioningEntryPersistence.update(provisioningEntry, true); }