List of usage examples for com.liferay.portal.kernel.util StringPool COMMA
String COMMA
To view the source code for com.liferay.portal.kernel.util StringPool COMMA.
Click Source Link
From source file:com.stoxx.service.business.registration.RegistrationServiceImpl.java
public User saveUserToLiferayDB(UserProfileDetails userProfileDetails, ThemeDisplay themeDisplay, ServiceContext serviceContext) throws STOXXException { try {/* w w w. j av a2 s . c om*/ Group stoxxNetgroup = GroupLocalServiceUtil.getGroup(themeDisplay.getCompanyId(), STOXXConstants.STOXXNET_SITE_NAME); Group stoxxgroup = GroupLocalServiceUtil.getGroup(themeDisplay.getCompanyId(), STOXXConstants.STOXX_SITE_NAME); User adminDefaultUser = UserLocalServiceUtil.getDefaultUser(themeDisplay.getCompanyId()); logger.info("the ****************************>default user id is " + adminDefaultUser.getUserId() + EMAIL_ADDRESS_IS + adminDefaultUser.getEmailAddresses()); long[] groupIds = null; if (userProfileDetails.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_VENDOR_USER)) { groupIds = new long[] { stoxxNetgroup.getGroupId() }; } else if (userProfileDetails.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_GENERAL_USER) || userProfileDetails.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_REGISTERED_USER)) { groupIds = new long[] { stoxxgroup.getGroupId() }; } else if (userProfileDetails.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_STAFF_USER)) { groupIds = new long[] { stoxxNetgroup.getGroupId(), stoxxgroup.getGroupId() }; } User user = null; if (!(userProfileDetails.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_VENDOR_USER))) { if (userProfileDetails.getUserType().equalsIgnoreCase(STOXXConstants.STOXX_REGISTERED_USER)) { if (null != userProfileDetails.getSalesEntryId()) { List<Long> roleList = new ArrayList<Long>(); Long salesEntryID = userProfileDetails.getSalesEntryId(); SalesEntry salesEntry = SalesEntryLocalServiceUtil.getSalesEntry(salesEntryID); if (!(salesEntry.getPackageNames().contains(StringPool.COMMA))) { Role packageRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(), salesEntry.getPackageNames().trim()); long packageRoleId = packageRole.getRoleId(); roleList.add(packageRoleId); } else { for (String packageName : salesEntry.getPackageNames().split(StringPool.COMMA)) { Role packageRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(), packageName.trim()); long packageRoleId = packageRole.getRoleId(); roleList.add(packageRoleId); } } if (StringUtils.isNotBlank(salesEntry.getKeyEmailAddress()) && salesEntry.getKeyEmailAddress().trim() .equalsIgnoreCase(userProfileDetails.getEmailAddress())) { if (isLicensedUser(userProfileDetails.getEmailAddress())) { Role keyAccntHolderUserRole = RoleLocalServiceUtil.getRole( themeDisplay.getCompanyId(), STOXXConstants.STOXX_KEY_ACCOUNT_HOLDER_ROLE); long roleKeyAccntHolder = keyAccntHolderUserRole.getRoleId(); roleList.add(roleKeyAccntHolder); } } long roleLicensed[] = ArrayUtils.toPrimitive(roleList.toArray(new Long[roleList.size()])); user = UserLocalServiceUtil.addUser(adminDefaultUser.getUserId(), themeDisplay.getCompanyId(), false, userProfileDetails.getPassword(), userProfileDetails.getPassword(), true, StringPool.BLANK, userProfileDetails.getEmailAddress(), 0, StringPool.BLANK, themeDisplay.getLocale(), userProfileDetails.getFirstName(), StringPool.BLANK, userProfileDetails.getLastName(), userProfileDetails.getPrefixId(), 0, userProfileDetails.isGender(), userProfileDetails.getBirthMonth(), userProfileDetails.getBirthDay(), userProfileDetails.getBirthYear(), userProfileDetails.getJobTitle(), groupIds, null, roleLicensed, null, false, serviceContext); } } else { user = UserLocalServiceUtil.addUser(adminDefaultUser.getUserId(), themeDisplay.getCompanyId(), false, userProfileDetails.getPassword(), userProfileDetails.getPassword(), true, StringPool.BLANK, userProfileDetails.getEmailAddress(), 0, StringPool.BLANK, themeDisplay.getLocale(), userProfileDetails.getFirstName(), StringPool.BLANK, userProfileDetails.getLastName(), userProfileDetails.getPrefixId(), 0, userProfileDetails.isGender(), userProfileDetails.getBirthMonth(), userProfileDetails.getBirthDay(), userProfileDetails.getBirthYear(), userProfileDetails.getJobTitle(), groupIds, null, null, null, false, serviceContext); } } Role powerUserRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(), RoleConstants.POWER_USER); if (Validator.isNotNull(powerUserRole)) { long rolePower[] = { powerUserRole.getRoleId() }; if (Validator.isNotNull(user) && rolePower.length > 0) { RoleLocalServiceUtil.unsetUserRoles(user.getUserId(), rolePower); } } return user; } catch (PortalException e) { logger.error(e.getMessage(), e); throw new STOXXException(e.getMessage(), e); } catch (SystemException e) { logger.error(e.getMessage(), e); throw new STOXXException(e.getMessage(), e); } }
From source file:com.stoxx.service.business.registration.RegistrationServiceImpl.java
private List<Long> assignTranslatorRole(String userGroupName, TranslatorAgency translatorAgency, ThemeDisplay themeDisplay) {// w w w . j av a 2 s . co m List<Long> roleList = new ArrayList<Long>(); try { if (translatorAgency.getTranslatorLanguage().trim().contains(StringPool.COMMA)) { for (String language : translatorAgency.getTranslatorLanguage().trim().split(StringPool.COMMA)) { Role translatorRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(), userGroupName.concat(StringPool.UNDERLINE.concat(language))); long translatorRoleId = translatorRole.getRoleId(); roleList.add(translatorRoleId); } } else { Role translatorRole = RoleLocalServiceUtil.getRole(themeDisplay.getCompanyId(), userGroupName .concat(StringPool.UNDERLINE.concat(translatorAgency.getTranslatorLanguage().trim()))); long translatorRoleId = translatorRole.getRoleId(); roleList.add(translatorRoleId); } } catch (PortalException e) { logger.error(e.getMessage(), e); } catch (SystemException e) { logger.error(e.getMessage(), e); } return roleList; }
From source file:com.stoxx.service.dao.userprofile.UserProfileDAOImpl.java
public int checkUserExistsForComapny(List<String> emailAddress) throws STOXXException { Long count = null;/*from w ww . ja v a 2 s . c o m*/ int licenseeCount = 0; Session session = null; StringBuilder queryStringInParam = new StringBuilder( "select count(*) from UserProfileDetails where emailAddress in ("); try { if (Validator.isNotNull(emailAddress) && emailAddress.size() > 0) { for (String catName : emailAddress) { queryStringInParam.append("'").append(catName.toLowerCase()).append("',"); } queryStringInParam.delete(queryStringInParam.lastIndexOf(StringPool.COMMA), queryStringInParam.length()); String append = ") and (status!=0 or status!=4)"; queryStringInParam.append(append); log.info("queryStringInParam ==> " + queryStringInParam.toString()); session = sessionFactory.openSession(); Query query = session.createQuery(queryStringInParam.toString()); count = (Long) query.uniqueResult(); log.info("license count already used in service before " + count); licenseeCount = emailAddress.size() - count.intValue(); log.info("new license count in service before " + licenseeCount); } } catch (Exception e) { log.error(e.getMessage() + "in checkUserExistsForComapny", e); } finally { try { if (null != session) { session.close(); } } catch (Exception e) { log.error(e.getMessage(), e); } } return licenseeCount; }
From source file:com.tahir.liferaypractice.service.persistence.impl.TestServiceModulePersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, TestServiceModule> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from w ww . ja v a2s .c om*/ Map<Serializable, TestServiceModule> map = new HashMap<Serializable, TestServiceModule>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); TestServiceModule testServiceModule = fetchByPrimaryKey(primaryKey); if (testServiceModule != null) { map.put(primaryKey, testServiceModule); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { TestServiceModule testServiceModule = (TestServiceModule) entityCache.getResult( TestServiceModuleModelImpl.ENTITY_CACHE_ENABLED, TestServiceModuleImpl.class, primaryKey); if (testServiceModule == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, testServiceModule); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_TESTSERVICEMODULE_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (TestServiceModule testServiceModule : (List<TestServiceModule>) q.list()) { map.put(testServiceModule.getPrimaryKeyObj(), testServiceModule); cacheResult(testServiceModule); uncachedPrimaryKeys.remove(testServiceModule.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(TestServiceModuleModelImpl.ENTITY_CACHE_ENABLED, TestServiceModuleImpl.class, primaryKey, _nullTestServiceModule); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.tahir.meeting.service.persistence.impl.HimalayaPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Himalaya> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/* w w w. j av a 2 s . c om*/ Map<Serializable, Himalaya> map = new HashMap<Serializable, Himalaya>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Himalaya himalaya = fetchByPrimaryKey(primaryKey); if (himalaya != null) { map.put(primaryKey, himalaya); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Himalaya himalaya = (Himalaya) entityCache.getResult(HimalayaModelImpl.ENTITY_CACHE_ENABLED, HimalayaImpl.class, primaryKey); if (himalaya == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, himalaya); } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_HIMALAYA_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (Himalaya himalaya : (List<Himalaya>) q.list()) { map.put(himalaya.getPrimaryKeyObj(), himalaya); cacheResult(himalaya); uncachedPrimaryKeys.remove(himalaya.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(HimalayaModelImpl.ENTITY_CACHE_ENABLED, HimalayaImpl.class, primaryKey, _nullHimalaya); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.tahir.motogplusservice.service.persistence.impl.KhaliqPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, Khaliq> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }// www . ja v a2 s.co m Map<Serializable, Khaliq> map = new HashMap<Serializable, Khaliq>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); Khaliq khaliq = fetchByPrimaryKey(primaryKey); if (khaliq != null) { map.put(primaryKey, khaliq); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(KhaliqModelImpl.ENTITY_CACHE_ENABLED, KhaliqImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (Khaliq) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_KHALIQ_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (Khaliq khaliq : (List<Khaliq>) q.list()) { map.put(khaliq.getPrimaryKeyObj(), khaliq); cacheResult(khaliq); uncachedPrimaryKeys.remove(khaliq.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(KhaliqModelImpl.ENTITY_CACHE_ENABLED, KhaliqImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.todolist.service.persistence.impl.TodoListPersistenceImpl.java
License:Open Source License
@Override public Map<Serializable, TodoList> fetchByPrimaryKeys(Set<Serializable> primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); }/*from ww w . ja va2 s .c o m*/ Map<Serializable, TodoList> map = new HashMap<Serializable, TodoList>(); if (primaryKeys.size() == 1) { Iterator<Serializable> iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); TodoList todoList = fetchByPrimaryKey(primaryKey); if (todoList != null) { map.put(primaryKey, todoList); } return map; } Set<Serializable> uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = entityCache.getResult(TodoListModelImpl.ENTITY_CACHE_ENABLED, TodoListImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet<Serializable>(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (TodoList) serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1); query.append(_SQL_SELECT_TODOLIST_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append(String.valueOf(primaryKey)); query.append(StringPool.COMMA); } query.setIndex(query.index() - 1); query.append(StringPool.CLOSE_PARENTHESIS); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (TodoList todoList : (List<TodoList>) q.list()) { map.put(todoList.getPrimaryKeyObj(), todoList); cacheResult(todoList); uncachedPrimaryKeys.remove(todoList.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { entityCache.putResult(TodoListModelImpl.ENTITY_CACHE_ENABLED, TodoListImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; }
From source file:com.vportal.portlet.vcms.service.persistence.VcmsArticleStatusPK.java
License:Open Source License
public String toString() { StringBundler sb = new StringBundler(20); sb.append(StringPool.OPEN_CURLY_BRACE); sb.append("statusId"); sb.append(StringPool.EQUAL);/*from w w w . j a v a 2 s.co m*/ sb.append(statusId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("articleId"); sb.append(StringPool.EQUAL); sb.append(articleId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("categoryId"); sb.append(StringPool.EQUAL); sb.append(categoryId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("createdDate"); sb.append(StringPool.EQUAL); sb.append(createdDate); sb.append(StringPool.CLOSE_CURLY_BRACE); return sb.toString(); }
From source file:com.vportal.portlet.vcms.service.persistence.VcmsArticleTypePK.java
License:Open Source License
public String toString() { StringBundler sb = new StringBundler(10); sb.append(StringPool.OPEN_CURLY_BRACE); sb.append("typeId"); sb.append(StringPool.EQUAL);// w w w .ja v a2 s . co m sb.append(typeId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("articleId"); sb.append(StringPool.EQUAL); sb.append(articleId); sb.append(StringPool.CLOSE_CURLY_BRACE); return sb.toString(); }
From source file:com.vportal.portlet.vcms.service.persistence.VcmsCARelationPK.java
License:Open Source License
public String toString() { StringBundler sb = new StringBundler(10); sb.append(StringPool.OPEN_CURLY_BRACE); sb.append("categoryId"); sb.append(StringPool.EQUAL);/*from w w w.j a v a2s . c o m*/ sb.append(categoryId); sb.append(StringPool.COMMA); sb.append(StringPool.SPACE); sb.append("articleId"); sb.append(StringPool.EQUAL); sb.append(articleId); sb.append(StringPool.CLOSE_CURLY_BRACE); return sb.toString(); }