List of usage examples for com.liferay.portal.kernel.util PortalClassInvoker invoke
public static Object invoke(MethodKey methodKey, Object... arguments) throws Exception
From source file:com.liferay.marketplace.util.MarketplaceLicenseUtil.java
License:Open Source License
public static String getOrder(String productEntryName) throws Exception { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); jsonObject.put("cmd", "GET_ORDER"); jsonObject.put("hostName", LicenseManagerUtil.getHostName()); jsonObject.put("ipAddresses", StringUtil.merge(LicenseManagerUtil.getIpAddresses())); jsonObject.put("macAddresses", StringUtil.merge(LicenseManagerUtil.getMacAddresses())); jsonObject.put("productEntryName", productEntryName); jsonObject.put("serverId", Arrays.toString(getServerIdBytes())); Thread currentThread = Thread.currentThread(); ClassLoader classLoader = currentThread.getContextClassLoader(); String response = null;/*from w w w . jav a 2 s .c om*/ try { currentThread.setContextClassLoader(PortalClassLoaderUtil.getClassLoader()); MethodKey methodKey = new MethodKey("com.liferay.portal.license.util.LicenseUtil", "sendRequest", String.class); response = (String) PortalClassInvoker.invoke(methodKey, jsonObject.toString()); } finally { currentThread.setContextClassLoader(classLoader); } JSONObject responseJSONObject = JSONFactoryUtil.createJSONObject(response); return responseJSONObject.getString("orderUuid"); }
From source file:com.vportal.portal.servlet.PortalSessionListener.java
License:Open Source License
protected void setCompanyId(long userId) throws Exception { MethodKey method = new MethodKey("com.liferay.portal.util.PortalInstances", "getCompanyIds"); long[] companyIds = (long[]) PortalClassInvoker.invoke(false, method); /*long[] companyIds = PortalInstances.getCompanyIds();*/ //long[] companyIds = PortalUtil.getCompanyIds(); long companyId = 0; if (companyIds.length == 1) { companyId = companyIds[0];// ww w.ja va 2 s . c o m } else if (companyIds.length > 1) { try { User user = UserLocalServiceUtil.getUserById(userId); companyId = user.getCompanyId(); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn("Unable to set the company id for user " + userId, e); } } } if (companyId > 0) { CompanyThreadLocal.setCompanyId(companyId); } }
From source file:m.omarh.liferay.resources.importer.generator.util.AutoDeployUtil.java
License:Open Source License
public static String getAutoDeployDestDir() { try {//from ww w . j a v a2 s . c o m return (String) PortalClassInvoker.invoke(false, _getAutoDeployDirMethodKey); } catch (Exception e) { _log.error(e.getMessage()); } return ""; }