List of usage examples for com.liferay.portal.kernel.util StringUtil equalsIgnoreCase
public static boolean equalsIgnoreCase(String s1, String s2)
true if the strings are equal, ignoring case. From source file:com.abubusoft.liferay.google.GoogleOAuth.java
License:Open Source License
protected User updateUser(User user, Userinfoplus userinfo) throws Exception { String emailAddress = userinfo.getEmail(); String firstName = userinfo.getGivenName(); String lastName = userinfo.getFamilyName(); boolean male = Validator.equals(userinfo.getGender(), "male"); if (emailAddress.equals(user.getEmailAddress()) && firstName.equals(user.getFirstName()) && lastName.equals(user.getLastName()) && (male == user.isMale())) { return user; }//from w w w.j a va 2 s. c o m Contact contact = user.getContact(); Calendar birthdayCal = CalendarFactoryUtil.getCalendar(); birthdayCal.setTime(contact.getBirthday()); int birthdayMonth = birthdayCal.get(Calendar.MONTH); int birthdayDay = birthdayCal.get(Calendar.DAY_OF_MONTH); int birthdayYear = birthdayCal.get(Calendar.YEAR); long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; List<UserGroupRole> userGroupRoles = null; long[] userGroupIds = null; ServiceContext serviceContext = new ServiceContext(); if (!StringUtil.equalsIgnoreCase(emailAddress, user.getEmailAddress())) { UserLocalServiceUtil.updateEmailAddress(user.getUserId(), StringPool.BLANK, emailAddress, emailAddress); } UserLocalServiceUtil.updateEmailAddressVerified(user.getUserId(), true); return UserLocalServiceUtil.updateUser(user.getUserId(), StringPool.BLANK, StringPool.BLANK, StringPool.BLANK, false, user.getReminderQueryQuestion(), user.getReminderQueryAnswer(), user.getScreenName(), emailAddress, 0, user.getOpenId(), user.getLanguageId(), user.getTimeZoneId(), user.getGreeting(), user.getComments(), firstName, user.getMiddleName(), lastName, contact.getPrefixId(), contact.getSuffixId(), male, birthdayMonth, birthdayDay, birthdayYear, contact.getSmsSn(), contact.getAimSn(), contact.getFacebookSn(), contact.getIcqSn(), contact.getJabberSn(), contact.getMsnSn(), contact.getMySpaceSn(), contact.getSkypeSn(), contact.getTwitterSn(), contact.getYmSn(), contact.getJobTitle(), groupIds, organizationIds, roleIds, userGroupRoles, userGroupIds, serviceContext); }
From source file:com.bemis.portal.inventory.model.impl.OrderInventoryImpl.java
License:Open Source License
/** * Check wether all batches sent from IBB in invalid. * Then we can remove this inventory out of our system. * @return//from w ww.ja va 2s .co m */ public void addOrderInventoryPallets(String specialStockCode, String stockTypeCde, String lotBatchNbr, double inventorySalesQty, Date manufacturingDte) { if (_specialStockCodes.contains(specialStockCode) && StringUtil.equalsIgnoreCase(_STOCK_TYPE_CODE, stockTypeCde)) { OrderInventoryBatch orderInventoryBatch = _orderInventoryBatches.get(lotBatchNbr); if (orderInventoryBatch == null) { orderInventoryBatch = new OrderInventoryBatchImpl(); orderInventoryBatch.setTotalBatchQty(0); _orderInventoryBatches.put(lotBatchNbr, orderInventoryBatch); } double totalQty = orderInventoryBatch.getTotalBatchQty() + inventorySalesQty; orderInventoryBatch.setBatchNo(lotBatchNbr); orderInventoryBatch.setTotalBatchQty(totalQty); orderInventoryBatch.setMfgDate(manufacturingDte); } }
From source file:com.cd.learning.hook.MBUtil.java
License:Open Source License
public static void collectPartContent(Part part, MBMailMessage mbMailMessage) throws Exception { Object partContent = part.getContent(); String contentType = StringUtil.toLowerCase(part.getContentType()); if ((part.getDisposition() != null) && StringUtil.equalsIgnoreCase(part.getDisposition(), MimeMessage.ATTACHMENT)) { if (_log.isDebugEnabled()) { _log.debug("Processing attachment"); }/*from ww w. j a va 2s . co m*/ byte[] bytes = null; if (partContent instanceof String) { bytes = ((String) partContent).getBytes(); } else if (partContent instanceof InputStream) { bytes = JavaMailUtil.getBytes(part); } mbMailMessage.addBytes(part.getFileName(), bytes); } else { if (partContent instanceof MimeMultipart) { MimeMultipart mimeMultipart = (MimeMultipart) partContent; collectMultipartContent(mimeMultipart, mbMailMessage); } else if (partContent instanceof String) { Map<String, Object> options = new HashMap<String, Object>(); options.put("emailPartToMBMessageBody", Boolean.TRUE); String messageBody = SanitizerUtil.sanitize(0, 0, 0, MBMessage.class.getName(), 0, contentType, Sanitizer.MODE_ALL, (String) partContent, options); if (contentType.startsWith(ContentTypes.TEXT_HTML)) { mbMailMessage.setHtmlBody(messageBody); } else { mbMailMessage.setPlainBody(messageBody); } } } }
From source file:com.custom.portal.security.ldap.CustomPortalLDAPImporterImpl.java
License:Open Source License
protected User updateUser(long companyId, CustomLDAPUser ldapUser, User user, Properties userMappings, Properties contactMappings, String password, String modifiedDate, boolean isNew) throws Exception { Date ldapUserModifiedDate = null; boolean passwordReset = ldapUser.isPasswordReset(); if (PrefsPropsUtil.getBoolean(companyId, PropsKeys.LDAP_EXPORT_ENABLED, PropsValues.LDAP_EXPORT_ENABLED)) { passwordReset = user.isPasswordReset(); }/*from w ww .j a va2 s .c o m*/ try { if (Validator.isNotNull(modifiedDate)) { ldapUserModifiedDate = LDAPUtil.parseDate(modifiedDate); if (ldapUserModifiedDate.equals(user.getModifiedDate())) { if (ldapUser.isAutoPassword()) { if (_log.isDebugEnabled()) { _log.debug("Skipping user " + user.getEmailAddress() + " because he is already synchronized"); } return user; } UserLocalServiceUtil.updatePassword(user.getUserId(), password, password, passwordReset, true); if (_log.isDebugEnabled()) { _log.debug("User " + user.getEmailAddress() + " is already synchronized, but updated " + "password to avoid a blank value"); } return user; } } else if (!isNew) { if (_log.isInfoEnabled()) { _log.info("Skipping user " + user.getEmailAddress() + " because the LDAP entry was never modified"); } return user; } } catch (ParseException pe) { if (_log.isDebugEnabled()) { _log.debug("Unable to parse LDAP modify timestamp " + modifiedDate, pe); } } if (!PropsValues.LDAP_IMPORT_USER_PASSWORD_ENABLED) { password = PropsValues.LDAP_IMPORT_USER_PASSWORD_DEFAULT; if (StringUtil.equalsIgnoreCase(password, _USER_PASSWORD_SCREEN_NAME)) { password = ldapUser.getScreenName(); } } if (Validator.isNull(ldapUser.getScreenName())) { ldapUser.setAutoScreenName(true); } if (ldapUser.isAutoScreenName()) { ScreenNameGenerator screenNameGenerator = ScreenNameGeneratorFactory.getInstance(); ldapUser.setScreenName( screenNameGenerator.generate(companyId, user.getUserId(), ldapUser.getEmailAddress())); } Calendar birthdayCal = CalendarFactoryUtil.getCalendar(); Contact ldapContact = ldapUser.getContact(); birthdayCal.setTime(ldapContact.getBirthday()); int birthdayMonth = birthdayCal.get(Calendar.MONTH); int birthdayDay = birthdayCal.get(Calendar.DAY_OF_MONTH); int birthdayYear = birthdayCal.get(Calendar.YEAR); if (ldapUser.isUpdatePassword()) { UserLocalServiceUtil.updatePassword(user.getUserId(), password, password, passwordReset, true); } updateLDAPUser(ldapUser.getUser(), ldapContact, user, userMappings, contactMappings); user = UserLocalServiceUtil.updateUser(user.getUserId(), password, StringPool.BLANK, StringPool.BLANK, passwordReset, ldapUser.getReminderQueryQuestion(), ldapUser.getReminderQueryAnswer(), ldapUser.getScreenName(), ldapUser.getEmailAddress(), ldapUser.getFacebookId(), ldapUser.getOpenId(), ldapUser.getLanguageId(), ldapUser.getTimeZoneId(), ldapUser.getGreeting(), ldapUser.getComments(), ldapUser.getFirstName(), ldapUser.getMiddleName(), ldapUser.getLastName(), ldapUser.getPrefixId(), ldapUser.getSuffixId(), ldapUser.isMale(), birthdayMonth, birthdayDay, birthdayYear, ldapUser.getSmsSn(), ldapUser.getAimSn(), ldapUser.getFacebookSn(), ldapUser.getIcqSn(), ldapUser.getJabberSn(), ldapUser.getMsnSn(), ldapUser.getMySpaceSn(), ldapUser.getSkypeSn(), ldapUser.getTwitterSn(), ldapUser.getYmSn(), ldapUser.getJobTitle(), ldapUser.getGroupIds(), ldapUser.getOrganizationIds(), ldapUser.getRoleIds(), ldapUser.getUserGroupRoles(), ldapUser.getUserGroupIds(), ldapUser.getServiceContext()); boolean hasBusinessPhone = false; for (Phone phone : user.getPhones()) { if (phone.getTypeId() == 11006) { hasBusinessPhone = true; break; } } if (!hasBusinessPhone && !ldapUser.getPhone().isEmpty()) { if (_log.isDebugEnabled()) { _log.debug("Adding Business phone: " + ldapUser.getPhone()); } PhoneLocalServiceUtil.addPhone(user.getUserId(), Contact.class.getName(), user.getContactId(), ldapUser.getPhone(), "", 11006, true, ldapUser.getServiceContext()); } boolean hasBusinessAddress = false; for (Address address : user.getAddresses()) { if (address.getTypeId() == 11000) { hasBusinessAddress = true; break; } } if (!hasBusinessAddress && !ldapUser.getStreet().isEmpty() && !ldapUser.getCity().isEmpty()) { if (_log.isDebugEnabled()) { _log.debug("Adding Business Address: " + ldapUser.getStreet() + " " + ldapUser.getCity() + " " + ldapUser.getZip()); } AddressLocalServiceUtil.addAddress(user.getUserId(), Contact.class.getName(), user.getContactId(), ldapUser.getStreet(), "", "", ldapUser.getCity(), ldapUser.getZip(), 0, 0, 11000, true, true, ldapUser.getServiceContext()); } user = UserLocalServiceUtil.updateStatus(user.getUserId(), ldapUser.getStatus()); if (ldapUserModifiedDate != null) { user = UserLocalServiceUtil.updateModifiedDate(user.getUserId(), ldapUserModifiedDate); } if (ldapUser.isUpdatePortrait()) { byte[] portraitBytes = ldapUser.getPortraitBytes(); if (ArrayUtil.isNotEmpty(portraitBytes)) { UserLocalServiceUtil.updatePortrait(user.getUserId(), portraitBytes); } else { UserLocalServiceUtil.deletePortrait(user.getUserId()); } } return user; }
From source file:com.fmdp.webform.portlet.WebFormPortlet.java
License:Open Source License
public void saveData(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); String portletId = PortalUtil.getPortletId(actionRequest); PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletId); boolean requireCaptcha = GetterUtil.getBoolean(preferences.getValue("requireCaptcha", StringPool.BLANK)); String successURL = GetterUtil.getString(preferences.getValue("successURL", StringPool.BLANK)); boolean sendAsEmail = GetterUtil.getBoolean(preferences.getValue("sendAsEmail", StringPool.BLANK)); boolean sendThanksEmail = GetterUtil.getBoolean(preferences.getValue("sendThanksEmail", StringPool.BLANK)); boolean saveToDatabase = GetterUtil.getBoolean(preferences.getValue("saveToDatabase", StringPool.BLANK)); String databaseTableName = GetterUtil .getString(preferences.getValue("databaseTableName", StringPool.BLANK)); boolean saveToFile = GetterUtil.getBoolean(preferences.getValue("saveToFile", StringPool.BLANK)); boolean uploadToDisk = GetterUtil.getBoolean(preferences.getValue("uploadToDisk", StringPool.BLANK)); boolean uploadToDM = GetterUtil.getBoolean(preferences.getValue("uploadToDM", StringPool.BLANK)); long newFolderId = GetterUtil.getLong(preferences.getValue("newFolderId", StringPool.BLANK)); String fileName = GetterUtil.getString(preferences.getValue("fileName", StringPool.BLANK)); String uploadDiskDir = GetterUtil.getString(preferences.getValue("uploadDiskDir", StringPool.BLANK)); if (requireCaptcha) { try {// w w w. ja v a2s . c om CaptchaUtil.check(actionRequest); } catch (CaptchaTextException cte) { SessionErrors.add(actionRequest, CaptchaTextException.class.getName()); return; } } UploadPortletRequest uploadRequest = PortalUtil.getUploadPortletRequest(actionRequest); Map<String, String> fieldsMap = new LinkedHashMap<String, String>(); String fileAttachment = ""; for (int i = 1; true; i++) { String fieldLabel = preferences.getValue("fieldLabel" + i, StringPool.BLANK); String fieldType = preferences.getValue("fieldType" + i, StringPool.BLANK); if (Validator.isNull(fieldLabel)) { break; } if (StringUtil.equalsIgnoreCase(fieldType, "paragraph")) { continue; } if (StringUtil.equalsIgnoreCase(fieldType, "file")) { if (_log.isDebugEnabled()) { _log.debug("Field name for file: " + fieldLabel); } File file = uploadRequest.getFile("field" + i); String sourceFileName = uploadRequest.getFileName("field" + i); if (_log.isDebugEnabled()) { _log.debug("File attachment: " + sourceFileName); } JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); if (Validator.isNotNull(sourceFileName) && !"".equals(sourceFileName)) { if (uploadRequest.getSize("field" + i) == 0) { SessionErrors.add(actionRequest, "uploadToDiskError", "Uploaded file size is 0"); if (_log.isDebugEnabled()) { _log.debug("Uploaded file size is 0"); } return; } // List<String> uploadResults = new ArrayList<String>(); String uploadResult = ""; if (uploadToDisk) { uploadResult = uploadFile(file, sourceFileName, uploadDiskDir); if (uploadResult.equalsIgnoreCase("File Upload Error")) { SessionErrors.add(actionRequest, "uploadToDiskError", uploadResult); return; } fileAttachment = uploadDiskDir + File.separator + uploadResult; //uploadResults.add(uploadResult); jsonObject.put("fsOriginalName", sourceFileName); jsonObject.put("fsName", uploadResult); } if (uploadToDM) { uploadResult = ""; String contentType = MimeTypesUtil.getContentType(file); Folder folderName = DLAppLocalServiceUtil.getFolder(newFolderId); if (_log.isDebugEnabled()) { _log.debug("DM Folder: " + folderName.getName()); } InputStream inputStream = new FileInputStream(file); long repositoryId = folderName.getRepositoryId(); try { String selectedFileName = sourceFileName; while (true) { try { DLAppLocalServiceUtil.getFileEntry(themeDisplay.getScopeGroupId(), newFolderId, selectedFileName); StringBundler sb = new StringBundler(5); sb.append(FileUtil.stripExtension(selectedFileName)); sb.append(StringPool.DASH); sb.append(StringUtil.randomString()); sb.append(StringPool.PERIOD); sb.append(FileUtil.getExtension(selectedFileName)); selectedFileName = sb.toString(); } catch (Exception e) { break; } } FileEntry fileEntry = DLAppLocalServiceUtil.addFileEntry(themeDisplay.getUserId(), repositoryId, newFolderId, selectedFileName, //file.getName(), contentType, selectedFileName, "", "", inputStream, file.length(), serviceContext); if (_log.isDebugEnabled()) { _log.debug("DM file uploade: " + fileEntry.getTitle()); } //Map<String, Serializable> workflowContext = new HashMap<String, Serializable>(); //workflowContext.put("event",DLSyncConstants.EVENT_UPDATE); //DLFileEntryLocalServiceUtil.updateStatus(themeDisplay.getUserId(), fileEntry.getFileVersion().getFileVersionId(), WorkflowConstants.STATUS_APPROVED, workflowContext, serviceContext); uploadResult = String.valueOf(fileEntry.getFileEntryId()); //uploadResults.add(uploadResult); String docUrl = themeDisplay.getPortalURL() + "/c/document_library/get_file?uuid=" + fileEntry.getUuid() + "&groupId=" + themeDisplay.getScopeGroupId(); jsonObject.put("fe", uploadResult); jsonObject.put("feOriginalName", sourceFileName); jsonObject.put("feName", fileEntry.getTitle()); jsonObject.put("feUrl", docUrl); } catch (PortalException pe) { SessionErrors.add(actionRequest, "uploadToDmError"); _log.error("The upload to DM failed", pe); return; } catch (Exception e) { _log.error("The upload to DM failed", e); return; } } jsonObject.put("Status", "With Attachment"); } else { jsonObject.put("Status", "No Attachment"); } fieldsMap.put(fieldLabel, jsonObject.toString()); } else { fieldsMap.put(fieldLabel, uploadRequest.getParameter("field" + i)); } } Set<String> validationErrors = null; try { validationErrors = validate(fieldsMap, preferences); } catch (Exception e) { SessionErrors.add(actionRequest, "validationScriptError", e.getMessage().trim()); return; } User currentUser = PortalUtil.getUser(actionRequest); String userEmail = ""; if (!Validator.isNull(currentUser)) { userEmail = currentUser.getEmailAddress(); if (_log.isDebugEnabled()) { _log.debug("User email for the form author: " + userEmail); } fieldsMap.put("email-from", userEmail); } else { fieldsMap.put("email-from", "guest"); } DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); df.setTimeZone(TimeZone.getTimeZone(themeDisplay.getTimeZone().getID())); Date dateobj = new Date(); fieldsMap.put("email-sent-on", df.format(dateobj)); if (validationErrors.isEmpty()) { boolean emailSuccess = true; boolean databaseSuccess = true; boolean fileSuccess = true; boolean emailThanksSuccess = true; if (sendAsEmail) { emailSuccess = WebFormUtil.sendEmail(themeDisplay.getCompanyId(), fieldsMap, preferences, fileAttachment); } if (sendThanksEmail && !Validator.isNull(currentUser)) { emailThanksSuccess = WebFormUtil.sendThanksEmail(themeDisplay.getCompanyId(), fieldsMap, preferences, userEmail); } if (saveToDatabase) { if (Validator.isNull(databaseTableName)) { databaseTableName = WebFormUtil.getNewDatabaseTableName(portletId); preferences.setValue("databaseTableName", databaseTableName); preferences.store(); } databaseSuccess = saveDatabase(themeDisplay.getCompanyId(), fieldsMap, preferences, databaseTableName); } if (saveToFile) { fileSuccess = saveFile(fieldsMap, fileName); } if (emailSuccess && emailThanksSuccess && databaseSuccess && fileSuccess) { if (Validator.isNull(successURL)) { SessionMessages.add(actionRequest, "success"); } else { SessionMessages.add(actionRequest, portletId + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_SUCCESS_MESSAGE); } } else { SessionErrors.add(actionRequest, "error"); } } else { for (String badField : validationErrors) { SessionErrors.add(actionRequest, "error" + badField); } } if (SessionErrors.isEmpty(actionRequest) && Validator.isNotNull(successURL)) { actionResponse.sendRedirect(successURL); } }
From source file:com.fmdp.webform.util.WebFormUtil.java
License:Open Source License
public static ExpandoTable checkTable(long companyId, String tableName, PortletPreferences preferences) throws Exception { ExpandoTable expandoTable = null;/*from w ww . j a v a 2s. c o m*/ try { expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, WebFormUtil.class.getName(), tableName); } catch (NoSuchTableException nste) { expandoTable = addTable(companyId, tableName); int i = 1; String fieldLabel = preferences.getValue("fieldLabel" + i, StringPool.BLANK); String fieldType = preferences.getValue("fieldType" + i, StringPool.BLANK); while ((i == 1) || Validator.isNotNull(fieldLabel)) { if (!StringUtil.equalsIgnoreCase(fieldType, "paragraph")) { ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), fieldLabel, ExpandoColumnConstants.STRING); } i++; fieldLabel = preferences.getValue("fieldLabel" + i, StringPool.BLANK); fieldType = preferences.getValue("fieldType" + i, StringPool.BLANK); } ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), "email-from", ExpandoColumnConstants.STRING); ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), "email-sent-on", ExpandoColumnConstants.STRING); } return expandoTable; }
From source file:com.liferay.alloy.mvc.AlloyFriendlyURLMapper.java
License:Open Source License
protected String getLifecycle(HttpServletRequest request) { String method = request.getMethod(); if (StringUtil.equalsIgnoreCase(method, HttpMethods.POST)) { return "1"; }//from ww w. java2s. c om return ParamUtil.getString(request, "p_p_lifecycle", "0"); }
From source file:com.liferay.asset.publisher.web.internal.exportimport.portlet.preferences.processor.AssetPublisherExportImportPortletPreferencesProcessor.java
License:Open Source License
protected PortletPreferences updateExportPortletPreferences(PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception { String anyAssetTypeString = portletPreferences.getValue("anyAssetType", null); String selectionStyle = portletPreferences.getValue("selectionStyle", null); if (Validator.isNotNull(selectionStyle) && selectionStyle.equals("manual")) { portletPreferences.reset("anyAssetType"); anyAssetTypeString = portletPreferences.getValue("anyAssetType", null); } else if (Validator.isNotNull(anyAssetTypeString) && anyAssetTypeString.equals("false")) { String[] classNameIds = portletPreferences.getValues("classNameIds", StringPool.EMPTY_ARRAY); if (classNameIds.length == 1) { portletPreferences.setValue("anyAssetType", classNameIds[0]); anyAssetTypeString = portletPreferences.getValue("anyAssetType", null); portletPreferences.reset("classNameIds"); }//from ww w. j a v a 2s. c o m } String anyAssetTypeClassName = StringPool.BLANK; long anyAssetType = GetterUtil.getLong(anyAssetTypeString); if (anyAssetType > 0) { anyAssetTypeClassName = portal.getClassName(anyAssetType); } Portlet portlet = _portletLocalService.getPortletById(portletDataContext.getCompanyId(), portletId); Enumeration<String> enu = portletPreferences.getNames(); while (enu.hasMoreElements()) { String name = enu.nextElement(); String value = GetterUtil.getString(portletPreferences.getValue(name, null)); if (name.equals("anyAssetType") || name.equals("classNameIds")) { if (name.equals("classNameIds") && Validator.isNotNull(anyAssetTypeString) && !anyAssetTypeString.equals("false")) { portletPreferences.reset(name); } else { updateExportClassNameIds(portletPreferences, name); } } else if (name.equals("anyClassTypeDLFileEntryAssetRendererFactory") || (name.equals("classTypeIds") && anyAssetTypeClassName.equals(DLFileEntry.class.getName())) || name.equals("classTypeIdsDLFileEntryAssetRendererFactory")) { String anyClassTypeDLFileEntryAssetRendererFactory = portletPreferences .getValue("anyClassTypeDLFileEntryAssetRendererFactory", null); String[] classTypeIdsDLFileEntryAssetRendererFactory = portletPreferences .getValues("classTypeIdsDLFileEntryAssetRendererFactory", StringPool.EMPTY_ARRAY); if (Validator.isNotNull(anyClassTypeDLFileEntryAssetRendererFactory) && anyClassTypeDLFileEntryAssetRendererFactory.equals("false") && (classTypeIdsDLFileEntryAssetRendererFactory.length == 1)) { portletPreferences.setValue("anyClassTypeDLFileEntryAssetRendererFactory", classTypeIdsDLFileEntryAssetRendererFactory[0]); portletPreferences.reset("classTypeIdsDLFileEntryAssetRendererFactory"); anyClassTypeDLFileEntryAssetRendererFactory = portletPreferences .getValue("anyClassTypeDLFileEntryAssetRendererFactory", null); } if (!anyAssetTypeClassName.equals(DLFileEntry.class.getName()) || (name.equals("classTypeIdsDLFileEntryAssetRendererFactory") && Validator.isNotNull(anyClassTypeDLFileEntryAssetRendererFactory) && !anyClassTypeDLFileEntryAssetRendererFactory.equals("false"))) { portletPreferences.reset(name); } else { updateExportPortletPreferencesClassPKs(portletDataContext, portlet, portletPreferences, name, DLFileEntryType.class.getName()); } } else if (name.equals("anyClassTypeJournalArticleAssetRendererFactory") || (name.equals("classTypeIds") && anyAssetTypeClassName.equals(JournalArticle.class.getName())) || name.equals("classTypeIdsJournalArticleAssetRendererFactory")) { String anyClassTypeJournalArticleAssetRendererFactory = portletPreferences .getValue("anyClassTypeJournalArticleAssetRendererFactory", null); String[] classTypeIdsJournalArticleAssetRendererFactory = portletPreferences .getValues("classTypeIdsJournalArticleAssetRendererFactory", StringPool.EMPTY_ARRAY); if (Validator.isNotNull(anyClassTypeJournalArticleAssetRendererFactory) && anyClassTypeJournalArticleAssetRendererFactory.equals("false") && (classTypeIdsJournalArticleAssetRendererFactory.length == 1)) { portletPreferences.setValue("anyClassTypeJournalArticleAssetRendererFactory", classTypeIdsJournalArticleAssetRendererFactory[0]); portletPreferences.reset("classTypeIdsJournalArticleAssetRendererFactory"); anyClassTypeJournalArticleAssetRendererFactory = portletPreferences .getValue("anyClassTypeJournalArticleAssetRendererFactory", null); } if (!anyAssetTypeClassName.equals(JournalArticle.class.getName()) || (name.equals("classTypeIdsJournalArticleAssetRendererFactory") && Validator.isNotNull(anyClassTypeJournalArticleAssetRendererFactory) && !anyClassTypeJournalArticleAssetRendererFactory.equals("false"))) { portletPreferences.reset(name); } else { updateExportPortletPreferencesClassPKs(portletDataContext, portlet, portletPreferences, name, DDMStructure.class.getName()); } } else if (name.equals("assetVocabularyId")) { long assetVocabularyId = GetterUtil.getLong(value); AssetVocabulary assetVocabulary = _assetVocabularyLocalService .fetchAssetVocabulary(assetVocabularyId); if (assetVocabulary != null) { StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, portletId, assetVocabulary); } updateExportPortletPreferencesClassPKs(portletDataContext, portlet, portletPreferences, name, AssetVocabulary.class.getName()); } else if (name.startsWith("orderByColumn") && StringUtil.startsWith(value, DDMStructureManager.STRUCTURE_INDEXER_FIELD_PREFIX)) { updateExportOrderByColumnClassPKs(portletDataContext, portlet, portletPreferences, name); } else if (name.startsWith("queryName") && StringUtil.equalsIgnoreCase(value, "assetCategories")) { String index = name.substring(9); long assetCategoryId = GetterUtil.getLong(portletPreferences.getValue("queryValues" + index, null)); AssetCategory assetCategory = _assetCategoryLocalService.fetchAssetCategory(assetCategoryId); if (assetCategory != null) { StagedModelDataHandlerUtil.exportReferenceStagedModel(portletDataContext, portletId, assetCategory); } updateExportPortletPreferencesClassPKs(portletDataContext, portlet, portletPreferences, "queryValues" + index, AssetCategory.class.getName()); } else if (name.equals("scopeIds")) { updateExportScopeIds(portletDataContext, portletPreferences, name, portletDataContext.getPlid()); } } return portletPreferences; }
From source file:com.liferay.asset.publisher.web.internal.exportimport.portlet.preferences.processor.AssetPublisherExportImportPortletPreferencesProcessor.java
License:Open Source License
protected PortletPreferences updateImportPortletPreferences(PortletDataContext portletDataContext, PortletPreferences portletPreferences) throws Exception { Company company = _companyLocalService.getCompanyById(portletDataContext.getCompanyId()); Group companyGroup = company.getGroup(); String anyAssetTypeClassName = portletPreferences.getValue("anyAssetType", StringPool.BLANK); Enumeration<String> enu = portletPreferences.getNames(); while (enu.hasMoreElements()) { String name = enu.nextElement(); String value = GetterUtil.getString(portletPreferences.getValue(name, null)); if (name.equals("anyAssetType") || name.equals("classNameIds")) { updateImportClassNameIds(portletPreferences, name); } else if (name.equals("anyClassTypeDLFileEntryAssetRendererFactory") || (name.equals("classTypeIds") && anyAssetTypeClassName.equals(DLFileEntry.class.getName())) || name.equals("classTypeIdsDLFileEntryAssetRendererFactory")) { updateImportPortletPreferencesClassPKs(portletDataContext, portletPreferences, name, DLFileEntryType.class, companyGroup.getGroupId()); } else if (name.equals("anyClassTypeJournalArticleAssetRendererFactory") || (name.equals("classTypeIds") && anyAssetTypeClassName.equals(JournalArticle.class.getName())) || name.equals("classTypeIdsJournalArticleAssetRendererFactory")) { updateImportPortletPreferencesClassPKs(portletDataContext, portletPreferences, name, DDMStructure.class, companyGroup.getGroupId()); } else if (name.equals("assetVocabularyId")) { updateImportPortletPreferencesClassPKs(portletDataContext, portletPreferences, name, AssetVocabulary.class, companyGroup.getGroupId()); } else if (name.startsWith("orderByColumn") && StringUtil.startsWith(value, DDMStructureManager.STRUCTURE_INDEXER_FIELD_PREFIX)) { updateImportOrderByColumnClassPKs(portletDataContext, portletPreferences, name, companyGroup.getGroupId()); } else if (name.startsWith("queryName") && StringUtil.equalsIgnoreCase(value, "assetCategories")) { String index = name.substring(9); updateImportPortletPreferencesClassPKs(portletDataContext, portletPreferences, "queryValues" + index, AssetCategory.class, companyGroup.getGroupId()); } else if (name.equals("scopeIds")) { updateImportScopeIds(portletDataContext, portletPreferences, name, companyGroup.getGroupId(), portletDataContext.getPlid()); }/* w w w .j ava2s . c om*/ } restorePortletPreference(portletDataContext, "notifiedAssetEntryIds", portletPreferences); return portletPreferences; }
From source file:com.liferay.chat.jabber.JabberImpl.java
License:Open Source License
@Override public void sendMessage(long fromUserId, long toUserId, String content) { try {// w w w. j av a 2 s.c o m if (Validator.isNull(content)) { return; } Connection connection = getConnection(fromUserId); if (connection == null) { if (_log.isWarnEnabled()) { _log.warn("User " + fromUserId + " is not connected to Jabber" + " and cannot send messages"); } return; } User toUser = UserLocalServiceUtil.getUser(toUserId); Roster roster = connection.getRoster(); String jabberId = getJabberId(toUser.getScreenName()); if (!roster.contains(jabberId)) { return; } Iterator<Presence> presences = roster.getPresences(jabberId); while (presences.hasNext()) { Presence presence = presences.next(); String from = presence.getFrom(); String resource = getResource(from); if (StringUtil.equalsIgnoreCase(resource, PortletPropsValues.JABBER_RESOURCE)) { continue; } ChatManager chatManager = connection.getChatManager(); MessageListener messageListener = new JabberMessageListener(toUser.getCompanyId(), fromUserId); Chat chat = chatManager.createChat(from, messageListener); try { chat.sendMessage(content); } catch (XMPPException xmppe) { if (_log.isWarnEnabled()) { _log.warn("User " + fromUserId + " could not send message", xmppe); } } } } catch (Exception e) { _log.error(e, e); } }