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.liferay.contacts.contactscenter.portlet.ContactsCenterPortlet.java
License:Open Source License
protected void updateProfile(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); User user = themeDisplay.getUser();// w w w . jav a 2s . c o m boolean deleteLogo = ParamUtil.getBoolean(actionRequest, "deleteLogo"); if (deleteLogo) { UserServiceUtil.deletePortrait(user.getUserId()); } String comments = BeanParamUtil.getString(user, actionRequest, "comments"); String emailAddress = BeanParamUtil.getString(user, actionRequest, "emailAddress"); String firstName = BeanParamUtil.getString(user, actionRequest, "firstName"); String jobTitle = BeanParamUtil.getString(user, actionRequest, "jobTitle"); String lastName = BeanParamUtil.getString(user, actionRequest, "lastName"); String middleName = BeanParamUtil.getString(user, actionRequest, "middleName"); String screenName = BeanParamUtil.getString(user, actionRequest, "screenName"); Contact contact = user.getContact(); String aimSn = BeanParamUtil.getString(contact, actionRequest, "aimSn"); String facebookSn = BeanParamUtil.getString(contact, actionRequest, "facebookSn"); String icqSn = BeanParamUtil.getString(contact, actionRequest, "icqSn"); String jabberSn = BeanParamUtil.getString(contact, actionRequest, "jabberSn"); String msnSn = BeanParamUtil.getString(contact, actionRequest, "msnSn"); String mySpaceSn = BeanParamUtil.getString(contact, actionRequest, "mySpaceSn"); String skypeSn = BeanParamUtil.getString(contact, actionRequest, "skypeSn"); String smsSn = BeanParamUtil.getString(contact, actionRequest, "smsSn"); String twitterSn = BeanParamUtil.getString(contact, actionRequest, "twitterSn"); String ymSn = BeanParamUtil.getString(contact, actionRequest, "ymSn"); Calendar cal = CalendarFactoryUtil.getCalendar(); cal.setTime(user.getBirthday()); int birthdayDay = cal.get(Calendar.DATE); int birthdayMonth = cal.get(Calendar.MONTH); int birthdayYear = cal.get(Calendar.YEAR); List<AnnouncementsDelivery> announcementsDeliveries = AnnouncementsDeliveryLocalServiceUtil .getUserDeliveries(user.getUserId()); UserServiceUtil.updateUser(user.getUserId(), user.getPasswordUnencrypted(), user.getPasswordUnencrypted(), user.getPasswordUnencrypted(), user.getPasswordReset(), user.getReminderQueryQuestion(), user.getReminderQueryAnswer(), screenName, emailAddress, user.getFacebookId(), user.getOpenId(), user.getLanguageId(), user.getTimeZoneId(), user.getGreeting(), comments, firstName, middleName, lastName, contact.getPrefixId(), contact.getSuffixId(), user.isMale(), birthdayMonth, birthdayDay, birthdayYear, smsSn, aimSn, facebookSn, icqSn, jabberSn, msnSn, mySpaceSn, skypeSn, twitterSn, ymSn, jobTitle, user.getGroupIds(), user.getOrganizationIds(), user.getRoleIds(), null, user.getUserGroupIds(), user.getAddresses(), null, user.getPhones(), user.getWebsites(), announcementsDeliveries, new ServiceContext()); }
From source file:com.liferay.contacts.contactscenter.portlet.ContactsCenterPortlet.java
License:Open Source License
protected void updateWebsites(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); User user = themeDisplay.getUser();/* w w w .jav a 2 s. c o m*/ List<Website> websites = UsersAdminUtil.getWebsites(actionRequest); UsersAdminUtil.updateWebsites(Contact.class.getName(), user.getContactId(), websites); }
From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.java
License:Open Source License
public void addSocialRelation(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long[] userIds = getUserIds(actionRequest); int type = ParamUtil.getInteger(actionRequest, "type"); if (type == SocialRelationConstants.TYPE_BI_CONNECTION) { return;/* w w w . ja v a 2s . c o m*/ } for (long userId : userIds) { if (userId == themeDisplay.getUserId()) { continue; } boolean blocked = socialRelationLocalService.hasRelation(userId, themeDisplay.getUserId(), SocialRelationConstants.TYPE_UNI_ENEMY); if (type == SocialRelationConstants.TYPE_UNI_ENEMY) { socialRelationLocalService.deleteRelations(themeDisplay.getUserId(), userId); socialRelationLocalService.deleteRelations(userId, themeDisplay.getUserId()); } else if (blocked) { continue; } socialRelationLocalService.addRelation(themeDisplay.getUserId(), userId, type); if (blocked) { socialRelationLocalService.addRelation(userId, themeDisplay.getUserId(), type); } } }
From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.java
License:Open Source License
public void deleteSocialRelation(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long[] userIds = getUserIds(actionRequest); int type = ParamUtil.getInteger(actionRequest, "type"); for (long userId : userIds) { if (userId == themeDisplay.getUserId()) { continue; }/*w w w .j a va2 s . c o m*/ try { socialRelationLocalService.deleteRelation(themeDisplay.getUserId(), userId, type); } catch (NoSuchRelationException nsre) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(nsre, nsre); } } } }
From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.java
License:Open Source License
public void getSelectedContacts(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); long[] userIds = StringUtil.split(ParamUtil.getString(resourceRequest, "userIds"), 0L); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (long userId : userIds) { try {/* w w w .j a v a2 s . c o m*/ JSONObject userJSONObject = JSONFactoryUtil.createJSONObject(); userJSONObject.put("success", Boolean.TRUE); userJSONObject.put("user", getUserJSONObject(resourceResponse, themeDisplay, userId)); jsonArray.put(userJSONObject); } catch (NoSuchUserException nsue) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(nsue, nsue); } } } jsonObject.put("contacts", jsonArray); writeJSON(resourceRequest, resourceResponse, jsonObject); }
From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.java
License:Open Source License
public void requestSocialRelation(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long[] userIds = getUserIds(actionRequest); int type = ParamUtil.getInteger(actionRequest, "type"); for (long userId : userIds) { if (userId == themeDisplay.getUserId()) { continue; }/*from ww w. ja v a2 s .c o m*/ if (socialRelationLocalService.hasRelation(userId, themeDisplay.getUserId(), SocialRelationConstants.TYPE_BI_CONNECTION) || socialRelationLocalService.hasRelation(userId, themeDisplay.getUserId(), SocialRelationConstants.TYPE_UNI_ENEMY) || socialRequestLocalService.hasRequest(themeDisplay.getUserId(), User.class.getName(), themeDisplay.getUserId(), type, userId, SocialRequestConstants.STATUS_PENDING)) { continue; } JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); String portletId = portal.getPortletId(actionRequest); extraDataJSONObject.put("portletId", PortletIdCodec.decodePortletName(portletId)); SocialRequest socialRequest = socialRequestLocalService.addRequest(themeDisplay.getUserId(), 0, User.class.getName(), themeDisplay.getUserId(), type, extraDataJSONObject.toString(), userId); sendNotificationEvent(socialRequest); } }
From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.java
License:Open Source License
public void updateEntry(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); String redirect = ParamUtil.getString(actionRequest, "redirect"); long entryId = ParamUtil.getLong(actionRequest, "entryId"); String fullName = ParamUtil.getString(actionRequest, "fullName"); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); String comments = ParamUtil.getString(actionRequest, "comments"); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); String message = null;//from w w w .ja va 2s. co m try { Entry entry = null; if (entryId > 0) { entry = entryLocalService.getEntry(entryId); if (entry.getUserId() == themeDisplay.getUserId()) { entry = entryLocalService.updateEntry(entryId, fullName, emailAddress, comments); message = "you-have-successfully-updated-the-contact"; } } else { entry = entryLocalService.addEntry(themeDisplay.getUserId(), fullName, emailAddress, comments); message = "you-have-successfully-added-a-new-contact"; } jsonObject.put("contact", getEntryJSONObject(actionResponse, themeDisplay, entry, redirect)); JSONObject contactsJSONObject = getContactsJSONObject(actionRequest, actionResponse); jsonObject.put("contactList", contactsJSONObject); jsonObject.put("success", Boolean.TRUE); } catch (Exception e) { if (e instanceof ContactFullNameException) { message = "full-name-cannot-be-empty"; } else if (e instanceof DuplicateEntryEmailAddressException) { message = "there-is-already-a-contact-with-this-email-address"; } else if (e instanceof EntryEmailAddressException) { message = "please-enter-a-valid-email-address"; } else { message = "an-error-occurred-while-processing-the-requested-resource"; } jsonObject.put("success", Boolean.FALSE); } jsonObject.put("message", translate(actionRequest, message)); writeJSON(actionRequest, actionResponse, jsonObject); }
From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.java
License:Open Source License
public void updateSocialRequest(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long socialRequestId = ParamUtil.getLong(actionRequest, "socialRequestId"); int status = ParamUtil.getInteger(actionRequest, "status"); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); try {/* w ww. j a v a 2 s . c o m*/ SocialRequest socialRequest = socialRequestLocalService.getSocialRequest(socialRequestId); if (socialRelationLocalService.hasRelation(socialRequest.getReceiverUserId(), socialRequest.getUserId(), SocialRelationConstants.TYPE_UNI_ENEMY)) { status = SocialRequestConstants.STATUS_IGNORE; } socialRequestLocalService.updateRequest(socialRequestId, status, themeDisplay); if (status == SocialRequestConstants.STATUS_CONFIRM) { socialRelationLocalService.addRelation(socialRequest.getUserId(), socialRequest.getReceiverUserId(), socialRequest.getType()); } jsonObject.put("success", Boolean.TRUE); } catch (Exception e) { jsonObject.put("success", Boolean.FALSE); } writeJSON(actionRequest, actionResponse, jsonObject); }
From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.java
License:Open Source License
protected void deleteEntry(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long entryId = ParamUtil.getLong(actionRequest, "entryId"); if (entryId > 0) { Entry entry = entryLocalService.getEntry(entryId); if (entry.getUserId() == themeDisplay.getUserId()) { entryLocalService.deleteEntry(entryId); }//from w w w. ja va 2s . co m } }
From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.java
License:Open Source License
protected JSONObject getContactsJSONObject(PortletRequest portletRequest, PortletResponse portletResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); String redirect = ParamUtil.getString(portletRequest, "redirect"); String filterBy = ParamUtil.getString(portletRequest, "filterBy"); String keywords = ParamUtil.getString(portletRequest, "keywords"); int start = ParamUtil.getInteger(portletRequest, "start"); int end = ParamUtil.getInteger(portletRequest, "end"); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); JSONObject optionsJSONObject = JSONFactoryUtil.createJSONObject(); optionsJSONObject.put("end", end); optionsJSONObject.put("filterBy", filterBy); optionsJSONObject.put("keywords", keywords); optionsJSONObject.put("start", start); jsonObject.put("options", optionsJSONObject); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); if (filterBy.equals(ContactsConstants.FILTER_BY_DEFAULT) && !portletId.equals(ContactsPortletKeys.MEMBERS)) { List<BaseModel<?>> contacts = entryLocalService.searchUsersAndContacts(themeDisplay.getCompanyId(), themeDisplay.getUserId(), keywords, start, end); int contactsCount = entryLocalService.searchUsersAndContactsCount(themeDisplay.getCompanyId(), themeDisplay.getUserId(), keywords); jsonObject.put("count", contactsCount); for (BaseModel<?> contact : contacts) { JSONObject contactJSONObject = null; if (contact instanceof User) { contactJSONObject = getUserJSONObject(portletResponse, themeDisplay, (User) contact); } else { contactJSONObject = getEntryJSONObject(portletResponse, themeDisplay, (Entry) contact, redirect);//from w w w . ja v a2 s . c o m } jsonArray.put(contactJSONObject); } } else if (filterBy.equals(ContactsConstants.FILTER_BY_FOLLOWERS) && !portletId.equals(ContactsPortletKeys.MEMBERS)) { List<SocialRelation> socialRelations = socialRelationLocalService.getInverseRelations( themeDisplay.getUserId(), SocialRelationConstants.TYPE_UNI_FOLLOWER, start, end); for (SocialRelation socialRelation : socialRelations) { jsonArray.put(getUserJSONObject(portletResponse, themeDisplay, socialRelation.getUserId1())); } } else if (filterBy.equals(ContactsConstants.FILTER_BY_TYPE_MY_CONTACTS) && !portletId.equals(ContactsPortletKeys.MEMBERS)) { List<Entry> entries = entryLocalService.search(themeDisplay.getUserId(), keywords, start, end); int entriesCount = entryLocalService.searchCount(themeDisplay.getUserId(), keywords); jsonObject.put("count", entriesCount); for (Entry entry : entries) { JSONObject contactJSONObject = getEntryJSONObject(portletResponse, themeDisplay, entry, redirect); jsonArray.put(contactJSONObject); } } else { LinkedHashMap<String, Object> params = new LinkedHashMap<>(); params.put("inherit", Boolean.TRUE); Group group = themeDisplay.getScopeGroup(); Layout layout = themeDisplay.getLayout(); if (group.isUser() && layout.isPublicLayout()) { params.put("socialRelationType", new Long[] { group.getClassPK(), (long) SocialRelationConstants.TYPE_BI_CONNECTION }); } else if (filterBy.startsWith(ContactsConstants.FILTER_BY_TYPE)) { params.put("socialRelationType", new Long[] { themeDisplay.getUserId(), ContactsUtil.getSocialRelationType(filterBy) }); } if (portletId.equals(ContactsPortletKeys.MEMBERS)) { params.put("usersGroups", group.getGroupId()); } else if (filterBy.startsWith(ContactsConstants.FILTER_BY_GROUP)) { params.put("usersGroups", ContactsUtil.getGroupId(filterBy)); } List<User> usersList = null; if (filterBy.equals(ContactsConstants.FILTER_BY_ADMINS)) { Role siteAdministratorRole = roleLocalService.getRole(group.getCompanyId(), RoleConstants.SITE_ADMINISTRATOR); params.put("userGroupRole", new Long[] { group.getGroupId(), siteAdministratorRole.getRoleId() }); Set<User> users = new HashSet<>(); users.addAll(userLocalService.search(themeDisplay.getCompanyId(), keywords, WorkflowConstants.STATUS_APPROVED, params, QueryUtil.ALL_POS, QueryUtil.ALL_POS, (OrderByComparator) null)); Role siteOwnerRole = roleLocalService.getRole(group.getCompanyId(), RoleConstants.SITE_OWNER); params.put("userGroupRole", new Long[] { group.getGroupId(), siteOwnerRole.getRoleId() }); users.addAll(userLocalService.search(themeDisplay.getCompanyId(), keywords, WorkflowConstants.STATUS_APPROVED, params, QueryUtil.ALL_POS, QueryUtil.ALL_POS, (OrderByComparator) null)); usersList = new ArrayList<>(users); ListUtil.sort(usersList, new UserLastNameComparator(true)); } else { int usersCount = userLocalService.searchCount(themeDisplay.getCompanyId(), keywords, WorkflowConstants.STATUS_APPROVED, params); jsonObject.put("count", usersCount); usersList = userLocalService.search(themeDisplay.getCompanyId(), keywords, WorkflowConstants.STATUS_APPROVED, params, start, end, new UserLastNameComparator(true)); } for (User user : usersList) { JSONObject userJSONObject = getUserJSONObject(portletResponse, themeDisplay, user); jsonArray.put(userJSONObject); } } jsonObject.put("users", jsonArray); return jsonObject; }