List of usage examples for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY
String THEME_DISPLAY
To view the source code for com.liferay.portal.kernel.util WebKeys THEME_DISPLAY.
Click Source Link
From source file:com.knowarth.portlets.themepersonalizer.ThemePersonalizerPortlet.java
License:Open Source License
@Override public void serveResource(ResourceRequest request, ResourceResponse response) throws PortletException, IOException { response.setContentType("text/html"); JSONArray array = JSONFactoryUtil.createJSONArray(); String themeId = request.getParameter(PARAM_SELECTED_THEME_ID); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Theme themeObject = ThemeLocalServiceUtil.fetchTheme(themeDisplay.getCompanyId(), themeId); if (Validator.isNotNull(themeObject)) { Map<String, ColorScheme> colorSchemeMap = themeObject.getColorSchemesMap(); for (String colorSchemeId : colorSchemeMap.keySet()) { JSONObject colorScheme = JSONFactoryUtil.createJSONObject(); colorScheme.put("colorSchemeId", colorSchemeId); colorScheme.put("colorSchemeName", colorSchemeMap.get(colorSchemeId).getName()); array.put(colorScheme);//from www . ja v a 2 s .co m } } PrintWriter writer = response.getWriter(); writer.write(array.toString()); }
From source file:com.labimo.portlet.LicenseManage.java
@Override public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { String action = (String) renderRequest.getAttribute("action"); System.out.println("action" + action); String screenName = (String) renderRequest.getAttribute("screenName"); System.out.println("screenName" + screenName); Boolean flag = false;/*from www. ja v a 2s. c o m*/ try { ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest .getAttribute(com.liferay.portal.kernel.util.WebKeys.THEME_DISPLAY); User currentUser = PortalUtil.getUser(renderRequest); if (currentUser != null) { List<UserGroup> userGroups = UserGroupLocalServiceUtil.getUserUserGroups(themeDisplay.getUserId()); for (UserGroup group : userGroups) { System.out.println(group.getName()); if (manageGroup.equals(group.getName())) { flag = true; } } List<License> licenseList = new ArrayList<License>(); if (flag) { if (Validator.isBlank(screenName)) { licenseList = LicenseLocalServiceUtil.getLicenses(0, queryMax); } else { screenName = "%" + screenName + "%"; DynamicQuery userQuery = DynamicQueryFactoryUtil.forClass(User.class) .add(PropertyFactoryUtil.forName("screenName").like(screenName)); userQuery.setLimit(0, queryMax); List<User> userList = UserLocalServiceUtil.dynamicQuery(userQuery); List<Long> userIdList = new ArrayList<Long>(); for (User user : userList) { userIdList.add(user.getUserId()); } DynamicQuery query = DynamicQueryFactoryUtil.forClass(License.class) .add(PropertyFactoryUtil.forName("userId").in(userIdList)); licenseList = LicenseLocalServiceUtil.dynamicQuery(query); } } else { DynamicQuery query = DynamicQueryFactoryUtil.forClass(License.class) .add(PropertyFactoryUtil.forName("userId").eq(currentUser.getUserId())); licenseList = LicenseLocalServiceUtil.dynamicQuery(query); } System.out.println(licenseList.size()); renderRequest.setAttribute("licenseList", licenseList); } renderRequest.setAttribute("flag", flag); } catch (Exception e) { e.printStackTrace(); } System.out.println("flag" + flag); if (flag) { super.doView(renderRequest, renderResponse); } else { include("/userView.jsp", renderRequest, renderResponse); } }
From source file:com.labimo.portlet.LicenseManage.java
@ProcessAction(name = "addLicense") public void addLicense(ActionRequest actionRequest, ActionResponse response) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat(liferay_pattern); User currentUser = PortalUtil.getUser(actionRequest); Utils utils = new Utils(); long userId = ParamUtil.getLong(actionRequest, "userId"); // String hardwareUuid = ParamUtil.getString(actionRequest, // "hardwareUuid"); Date issueDate = ParamUtil.getDate(actionRequest, "issueDate", sdf); Date validDate = ParamUtil.getDate(actionRequest, "validDate", sdf); // Integer issue_day = ParamUtil.getInteger(actionRequest, "issue_day"); // Integer issue_month = ParamUtil.getInteger(actionRequest, // "issue_month"); // Integer issue_year = ParamUtil.getInteger(actionRequest, // "issue_year"); // Calendar issueCalendar = Calendar.getInstance(); // issueCalendar.set(issue_year, issue_month, issue_day, 0, 0, 0); // issueDate =issueCalendar.getTime(); ////from www .ja v a2 s.co m // Integer valid_day = ParamUtil.getInteger(actionRequest, "valid_day"); // Integer valid_month = ParamUtil.getInteger(actionRequest, // "valid_month"); // Integer valid_year = ParamUtil.getInteger(actionRequest, // "valid_year"); // Calendar validCalendar = Calendar.getInstance(); // validCalendar.set(valid_year, valid_month, valid_day, 0, 0, 0); // validDate = validCalendar.getTime(); long currentTime = new Date().getTime(); System.out.println("userId = " + userId); // System.out.println("hardwareUuid = " + hardwareUuid); System.out.println("issueDate = " + issueDate); System.out.println("validDate = " + validDate); User user = UserLocalServiceUtil.fetchUser(userId); if (Validator.isNotNull(user) && validDate.after(issueDate) && validDate.getTime() > currentTime) { License ChargesLincense = new LicenseImpl(); String licenseId = LicenseUtils.getCustomUuid(UUID.randomUUID()); ChargesLincense.setLicenseUuid(licenseId); ChargesLincense.setIssueDate(issueDate); ChargesLincense.setValidDate(validDate); ChargesLincense.setUserId(userId); ChargesLincense.setValid(true); ChargesLincense.setCreateDate(new Date()); ChargesLincense.setModifiedDate(new Date()); LicenseLocalServiceUtil.addLicense(ChargesLincense); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long gourpId = themeDisplay.getScopeGroupId(); JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", currentUser.getScreenName() + LicenseConstants.ADD_LICENSE_MSG + ChargesLincense.getLicenseUuid()); SocialActivityLocalServiceUtil.addActivity(currentUser.getUserId(), gourpId, LicenseConstants.LICENSE_CLASS_NAME, LicenseConstants.LICENSE_CLASS_NAME_ID, LicenseConstants.ADD_LICENSE, extraDataJSONObject.toString(), 0); } }
From source file:com.labimo.portlet.LicenseManage.java
@ProcessAction(name = "updateLicense") public void updateLicense(ActionRequest actionRequest, ActionResponse response) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat(liferay_pattern); User currentUser = PortalUtil.getUser(actionRequest); Utils utils = new Utils(); long userId = ParamUtil.getLong(actionRequest, "userId"); String licenseUuid = ParamUtil.getString(actionRequest, "licenseUuid"); licenseUuid = LicenseUtils.formatToString(licenseUuid); String hardwareUuid = ParamUtil.getString(actionRequest, "hardwareUuid"); Boolean valid = ParamUtil.getBoolean(actionRequest, "valid"); Date issueDate = ParamUtil.getDate(actionRequest, "issueDate", sdf); Date validDate = ParamUtil.getDate(actionRequest, "validDate", sdf); long currentTime = new Date().getTime(); System.out.println("userId = " + userId); System.out.println("licenseUuid = " + licenseUuid); System.out.println("issueDate = " + issueDate); System.out.println("hardwareUuid = " + hardwareUuid); System.out.println("validDate = " + validDate); System.out.println("valid = " + valid + " valid=" + ParamUtil.getString(actionRequest, "valid")); License license = LicenseLocalServiceUtil.getLicense(licenseUuid); if (license != null && license.getUserId() == userId && validDate.after(issueDate) && validDate.getTime() > currentTime) { System.out.println("======"); license.setModifiedDate(new Date()); license.setIssueDate(issueDate); license.setValidDate(validDate); license.setValid(valid);/*from ww w . ja v a2s . c o m*/ LicenseLocalServiceUtil.updateLicense(license); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long gourpId = themeDisplay.getScopeGroupId(); JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", currentUser.getScreenName() + LicenseConstants.UPDATE_LICENSE_MSG + license.getLicenseUuid()); SocialActivityLocalServiceUtil.addActivity(currentUser.getUserId(), gourpId, LicenseConstants.LICENSE_CLASS_NAME, LicenseConstants.LICENSE_CLASS_NAME_ID, LicenseConstants.UPDATE_LICENSE, extraDataJSONObject.toString(), 0); } }
From source file:com.liferay.adaptive.media.image.taglib.servlet.taglib.AMImageImgTag.java
License:Open Source License
private String _getFallbackTag() throws PortalException { Map<String, Object> dynamicAttributes = getDynamicAttributes(); StringBundler sb = new StringBundler(4 + (4 * dynamicAttributes.size())); sb.append("<img "); for (Map.Entry<String, Object> entry : dynamicAttributes.entrySet()) { sb.append(entry.getKey());// w w w . j a va 2 s.c o m sb.append("=\""); Object value = entry.getValue(); sb.append(HtmlUtil.escapeAttribute(value.toString())); sb.append("\" "); } ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String downloadURL = DLUtil.getPreviewURL(_fileVersion.getFileEntry(), _fileVersion, themeDisplay, StringPool.BLANK); sb.append("src=\""); sb.append(downloadURL); sb.append("\" />"); return sb.toString(); }
From source file:com.liferay.adaptive.media.image.web.internal.servlet.taglib.AMPictureDynamicInclude.java
License:Open Source License
@Override public void include(HttpServletRequest request, HttpServletResponse response, String key) throws IOException { if (BrowserSnifferUtil.isIe(request)) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PrintWriter printWriter = response.getWriter(); StringBundler sb = new StringBundler(7); sb.append("<script src=\""); sb.append(themeDisplay.getPortalURL()); sb.append(_portal.getPathProxy()); sb.append(_servletContext.getContextPath()); sb.append("/picturefill.min.js\" "); sb.append("type= \"text/javascript\">"); sb.append("</script>"); printWriter.println(sb.toString()); }//ww w . ja v a 2 s.c om }
From source file:com.liferay.adaptive.media.image.web.servlet.taglib.AdaptiveMediaPictureDynamicInclude.java
License:Open Source License
@Override public void include(HttpServletRequest request, HttpServletResponse response, String key) throws IOException { if (BrowserSnifferUtil.isIe(request)) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PrintWriter printWriter = response.getWriter(); StringBundler sb = new StringBundler(7); sb.append("<script src=\""); sb.append(themeDisplay.getPortalURL()); sb.append(_portal.getPathProxy()); sb.append(_servletContext.getContextPath()); sb.append("/picturefill.js\" "); sb.append("type= \"text/javascript\">"); sb.append("</script>"); printWriter.println(sb.toString()); }/* www. j a v a2s . com*/ }
From source file:com.liferay.adaptive.media.web.internal.portlet.action.AdaptedImagesPercentageMVCResourceCommand.java
License:Open Source License
@Override protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); long companyId = themeDisplay.getCompanyId(); String entryUuid = ParamUtil.getString(resourceRequest, "entryUuid"); int entriesCount = _adaptiveMediaImageEntryLocalService.getAdaptiveMediaImageEntriesCount(companyId, entryUuid);/*w w w . j a va2 s . com*/ int expectedEntriesCount = _adaptiveMediaImageEntryLocalService .getExpectedAdaptiveMediaImageEntriesCount(companyId); jsonObject.put("adaptedImages", String.valueOf(entriesCount)); jsonObject.put("totalImages", String.valueOf(expectedEntriesCount)); JSONPortletResponseUtil.writeJSON(resourceRequest, resourceResponse, jsonObject); }
From source file:com.liferay.adaptive.media.web.internal.portlet.action.BaseMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); _checkPermission(themeDisplay.getPermissionChecker()); doPermissionCheckedProcessAction(actionRequest, actionResponse); }
From source file:com.liferay.adaptive.media.web.internal.portlet.action.DeleteImageConfigurationEntryMVCActionCommand.java
License:Open Source License
@Override protected void doPermissionCheckedProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String[] deleteAdaptiveMediaImageConfigurationEntryUuids = ParamUtil.getStringValues(actionRequest, "rowIdsAdaptiveMediaImageConfigurationEntry"); List<AdaptiveMediaImageConfigurationEntry> deletedConfigurationEntries = new ArrayList<>(); for (String deleteAdaptiveMediaImageConfigurationEntryUuid : deleteAdaptiveMediaImageConfigurationEntryUuids) { Optional<AdaptiveMediaImageConfigurationEntry> configurationEntryOptional = _adaptiveMediaImageConfigurationHelper .getAdaptiveMediaImageConfigurationEntry(themeDisplay.getCompanyId(), deleteAdaptiveMediaImageConfigurationEntryUuid); _adaptiveMediaImageConfigurationHelper.deleteAdaptiveMediaImageConfigurationEntry( themeDisplay.getCompanyId(), deleteAdaptiveMediaImageConfigurationEntryUuid); configurationEntryOptional.ifPresent(deletedConfigurationEntries::add); }/*from w w w . j ava2 s . co m*/ SessionMessages.add(actionRequest, "configurationEntriesDeleted", deletedConfigurationEntries); }