List of usage examples for com.liferay.portal.kernel.util PropsUtil get
public static String get(String key)
From source file:com.stoxx.portlet.controller.RegistrationController.java
@ActionMapping(params = "action=addUserRegistrationAction") public void addUserRegistrationAction(ActionRequest actionRequest, ActionResponse actionResponse, Model model, @ModelAttribute(REGISTRATION_BEAN) RegistrationBean registrationBean, BindingResult bindingResult) { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); SessionMessages.add(actionRequest,//from w w w . j a va2 s .c om PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); String actionResponseParameter = null; try { log.info("***************************the business email address variable is" + businessEmailAddress); log.info("registrationBean.toString() : " + registrationBean.toString()); log.info("***************************On Linked in click" + registrationBean.getLinkedinReg()); log.info("registrationBean.getLinkedinReg() is" + registrationBean.getLinkedinReg()); if (Validator.isNull(registrationBean.getLinkedinReg())) { registrationBean.setLinkedinReg(Boolean.FALSE); } registrationBean.setCompanyId(themeDisplay.getCompanyId()); if (Validator.isNotNull(registrationBean) && registrationBean.getLinkedinReg()) { if (registrationDelegator.checkIfUserExistsInLiferayDB(registrationBean)) { SessionErrors.add(actionRequest, USER_EXISTS_KEY); actionResponse.setRenderParameter(ACTION, USER_EXISTS); return; } else { registrationBean.setUserType(STOXXConstants.STOXX_GENERAL_USER); registrationBean.setIsExistingUser(Boolean.FALSE); actionResponseParameter = "setupProfileTRANSLATOR"; createActivationLink(actionRequest, registrationBean, themeDisplay); actionResponse.setRenderParameter(ACTION, actionResponseParameter); return; } } if (Validator.isNotNull(registrationBean)) { registrationBean.setCompanyId(themeDisplay.getCompanyId()); log.info("the company id is" + registrationBean.getCompanyId()); log.info("registrationBean.getIsDeletedUser() : " + registrationBean.getIsDeletedUser()); if (Validator.isNotNull(registrationBean.getIsExistingUser()) && registrationBean.getIsExistingUser() && !(Validator.isNotNull(registrationBean.getIsDeletedUser()) && registrationBean.getIsDeletedUser())) { log.info("Return the user back to login page..."); actionResponse.setRenderParameter(ACTION, "existingUserStep2"); return; } } if (Validator.isNotNull(registrationBean) && null != registrationBean.getBusinessEmailAddress()) { log.info("the EXPECTED emailAddress id is" + registrationBean.getBusinessEmailAddress()); RegistrationBean regBean = registrationDelegator.fetchFromStoxxUser(registrationBean); log.info("the status is" + regBean.getStatus()); if (Validator.isNotNull(regBean) && Validator.isNotNull(regBean.getStatus()) && (regBean.getStatus() == 3 || regBean.getStatus() == 4)) { log.info("the user with emailAddress id is" + regBean.getBusinessEmailAddress() + "is an existing user and needs to be migrated"); try { if (regBean.getStatus() == 4 && regBean.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_REGISTERED_USER)) { String emailDomainName = registrationBean.getBusinessEmailAddress() .substring(registrationBean.getBusinessEmailAddress().lastIndexOf("@")); EmailDomain emailDomain = EmailDomainLocalServiceUtil.getEmailDomain(emailDomainName); regBean.setSalesEntryId(emailDomain.getSalesEntryId()); SalesEntry salesEntry = SalesEntryLocalServiceUtil .getSalesEntry(emailDomain.getSalesEntryId()); int allowedLicenses = salesEntry.getUsersAllowed(); int alreadyUsedLicenses = registrationDelegator .getCustomerCountByGroupId(salesEntry.getSalesEntryId()); log.info("alreadyUsedLicenses from DB for salesentryID: " + salesEntry.getSalesEntryId() + " is: " + alreadyUsedLicenses); log.info("allowedLicenses: " + allowedLicenses + "for salesentry company: " + salesEntry.getCompanyName()); if (allowedLicenses <= alreadyUsedLicenses) { SessionErrors.add(actionRequest, CUST_USER_EXCEEDED); actionResponse.setRenderParameter(ACTION, CUST_USER_EXCEEDED); return; } } } catch (NoSuchEmailDomainException e) { log.info("No domain exist for provided email address."); regBean.setUserType(STOXXConstants.STOXX_GENERAL_USER); } createActivationLink(actionRequest, regBean, themeDisplay); actionResponse.setRenderParameter(ACTION, EXISTING_USER); return; } if (registrationDelegator.checkIfUserExistsInLiferayDB(registrationBean)) { SessionErrors.add(actionRequest, USER_EXISTS_KEY); actionResponse.setRenderParameter(ACTION, USER_EXISTS); return; } else if (fetchActivationLinkCreateDateDiff(registrationBean.getBusinessEmailAddress())) { SessionErrors.add(actionRequest, RegistrationConstants.REGISTRATION_LINK_EXPIRED); actionResponse.setRenderParameter(ACTION, RegistrationConstants.REGISTRATION_LINK_ALREADY_SENT); return; } else if (registrationDelegator.checkIfUserExistsInLiferay(registrationBean)) { SessionErrors.add(actionRequest, "user-activation-link-already-sent"); actionResponse.setRenderParameter(ACTION, RegistrationConstants.REGISTRATION_LINK_ALREADY_SENT); return; } } else if (null != businessEmailAddress) { log.info("Within else if : businessEmailAddress : " + businessEmailAddress); RegistrationBean regBean = registrationDelegator.fetchFromStoxxUser(registrationBean, businessEmailAddress); if (Validator.isNotNull(regBean) && Validator.isNotNull(regBean.getStatus()) && regBean.getStatus() == 3) { log.info("the user with emailAddress id is" + regBean.getBusinessEmailAddress() + "is an existing user and needs to be migrated"); actionResponse.setRenderParameter(ACTION, EXISTING_USER); return; } if (Validator.isNotNull(regBean) && Validator.isNotNull(regBean.getStatus()) && regBean.getStatus() == 4) { log.info("the user with emailAddress id is" + regBean.getBusinessEmailAddress() + "is an existing user and needs to be migrated"); actionResponse.setRenderParameter(ACTION, DELETED_USER); return; } if (Validator.isNotNull(registrationBean.getIsDeletedUser()) && registrationBean.getIsDeletedUser()) { log.info("User email address is : " + businessEmailAddress + ". User added as customer after delition"); actionResponse.setRenderParameter(ACTION, DELETED_USER); return; } if (registrationDelegator.checkIfUserExistsInLiferayDB(registrationBean, businessEmailAddress)) { log.info("User exist in liferay DB"); SessionErrors.add(actionRequest, USER_EXISTS_KEY); actionResponse.setRenderParameter(ACTION, USER_EXISTS); return; } else if (fetchActivationLinkCreateDateDiff(businessEmailAddress)) { log.info("The activation link is expired."); SessionErrors.add(actionRequest, LINK_EXPIRED); actionResponse.setRenderParameter(ACTION, RegistrationConstants.REGISTRATION_LINK_ALREADY_SENT); return; } } if (null != registrationBean.getBusinessEmailAddress()) { log.info("Within If " + registrationBean.getBusinessEmailAddress()); if (registrationBean.getBusinessEmailAddress() .substring(registrationBean.getBusinessEmailAddress().indexOf(StringPool.AT) + 1) .equalsIgnoreCase(RegistrationConstants.STAFF_DOMAIN_PATTERN)) { registrationBean.setUserType(STOXXConstants.STOXX_STAFF_USER); createActivationLink(actionRequest, registrationBean, themeDisplay); actionResponseParameter = "setupProfileSTAFF"; } else { try { String emailDomainName = registrationBean.getBusinessEmailAddress() .substring(registrationBean.getBusinessEmailAddress().lastIndexOf("@")); EmailDomain emailDomain = EmailDomainLocalServiceUtil.getEmailDomain(emailDomainName); registrationBean.setSalesEntryId(emailDomain.getSalesEntryId()); SalesEntry salesEntry = SalesEntryLocalServiceUtil .getSalesEntry(emailDomain.getSalesEntryId()); int allowedLicenses = salesEntry.getUsersAllowed(); int alreadyUsedLicenses = registrationDelegator .getCustomerCountByGroupId(salesEntry.getSalesEntryId()); log.info("alreadyUsedLicenses from DB for salesentryID: " + salesEntry.getSalesEntryId() + "is: " + alreadyUsedLicenses); log.info("allowedLicenses: " + allowedLicenses + "for salesentry company: " + salesEntry.getCompanyName()); if (allowedLicenses <= alreadyUsedLicenses) { SessionErrors.add(actionRequest, CUST_USER_EXCEEDED); actionResponse.setRenderParameter(ACTION, CUST_USER_EXCEEDED); return; } registrationBean.setUserType(STOXXConstants.STOXX_REGISTERED_USER); registrationBean.setCompanyName(salesEntry.getCompanyName()); actionResponseParameter = "setupProfileGENERALLICENSED"; } catch (NoSuchEmailDomainException e) { log.info("No domain exist for provided email address."); registrationBean.setUserType(STOXXConstants.STOXX_GENERAL_USER); actionResponseParameter = "setupProfileGENERAL"; } createActivationLink(actionRequest, registrationBean, themeDisplay); } } else { log.info("Within If " + businessEmailAddress); registrationBean = registrationDelegator.fetchFromStoxxUser(registrationBean, businessEmailAddress); if (Validator.isNotNull(registrationBean.getActivationLink()) && registrationBean.getActivationLink().indexOf(PropsUtil.get("INTRANET")) != -1 && registrationBean.getActivationLink().contains(StringPool.DOLLAR)) { if (registrationDelegator.checkIfUserExistsInLiferay(registrationBean, businessEmailAddress)) { registrationBean.setBusinessEmailAddress(businessEmailAddress); registrationDelegator.fetchFromStoxxUser(registrationBean); } else { registrationBean.setCompanyName(RegistrationConstants.STAFF_COMPANY); registrationBean.setUserType(STOXXConstants.STOXX_STAFF_USER); } } else if (Validator.isNotNull(registrationBean.getActivationLink()) && registrationBean.getActivationLink().indexOf(PropsUtil.get(INTERNET)) != -1) { if (registrationDelegator.checkIfUserExistsInLiferay(registrationBean, businessEmailAddress)) { registrationBean.setBusinessEmailAddress(businessEmailAddress); registrationDelegator.fetchFromStoxxUser(registrationBean); } else { registrationBean.setUserType(STOXXConstants.STOXX_GENERAL_USER); } } actionResponseParameter = "setupProfileTRANSLATOR"; } log.info("the action parameter is " + actionResponse.getRenderParameterMap()); actionResponse.setRenderParameter(ACTION, actionResponseParameter); } catch (STOXXException e) { log.error("STOXXException in addUserRegistrationAction", e); } catch (Exception e) { log.error("Exception in addUserRegistrationAction ", e); } }
From source file:com.stoxx.portlet.controller.RegistrationController.java
@ActionMapping(params = "action=setupProfileAction") public void setupProfileAction(ActionRequest actionRequest, ActionResponse actionResponse, Model model, @ModelAttribute(REGISTRATION_BEAN) RegistrationBean registrationBean, BindingResult bindingResult) { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String emailVelocityTemplate = StringPool.BLANK; try {//from w ww. j a v a 2s .co m ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest); log.info("Within setupProfileAction..."); log.info("registrationBean.toString() : " + registrationBean.toString()); HttpServletRequest httpreq = PortalUtil.getHttpServletRequest(actionRequest); HttpServletRequest httpOriginalreq = PortalUtil.getOriginalServletRequest(httpreq); //String remoteAddr = httpOriginalreq.getHeader("remote_addr"); // Should be Client-IP to retrieve IP address of the client machine // String remoteAddr = httpOriginalreq.getHeader("Client-IP"); if (Validator.isNull(remoteAddr)) { remoteAddr = httpOriginalreq.getRemoteAddr(); } try { CaptchaUtil.check(actionRequest); } catch (Exception e) { if (e instanceof CaptchaTextException) { SessionErrors.add(actionRequest, e.getClass(), e); actionResponse.setRenderParameter(ACTION, "CaptchaException"); return; } } log.info("the remote address is " + remoteAddr); String location = RegistrationVOUtil.getLocationForUser(remoteAddr); if (null != location) { registrationBean.setLocation(location); } RegistrationBean registrationBean1 = registrationDelegator.fetchFromStoxxUser(registrationBean); registrationBean.setUserType(registrationBean1.getUserType()); registrationBean.setCompanyId(themeDisplay.getCompanyId()); registrationBean.setActivationLink(registrationBean.getActivationLink()); log.info("registrationBean.getActivationLink() : " + registrationBean.getActivationLink()); log.info("registrationBean.getIsExistingUser() : " + registrationBean.getIsExistingUser()); log.info("registrationBean.getIsDeletedUser() : " + registrationBean.getIsDeletedUser()); registrationBean.setActivationLinkCreatedDate(new Date()); registrationDelegator.addUserRegistration(registrationBean, serviceContext, themeDisplay, registrationBean.getIsExistingUser(), registrationBean.getIsDeletedUser()); Layout layout = themeDisplay.getLayout(); PortletURL loginActionUrl = PortletURLFactoryUtil.create(actionRequest, "58", layout.getPlid(), "ACTION_PHASE"); loginActionUrl.setWindowState(WindowState.MAXIMIZED); loginActionUrl.setPortletMode(PortletMode.VIEW); loginActionUrl.setParameter("saveLastPath", "0"); loginActionUrl.setParameter("struts_action", "/login/login"); loginActionUrl.setParameter("login", registrationBean.getBusinessEmailAddress()); loginActionUrl.setParameter("password", registrationBean.getUserPassword()); Map<String, Object> emailBodyMap = new HashMap<String, Object>(); String emailTemplateFolder = "templates"; emailBodyMap.put("toName", registrationBean.getBusinessEmailAddress()); emailBodyMap.put("fromName", PrefsPropsUtil.getString("stoxx-reg-mail-from-name")); emailBodyMap.put("fromAddress", PrefsPropsUtil.getString("stoxx-reg-mail-fromAddress")); emailVelocityTemplate = emailTemplateFolder + StringPool.SLASH + "willingtocontact.vm"; String subject = LanguageUtil.get(themeDisplay.getLocale(), "stoxx-reg-mail-subject-for-wiiling-to-contact"); if (registrationBean.isContactMe()) stoxxMailUtil.shareByEmail(registrationBean.getBusinessEmailAddress(), PrefsPropsUtil.getString("stoxx-reg-mail-from-name"), emailVelocityTemplate, subject, emailBodyMap, themeDisplay); if (null != registrationBean.getUserType()) { if (registrationBean.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_VENDOR_USER)) { log.info("if redirected page is " + PortalUtil.getPortalURL(httpOriginalreq) + RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get(INTRANET) + RegistrationConstants.REGISTRATION_DASHBOARD); log.info("registrationBean.getDashboardRedirectCondition() 1>>>>>>>>>" + registrationBean.getDashboardRedirectCondition()); loginActionUrl.setParameter(_58_REDIRECT, RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get("INTRANET") + RegistrationConstants.REGISTRATION_DASHBOARD); actionResponse.sendRedirect(loginActionUrl.toString()); } else if (registrationBean.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_STAFF_USER)) { log.info("registrationBean.getDashboardRedirectCondition() 2>>>>>>>>>" + registrationBean.getDashboardRedirectCondition()); if (StringUtils.isNotBlank(registrationBean.getDashboardRedirectCondition())) { log.info("registrationBean.getDashboardRedirectCondition() 3>>>>>>>>>" + registrationBean.getDashboardRedirectCondition()); if ("yes".equalsIgnoreCase(registrationBean.getDashboardRedirectCondition())) { log.info("registrationBean.getDashboardRedirectCondition() 4>>>>>>>>>" + registrationBean.getDashboardRedirectCondition()); log.info("if redirected page is " + PortalUtil.getPortalURL(httpOriginalreq) + RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get(INTERNET) + RegistrationConstants.REGISTRATION_MYPROFILE); loginActionUrl.setParameter(_58_REDIRECT, RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get(INTERNET) + RegistrationConstants.REGISTRATION_MYPROFILE); actionResponse.sendRedirect(loginActionUrl.toString()); } else { if ("no".equalsIgnoreCase(registrationBean.getDashboardRedirectCondition())) { log.info("registrationBean.getDashboardRedirectCondition() 4>>>>>>>>>" + registrationBean.getDashboardRedirectCondition()); log.info("if redirected page is " + PortalUtil.getPortalURL(httpOriginalreq) + RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get(INTRANET) + RegistrationConstants.REGISTRATION_DASHBOARD); loginActionUrl.setParameter(_58_REDIRECT, RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get(INTRANET) + RegistrationConstants.REGISTRATION_DASHBOARD); actionResponse.sendRedirect(loginActionUrl.toString()); } } } } else { log.info("else redirected page is " + PortalUtil.getPortalURL(httpOriginalreq) + RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get("INTERNET") + RegistrationConstants.REGISTRATION_DASHBOARD); loginActionUrl.setParameter(_58_REDIRECT, RegistrationConstants.REGISTRATION_GROUP + PropsUtil.get("INTERNET") + RegistrationConstants.REGISTRATION_DASHBOARD); actionResponse.sendRedirect(loginActionUrl.toString()); } } } catch (STOXXException e) { log.error("STOXXException createActivationLink", e); } catch (Exception e) { log.error("Exception createActivationLink", e); try { registrationDelegator.deleteUser(registrationBean.getBusinessEmailAddress(), themeDisplay.getCompanyId()); } catch (STOXXException e1) { log.info("the delete user STOXXException ", e1); } log.error("Exception in setupProfileAction" + e.getMessage(), e); } }
From source file:com.stoxx.portlet.manageusers.controller.ManageUsersController.java
@ActionMapping(params = "action=SUSPEND") public void suspendUserAction(@RequestParam String userID, @ModelAttribute(MANAGEUSERSBEAN) ManageUsersBean manageUsersBean, ActionRequest actionRequest, ActionResponse actionResponse, Model model) { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); try {//from w ww .jav a2 s.co m manageUsersDeligate.suspendUser(userID); } catch (STOXXException e) { log.error(e.getMessage(), e); } List<String> roleNameList = new ArrayList<String>(); roleNameList.add(PropsUtil.get("stoxx.user.role.gateway.role")); try { User suspendeduser = UserLocalServiceUtil.fetchUser(Long.valueOf(userID)); Set<User> userIds = SendNotificationUtil.getuserByRoleName(themeDisplay.getCompanyId(), themeDisplay.getUserId(), roleNameList); if (Validator.isNotNull(suspendeduser)) { String message = LanguageUtil.get(themeDisplay.getLocale(), "notification_for_suspend_user1") + " " + suspendeduser.getFullName() + " " + LanguageUtil.get(themeDisplay.getLocale(), "notification_for_suspend_user2"); sendnotification(themeDisplay, userIds, message); if (actionRequest.getParameter(PAGE_NAME) != null && actionRequest.getParameter(PAGE_NAME).equalsIgnoreCase(STAFF_USERS)) { actionResponse.setRenderParameter(REDIRECTED_PAGE, STAFF); } else if (actionRequest.getParameter(PAGE_NAME) != null && actionRequest.getParameter(PAGE_NAME).equalsIgnoreCase(GENERAL_USERS)) { actionResponse.setRenderParameter(REDIRECTED_PAGE, GENERAL_USER); } else { redirectTranslatorCompanyUser(actionRequest, actionResponse); } } } catch (SystemException e) { log.error(e.getMessage(), e); } catch (IOException e) { log.error(e.getMessage(), e); } catch (PortletException e) { log.error(e.getMessage(), e); } catch (PortalException e) { log.error(e.getMessage(), e); } }
From source file:com.stoxx.portlet.preregcustomeradmin.delegate.CustomerAdminDelegate.java
private void sendActivationEmailToKeyAccountHolder(String emailAddress, String ownActivationLink, String accountDetailLink, Locale locale) throws SystemException, MessagingException { Map<String, Object> emailBodyMap = new HashMap<String, Object>(); emailBodyMap.put("userActivationLink", ownActivationLink); emailBodyMap.put("staffActivationLink", accountDetailLink); emailBodyMap.put("fromName", PrefsPropsUtil.getString("stoxx-mail-from-name")); emailBodyMap.put("fromAddress", PropsUtil.get("stoxx-prereg-customer-admin-mail-from-address")); emailBodyMap.put("portalURL", PrefsPropsUtil.getString("stoxx-mail-from-url")); log.info("Sending activation link to key account holder user " + emailAddress); sendActivationEmail(emailAddress, locale, emailBodyMap, "templates/translatorActivationMail.vm"); }
From source file:com.stoxx.portlet.preregcustomeradmin.delegate.CustomerAdminDelegate.java
private void sendActivationEmailToCustomer(String emailAddress, String ownActivationLink, Locale locale) throws SystemException, MessagingException { Map<String, Object> emailBodyMap = new HashMap<String, Object>(); emailBodyMap.put("userActivationLink", ownActivationLink); emailBodyMap.put("fromName", PrefsPropsUtil.getString("stoxx-mail-from-name")); emailBodyMap.put("fromAddress", PropsUtil.get("stoxx-prereg-customer-admin-mail-from-address")); emailBodyMap.put("portalURL", PrefsPropsUtil.getString("stoxx-mail-from-url")); log.info("Sending activation link to customer user " + emailAddress); sendActivationEmail(emailAddress, locale, emailBodyMap, "templates/customerActivationMail.vm"); }
From source file:com.stoxx.portlet.preregcustomeradmin.delegate.CustomerAdminDelegate.java
private void sendActivationEmail(String emailAddress, Locale locale, Map<String, Object> emailBodyMap, String emailVelocityTemplate) throws MessagingException { stoxxMailUtil.sendEmailNotification(emailAddress, PropsUtil.get("stoxx-prereg-customer-admin-mail-from-address"), emailVelocityTemplate, LanguageUtil.get(locale, "stoxx-prereg-email-subject"), emailBodyMap); }
From source file:com.student.services.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }//from ww w . j ava 2s . c o m synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "studentmgmt-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil.get("studentmgmt-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "studentmgmt-portlet"; } return _servletContextName; } }
From source file:com.StudentAvailability.slayer.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }/*from w w w .j av a 2 s . co m*/ synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "Availability-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil.get("Availability-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "Availability-portlet"; } return _servletContextName; } }
From source file:com.subscriberapprove.service.ClpSerializer.java
License:Open Source License
public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; }/*from ww w.j a v a 2 s. co m*/ synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "Subscriberapprove-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil .get("Subscriberapprove-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "Subscriberapprove-portlet"; } return _servletContextName; } }
From source file:com.sympo.antivirus.EsetAntivirusScannerImpl.java
License:Open Source License
public void scan(File file) throws AntivirusScannerException, SystemException { Runtime runtime = Runtime.getRuntime(); String filePath = file.getAbsolutePath(); String antivirusExecutePath = PropsUtil.get("antivirus.execute.path"); String[] parameters = new String[] { antivirusExecutePath, filePath }; Process process = null;// w w w. ja v a2s . c o m try { process = runtime.exec(parameters); InputStream inputStream = process.getInputStream(); String scanResult = StringUtil.read(inputStream); process.waitFor(); int exitValue = process.exitValue(); if (exitValue == EsetAntivirusScannerConstants.VIRUS_FOUND) { if (_log.isErrorEnabled()) { _log.error(scanResult); } throw new AntivirusScannerException("Virus detected in " + filePath); } else if (exitValue == EsetAntivirusScannerConstants.CANNOT_SCAN_DOCUMENT) { if (_log.isErrorEnabled()) { _log.error(scanResult); } throw new AntivirusScannerException("Couldn't scan file in " + filePath); } else if (exitValue != EsetAntivirusScannerConstants.VIRUS_NOT_FOUND) { if (_log.isErrorEnabled()) { _log.error(scanResult); } throw new AntivirusScannerException("Some error ocurred while trying to analyze file " + filePath); } } catch (IOException ioe) { throw new SystemException("Unable to scan file", ioe); } catch (InterruptedException ie) { throw new SystemException("Unable to scan file", ie); } finally { if (process != null) { process.destroy(); } } }