List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED
int STATUS_APPROVED
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_APPROVED.
Click Source Link
From source file:com.liferay.lms.service.impl.CompetenceLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) public Competence addCompetence(String title, String description, boolean generateCertificate, ServiceContext serviceContext) throws SystemException, PortalException { long userId = serviceContext.getUserId(); Competence competence = competencePersistence .create(counterLocalService.increment(Competence.class.getName())); competence.setCompanyId(serviceContext.getCompanyId()); competence.setGroupId(serviceContext.getScopeGroupId()); competence.setDiplomaTemplate(//from ww w .j a v a 2s. c o m ParamUtil.getString(serviceContext.getRequest(), "template", StringPool.BLANK), serviceContext.getLocale()); competence.setGenerateCertificate(generateCertificate); competence.setUserId(userId); competence.setDescription(description, serviceContext.getLocale()); competence.setTitle(title, serviceContext.getLocale()); competence.setStatus(WorkflowConstants.STATUS_APPROVED); competence.setExpandoBridgeAttributes(serviceContext); competence.setPage((String) serviceContext.getAttribute("page")); competencePersistence.update(competence, true); competence = LmsLocaleUtil.checkDefaultLocale(Competence.class, competence, "title"); competence = LmsLocaleUtil.checkDefaultLocale(Competence.class, competence, "description"); try { resourceLocalService.addResources(serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), userId, Competence.class.getName(), competence.getPrimaryKey(), false, true, true); } catch (Exception e) { e.printStackTrace(); } AssetEntryLocalServiceUtil.updateEntry(userId, competence.getGroupId(), Competence.class.getName(), competence.getCompetenceId(), competence.getUuid(), 0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, new java.util.Date(System.currentTimeMillis()), null, ContentTypes.TEXT_HTML, competence.getTitle(), competence.getDescription(serviceContext.getLocale()), competence.getDescription(serviceContext.getLocale()), null, null, 0, 0, null, false); //creating group return competence; }
From source file:com.liferay.lms.service.impl.CourseLocalServiceImpl.java
License:Open Source License
public Course addCourse(String title, String description, String summary, String friendlyURL, Locale locale, java.util.Date createDate, java.util.Date startDate, java.util.Date endDate, long layoutSetPrototypeId, int typesite, long CourseEvalId, long calificationType, int maxUsers, ServiceContext serviceContext, boolean isfromClone) throws SystemException, PortalException { LmsPrefs lmsPrefs = lmsPrefsLocalService.getLmsPrefsIni(serviceContext.getCompanyId()); long userId = serviceContext.getUserId(); Course course = coursePersistence.create(counterLocalService.increment(Course.class.getName())); try {/* w w w .j a va 2s .c om*/ //Se asegura que la longitud de friendlyURL no supere el maximo int maxLength = GetterUtil.getInteger( ModelHintsUtil.getHints(Group.class.getName(), "friendlyURL").get("max-length"), GetterUtil.getInteger(ModelHintsConstants.TEXT_MAX_LENGTH)); if (Validator.isNull(friendlyURL)) { friendlyURL = StringPool.SLASH + FriendlyURLNormalizerUtil.normalize(title); if (friendlyURL.length() > maxLength) { friendlyURL = friendlyURL.substring(0, maxLength); } for (int i = 0;; i++) { Group exist = groupLocalService.fetchFriendlyURLGroup(serviceContext.getCompanyId(), friendlyURL); if (Validator.isNotNull(exist)) { String iString = String.valueOf(i); if (friendlyURL.length() + iString.length() > maxLength) { if (iString.length() > maxLength) { throw new SystemException(); } friendlyURL = friendlyURL.substring(0, maxLength - iString.length()) + iString; } else { friendlyURL = friendlyURL + iString; } } else { break; } } } friendlyURL = StringPool.SLASH + friendlyURL.replaceAll("[^a-zA-Z0-9_-]+", ""); course.setCompanyId(serviceContext.getCompanyId()); course.setGroupId(serviceContext.getScopeGroupId()); course.setUserId(userId); course.setUserName(userLocalService.getUser(userId).getFullName()); course.setFriendlyURL(friendlyURL); course.setDescription(description, locale); course.setTitle(title, locale); course.setCreateDate(createDate); course.setModifiedDate(createDate); course.setStartDate(startDate); course.setEndDate(endDate); course.setStatus(WorkflowConstants.STATUS_APPROVED); course.setExpandoBridgeAttributes(serviceContext); course.setCourseEvalId(CourseEvalId); course.setCalificationType(calificationType); course.setMaxusers(maxUsers); course = LmsLocaleUtil.checkDefaultLocale(Course.class, course, "description"); //creating group Group group = groupLocalService.addGroup( userLocalService.getDefaultUser(serviceContext.getCompanyId()).getUserId(), null, 0, title, summary, typesite, friendlyURL, true, true, serviceContext); course.setGroupCreatedId(group.getGroupId()); course.setFriendlyURL(group.getFriendlyURL()); coursePersistence.update(course, true); resourceLocalService.addResources(serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), userId, Course.class.getName(), course.getPrimaryKey(), false, true, true); AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, course.getGroupId(), Course.class.getName(), course.getCourseId(), course.getUuid(), 0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, new java.util.Date(System.currentTimeMillis()), null, ContentTypes.TEXT_HTML, course.getTitle(), course.getDescription(locale), summary, null, null, 0, 0, null, false); assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), serviceContext.getAssetLinkEntryIds(), AssetLinkConstants.TYPE_RELATED); //Aadimos el rol Teacher al usuario que crea el blog long[] usuarios = new long[] { userId }; boolean teacherRoleToCreator = GetterUtil .getBoolean(PropsUtil.get("lms.course.add.teacherRoleToCreator")); boolean editorRoleToCreator = GetterUtil .getBoolean(PropsUtil.get("lms.course.add.editorRoleToCreator")); if (teacherRoleToCreator || editorRoleToCreator) { groupLocalService.addUserGroups(userId, new long[] { group.getGroupId() }); } if (teacherRoleToCreator) { userGroupRoleLocalService.addUserGroupRoles(usuarios, course.getGroupCreatedId(), lmsPrefs.getTeacherRole()); } if (editorRoleToCreator) { userGroupRoleLocalService.addUserGroupRoles(usuarios, course.getGroupCreatedId(), lmsPrefs.getEditorRole()); } LayoutSetPrototype lsProto = layoutSetPrototypeLocalService.getLayoutSetPrototype(layoutSetPrototypeId); //importLayouts(getAdministratorUser(serviceContext.getCompanyId()).getUserId(), group, lsProto); importLayouts(userId, group, lsProto); CourseEval courseEval = new CourseEvalRegistry().getCourseEval(CourseEvalId); if (courseEval != null) { courseEval.setExtraContent(course, "ADD_COURSE", serviceContext); } /* activamos social activity para la comunidad creada */ List<SocialActivitySetting> actSettings = SocialActivitySettingLocalServiceUtil .getActivitySettings(lsProto.getGroup().getGroupId()); for (SocialActivitySetting actSetting : actSettings) { //Activamos las activity settings que estn activadas en la plantilla SocialActivitySettingLocalServiceUtil.updateActivitySetting(group.getGroupId(), actSetting.getClassName(), true); List<SocialActivityDefinition> sads = SocialActivitySettingServiceUtil .getActivityDefinitions(lsProto.getGroup().getGroupId(), actSetting.getClassName()); for (SocialActivityDefinition sad : sads) { java.util.Collection<SocialActivityCounterDefinition> sacdl = sad .getActivityCounterDefinitions(); List<SocialActivityCounterDefinition> sacdlnew = new java.util.ArrayList<SocialActivityCounterDefinition>(); for (SocialActivityCounterDefinition sacd : sacdl) { SocialActivityCounterDefinition sacdn = sacd.clone(); sacdlnew.add(sacdn); } SocialActivitySettingServiceUtil.updateActivitySettings(group.getGroupId(), actSetting.getClassName(), sad.getActivityType(), sacdlnew); } } Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Course.class); indexer.reindex(course); } catch (PortalException e) { if (log.isInfoEnabled()) { log.info("CourseLocalServiceImpl.addCourse(): " + e + "message: " + e.getMessage()); } throw e; } catch (Exception e) { if (log.isInfoEnabled()) { log.info("CourseLocalServiceImpl.addCourse(): " + e + "message: " + e.getMessage()); } throw new PortalException(e.getMessage()); } // METODO METIDO POR MIGUEL if (!isfromClone) { Module newModule; try { newModule = ModuleLocalServiceUtil .createModule(CounterLocalServiceUtil.increment(Module.class.getName())); newModule.setTitle(LanguageUtil.get(locale, "com.liferay.lms.model.module"), locale); newModule.setDescription(LanguageUtil.get(locale, "description"), locale); newModule.setCompanyId(course.getCompanyId()); newModule.setGroupId(course.getGroupCreatedId()); newModule.setUserId(course.getUserId()); newModule.setOrdern(newModule.getModuleId()); /* Calendar start = Calendar.getInstance(); start.setTimeInMillis(module.getStartDate().getTime() + TimeUnit.MILLISECONDS.convert(days, TimeUnit.DAYS)); Calendar stop = Calendar.getInstance(); stop.setTimeInMillis(module.getEndDate().getTime() + TimeUnit.MILLISECONDS.convert(days, TimeUnit.DAYS)); */ //System.out.println(" startDate: "+ start.getTime() +" -> "+module.getStartDate()); //System.out.println(" stopDate : "+ stop.getTime() +" -> "+module.getEndDate()); newModule.setStartDate(startDate); newModule.setEndDate(endDate); ModuleLocalServiceUtil.addModule(newModule); System.out.println(" + Module : " + newModule.getTitle(Locale.getDefault()) + "(" + newModule.getModuleId() + ")"); } catch (Exception e) { e.printStackTrace(); } } //////////////////////////// //auditing AuditingLogFactory.audit(course.getCompanyId(), course.getGroupId(), Course.class.getName(), course.getCourseId(), userId, AuditConstants.ADD, null); return course; }
From source file:com.liferay.lms.service.impl.LearningActivityLocalServiceImpl.java
License:Open Source License
public LearningActivity addLearningActivity(String title, String description, java.util.Date createDate, java.util.Date startDate, java.util.Date endDate, int typeId, long tries, int passpuntuation, long moduleId, String extracontent, String feedbackCorrect, String feedbackNoCorrect, ServiceContext serviceContext) throws SystemException, PortalException { String titleAux = title;//from www . jav a2 s . c om long userId = serviceContext.getUserId(); LearningActivity larn = learningActivityPersistence .create(counterLocalService.increment(LearningActivity.class.getName())); larn.setCompanyId(serviceContext.getCompanyId()); larn.setGroupId(serviceContext.getScopeGroupId()); larn.setUserId(userId); larn.setUserName(userLocalService.getUser(userId).getFullName()); larn.setGroupId(serviceContext.getScopeGroupId()); larn.setDescription(description); larn.setTypeId(typeId); larn.setTitle(title); larn.setStartdate(startDate); larn.setCreateDate(new java.util.Date(System.currentTimeMillis())); larn.setModifiedDate(new java.util.Date(System.currentTimeMillis())); larn.setEnddate(endDate); larn.setTries(tries); larn.setPasspuntuation(passpuntuation); larn.setStatus(WorkflowConstants.STATUS_APPROVED); larn.setModuleId(moduleId); larn.setExtracontent(extracontent); larn.setPriority(larn.getActId()); larn.setFeedbackCorrect(feedbackCorrect); larn.setFeedbackNoCorrect(feedbackNoCorrect); larn = LmsLocaleUtil.checkDefaultLocale(LearningActivity.class, larn, "title"); larn = LmsLocaleUtil.checkDefaultLocale(LearningActivity.class, larn, "description"); learningActivityPersistence.update(larn, true); resourceLocalService.addModelResources(larn, serviceContext); assetEntryLocalService.updateEntry(userId, larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(), larn.getUuid(), typeId, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, new java.util.Date(System.currentTimeMillis()), null, ContentTypes.TEXT_HTML, larn.getTitle().length() < 255 ? larn.getTitle() : larn.getTitle(Locale.getDefault()), null, larn.getDescription(serviceContext.getLocale()), null, null, 0, 0, null, false); socialActivityLocalService.addUniqueActivity(larn.getUserId(), larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(), 0, StringPool.BLANK, 0); //auditing AuditingLogFactory.audit(larn.getCompanyId(), larn.getGroupId(), LearningActivity.class.getName(), larn.getPrimaryKey(), serviceContext.getUserId(), AuditConstants.ADD, null); boolean isNotificationActivated = PrefsPropsUtil.getBoolean(larn.getCompanyId(), "lms.notifications.active"); if (isNotificationActivated && larn.getTypeId() != 8) { List<User> listaUsuarios = userService.getGroupUsers(larn.getGroupId()); Iterator<User> it = listaUsuarios.iterator(); while (it.hasNext()) { User u = it.next(); try { if (u.isActive() && !(PermissionCheckerFactoryUtil.create(u)).hasPermission(larn.getGroupId(), "com.liferay.lms.model", larn.getGroupId(), "VIEW_RESULTS") && !larn.isInactive() && !larn.isExpired() && !moduleService.isLocked(larn.getModuleId()) && !courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()).isInactive() && !courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()).isExpired() && !courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()).isClosed()) { String courseTitle = courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()) .getTitle(u.getLocale()); String subject = LanguageUtil.format(u.getLocale(), "notif.modification.new.title", null); String body = LanguageUtil.format(u.getLocale(), "notif.modification.new.body", new String[] { titleAux, courseTitle }); sendNotification(subject, body, "", "announcements.type.general", 1, serviceContext, startDate, endDate, u.getUserId()); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return larn; }
From source file:com.liferay.lms.service.impl.LearningActivityLocalServiceImpl.java
License:Open Source License
public LearningActivity modLearningActivity(long actId, String title, String description, java.util.Date createDate, java.util.Date startDate, java.util.Date endDate, int typeId, long tries, int passpuntuation, long moduleId, String extracontent, String feedbackCorrect, String feedbackNoCorrect, ServiceContext serviceContext) throws SystemException, PortalException { long userId = serviceContext.getUserId(); LearningActivity larn = this.getLearningActivity(actId); String titleAux = larn.getTitle(serviceContext.getLocale()); larn.setCompanyId(serviceContext.getCompanyId()); larn.setGroupId(serviceContext.getScopeGroupId()); larn.setUserId(userId);// w ww.j ava 2 s . com larn.setDescription(description); larn.setTitle(title); larn.setStartdate(startDate); larn.setEnddate(endDate); larn.setTries(tries); larn.setPasspuntuation(passpuntuation); larn.setStatus(WorkflowConstants.STATUS_APPROVED); larn.setModuleId(moduleId); larn.setExtracontent(extracontent); larn.setFeedbackCorrect(feedbackCorrect); larn.setFeedbackNoCorrect(feedbackNoCorrect); larn = LmsLocaleUtil.checkDefaultLocale(LearningActivity.class, larn, "title"); larn = LmsLocaleUtil.checkDefaultLocale(LearningActivity.class, larn, "description"); learningActivityPersistence.update(larn, true); try { assetEntryLocalService.updateEntry(userId, larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(), larn.getUuid(), larn.getTypeId(), serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, new java.util.Date(System.currentTimeMillis()), null, ContentTypes.TEXT_HTML, larn.getTitle(), null, larn.getDescription(serviceContext.getLocale()), null, null, 0, 0, null, false); SocialActivityLocalServiceUtil.addActivity(larn.getUserId(), larn.getGroupId(), LearningActivity.class.getName(), larn.getActId(), 1, StringPool.BLANK, 0); } catch (Exception e) { } //auditing AuditingLogFactory.audit(larn.getCompanyId(), larn.getGroupId(), LearningActivity.class.getName(), larn.getPrimaryKey(), serviceContext.getUserId(), AuditConstants.UPDATE, null); boolean isNotificationActivated = PrefsPropsUtil.getBoolean(larn.getCompanyId(), "lms.notifications.active"); if (isNotificationActivated && larn.getTypeId() != 8) { List<User> listaUsuarios = userService.getGroupUsers(larn.getGroupId()); Iterator<User> it = listaUsuarios.iterator(); while (it.hasNext()) { User u = it.next(); try { if (u.isActive() && !(PermissionCheckerFactoryUtil.create(u)).hasPermission(larn.getGroupId(), "com.liferay.lms.model", larn.getGroupId(), "VIEW_RESULTS") && !larn.isInactive() && !larn.isExpired() && !moduleService.isLocked(larn.getModuleId()) && !courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()).isInactive() && !courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()).isExpired() && !courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()).isClosed()) { String courseTitle = courseLocalService.getCourseByGroupCreatedId(larn.getGroupId()) .getTitle(u.getLocale()); String subject = LanguageUtil.format(u.getLocale(), "notif.modification.larn.title", null); String body = LanguageUtil.format(u.getLocale(), "notif.modification.larn.body", new String[] { titleAux, courseTitle }); sendNotification(subject, body, "", "announcements.type.general", 1, serviceContext, startDate, endDate, u.getUserId()); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return larn; }
From source file:com.liferay.lms.service.impl.SCORMContentLocalServiceImpl.java
License:Open Source License
public SCORMContent addSCORMContent(String title, String description, File scormfile, boolean ciphered, ServiceContext serviceContext) throws SystemException, PortalException, IOException { SCORMContent scocontent = scormContentPersistence .create(counterLocalService.increment(SCORMContent.class.getName())); long userId = serviceContext.getUserId(); scocontent.setCompanyId(serviceContext.getCompanyId()); String uuid = serviceContext.getUuid(); if (Validator.isNotNull(uuid)) { scocontent.setUuid(uuid);/*from w ww. j a va2s . co m*/ } scocontent.setGroupId(serviceContext.getScopeGroupId()); scocontent.setUserId(userId); scocontent.setDescription(description); scocontent.setTitle(title); scocontent.setCiphered(ciphered); scocontent.setStatus(WorkflowConstants.STATUS_APPROVED); scocontent.setExpandoBridgeAttributes(serviceContext); scormContentPersistence.update(scocontent, true); String dirScorm = getDirScormPath(scocontent); File dir = new File(dirScorm); String dirScormZip = getDirScormzipPath(scocontent); File dirZip = new File(dirScormZip); FileUtils.forceMkdir(dir); FileUtils.forceMkdir(dirZip); File scormFileZip = new File(dirZip.getAbsolutePath() + "/" + scocontent.getUuid() + ".zip"); FileUtils.copyFile(scormfile, scormFileZip); try { ZipFile zipFile = new ZipFile(scormfile); zipFile.extractAll(dir.getCanonicalPath()); File manifestfile = new File(dir.getCanonicalPath() + "/imsmanifest.xml"); try { Document imsdocument = SAXReaderUtil.read(manifestfile); Element item = imsdocument.getRootElement().element("organizations").elements("organization").get(0) .elements("item").get(0); String resourceid = item.attributeValue("identifierref"); java.util.List<Element> resources = imsdocument.getRootElement().element("resources") .elements("resource"); for (Element resource : resources) { if (resource.attributeValue("identifier").equals(resourceid)) { scocontent.setIndex(resource.attributeValue("href")); scormContentPersistence.update(scocontent, true); } } } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (ZipException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) { resourceLocalService.addResources(serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), userId, SCORMContent.class.getName(), scocontent.getPrimaryKey(), false, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions()); } else { resourceLocalService.addModelResources(serviceContext.getCompanyId(), serviceContext.getScopeGroupId(), userId, SCORMContent.class.getName(), scocontent.getPrimaryKey(), serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); } assetEntryLocalService.updateEntry(userId, scocontent.getGroupId(), SCORMContent.class.getName(), scocontent.getScormId(), scocontent.getUuid(), 0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, null, null, new java.util.Date(System.currentTimeMillis()), null, ContentTypes.TEXT_HTML, scocontent.getTitle(), null, HtmlUtil.extractText(scocontent.getDescription()), getUrlManifest(scocontent), null, 0, 0, null, false); Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(SCORMContent.class); indexer.reindex(scocontent); return scocontent; }
From source file:com.liferay.login.web.internal.portlet.action.CreateAccountMVCActionCommand.java
License:Open Source License
protected void addUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = _portal.getHttpServletRequest(actionRequest); HttpSession session = request.getSession(); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); boolean autoPassword = true; String password1 = null;/*from w ww . j av a 2 s .c o m*/ String password2 = null; boolean autoScreenName = isAutoScreenName(); String screenName = ParamUtil.getString(actionRequest, "screenName"); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); long facebookId = ParamUtil.getLong(actionRequest, "facebookId"); String openId = ParamUtil.getString(actionRequest, "openId"); String languageId = ParamUtil.getString(actionRequest, "languageId"); String firstName = ParamUtil.getString(actionRequest, "firstName"); String middleName = ParamUtil.getString(actionRequest, "middleName"); String lastName = ParamUtil.getString(actionRequest, "lastName"); long prefixId = ParamUtil.getInteger(actionRequest, "prefixId"); long suffixId = ParamUtil.getInteger(actionRequest, "suffixId"); boolean male = ParamUtil.getBoolean(actionRequest, "male", true); int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth"); int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay"); int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear"); String jobTitle = ParamUtil.getString(actionRequest, "jobTitle"); long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; long[] userGroupIds = null; boolean sendEmail = true; ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest); if (PropsValues.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD) { autoPassword = false; password1 = ParamUtil.getString(actionRequest, "password1"); password2 = ParamUtil.getString(actionRequest, "password2"); } boolean openIdPending = false; Boolean openIdLoginPending = (Boolean) session.getAttribute(WebKeys.OPEN_ID_LOGIN_PENDING); if ((openIdLoginPending != null) && openIdLoginPending.booleanValue() && Validator.isNotNull(openId)) { sendEmail = false; openIdPending = true; } User user = _userService.addUserWithWorkflow(company.getCompanyId(), autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, LocaleUtil.fromLanguageId(languageId), firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext); if (openIdPending) { session.setAttribute(WebKeys.OPEN_ID_LOGIN, Long.valueOf(user.getUserId())); session.removeAttribute(WebKeys.OPEN_ID_LOGIN_PENDING); } else { // Session messages if (user.getStatus() == WorkflowConstants.STATUS_APPROVED) { SessionMessages.add(request, "userAdded", user.getEmailAddress()); SessionMessages.add(request, "userAddedPassword", user.getPasswordUnencrypted()); } else { SessionMessages.add(request, "userPending", user.getEmailAddress()); } } // Send redirect sendRedirect(actionRequest, actionResponse, themeDisplay, user, user.getPasswordUnencrypted()); }
From source file:com.liferay.login.web.internal.portlet.action.CreateAccountMVCActionCommand.java
License:Open Source License
protected void updateIncompleteUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = _portal .getOriginalServletRequest(_portal.getHttpServletRequest(actionRequest)); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); boolean autoPassword = true; String password1 = null;/*from ww w. j av a 2s . c o m*/ String password2 = null; boolean autoScreenName = false; String screenName = ParamUtil.getString(actionRequest, "screenName"); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); HttpSession session = request.getSession(); long facebookId = GetterUtil.getLong(session.getAttribute(WebKeys.FACEBOOK_INCOMPLETE_USER_ID)); String googleUserId = GetterUtil.getString(session.getAttribute(WebKeys.GOOGLE_INCOMPLETE_USER_ID)); if (Validator.isNotNull(googleUserId)) { autoPassword = false; } if ((facebookId > 0) || Validator.isNotNull(googleUserId)) { password1 = PwdGenerator.getPassword(); password2 = password1; } String openId = ParamUtil.getString(actionRequest, "openId"); String firstName = ParamUtil.getString(actionRequest, "firstName"); String middleName = ParamUtil.getString(actionRequest, "middleName"); String lastName = ParamUtil.getString(actionRequest, "lastName"); long prefixId = ParamUtil.getInteger(actionRequest, "prefixId"); long suffixId = ParamUtil.getInteger(actionRequest, "suffixId"); boolean male = ParamUtil.getBoolean(actionRequest, "male", true); int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth"); int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay"); int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear"); String jobTitle = ParamUtil.getString(actionRequest, "jobTitle"); boolean updateUserInformation = true; boolean sendEmail = true; if (Validator.isNotNull(googleUserId)) { sendEmail = false; } ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest); User user = _userService.updateIncompleteUser(themeDisplay.getCompanyId(), autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, themeDisplay.getLocale(), firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, updateUserInformation, sendEmail, serviceContext); if (facebookId > 0) { session.removeAttribute(WebKeys.FACEBOOK_INCOMPLETE_USER_ID); updateUserAndSendRedirect(actionRequest, actionResponse, themeDisplay, user, password1); return; } if (Validator.isNotNull(googleUserId)) { _userLocalService.updateGoogleUserId(user.getUserId(), googleUserId); session.removeAttribute(WebKeys.GOOGLE_INCOMPLETE_USER_ID); updateUserAndSendRedirect(actionRequest, actionResponse, themeDisplay, user, password1); return; } // Session messages if (user.getStatus() == WorkflowConstants.STATUS_APPROVED) { SessionMessages.add(request, "userAdded", user.getEmailAddress()); SessionMessages.add(request, "userAddedPassword", user.getPasswordUnencrypted()); } else { SessionMessages.add(request, "userPending", user.getEmailAddress()); } // Send redirect sendRedirect(actionRequest, actionResponse, themeDisplay, user, user.getPasswordUnencrypted()); }
From source file:com.liferay.login.web.internal.portlet.action.CreateAnonymousAccountMVCActionCommand.java
License:Open Source License
protected JSONObject updateIncompleteUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest); boolean autoPassword = true; String password1 = null;/*from w w w . j ava 2 s . c o m*/ String password2 = null; boolean autoScreenName = false; String screenName = null; String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); long facebookId = 0; String openId = null; String firstName = null; String middleName = null; String lastName = null; long prefixId = 0; long suffixId = 0; boolean male = true; int birthdayMonth = 0; int birthdayDay = 1; int birthdayYear = 1970; String jobTitle = null; boolean updateUserInformation = false; boolean sendEmail = true; User user = _userService.updateIncompleteUser(themeDisplay.getCompanyId(), autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, themeDisplay.getLocale(), firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, updateUserInformation, sendEmail, serviceContext); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); if (user.getStatus() == WorkflowConstants.STATUS_APPROVED) { jsonObject.put("userStatus", "user_added"); } else { jsonObject.put("userStatus", "user_pending"); } return jsonObject; }
From source file:com.liferay.mentions.hook.service.impl.MentionsBlogsEntryServiceImpl.java
License:Open Source License
@Override public BlogsEntry updateStatus(long userId, long entryId, int status, ServiceContext serviceContext, Map<String, Serializable> workflowContext) throws PortalException { BlogsEntry entry = BlogsEntryLocalServiceUtil.getEntry(entryId); int oldStatus = entry.getStatus(); entry = super.updateStatus(userId, entryId, status, serviceContext, workflowContext); if ((status != WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_IN_TRASH)) { return entry; }/* ww w.j a v a2 s.c om*/ long siteGroupId = PortalUtil.getSiteGroupId(entry.getGroupId()); if (!MentionsUtil.isMentionsEnabled(siteGroupId)) { return entry; } MentionsNotifier mentionsNotifier = new MentionsNotifier(); String contentURL = (String) serviceContext.getAttribute("contentURL"); if (Validator.isNull(contentURL)) { serviceContext.setAttribute("contentURL", workflowContext.get("url")); } mentionsNotifier.notify(entry.getUserId(), entry.getGroupId(), entry.getContent(), BlogsEntry.class.getName(), entry.getEntryId(), ContentUtil.get(PortletPropsValues.ASSET_ENTRY_MENTION_EMAIL_SUBJECT), ContentUtil.get(PortletPropsValues.ASSET_ENTRY_MENTION_EMAIL_BODY), serviceContext); return entry; }
From source file:com.liferay.mentions.hook.service.impl.MentionsMessageServiceImpl.java
License:Open Source License
@Override public MBMessage updateStatus(long userId, long messageId, int status, ServiceContext serviceContext, Map<String, Serializable> workflowContext) throws PortalException { MBMessage message = MBMessageLocalServiceUtil.getMessage(messageId); int oldStatus = message.getStatus(); message = super.updateStatus(userId, messageId, status, serviceContext, workflowContext); if ((status != WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_APPROVED) || (oldStatus == WorkflowConstants.STATUS_IN_TRASH)) { return message; }//ww w . j a v a 2 s .c o m long siteGroupId = PortalUtil.getSiteGroupId(message.getGroupId()); if (!MentionsUtil.isMentionsEnabled(siteGroupId)) { return message; } MentionsNotifier mentionsNotifier = new MentionsNotifier(); String content = message.getBody(); if (message.isFormatBBCode()) { content = BBCodeTranslatorUtil.getHTML(content); } content = HtmlUtil.extractText(content); String subject = ContentUtil.get(PortletPropsValues.COMMENT_MENTION_EMAIL_SUBJECT); String body = ContentUtil.get(PortletPropsValues.COMMENT_MENTION_EMAIL_BODY); if (!message.isDiscussion()) { subject = ContentUtil.get(PortletPropsValues.ASSET_ENTRY_MENTION_EMAIL_SUBJECT); body = ContentUtil.get(PortletPropsValues.ASSET_ENTRY_MENTION_EMAIL_BODY); } String contentURL = (String) serviceContext.getAttribute("contentURL"); if (Validator.isNull(contentURL)) { serviceContext.setAttribute("contentURL", workflowContext.get("url")); } mentionsNotifier.notify(message.getUserId(), message.getGroupId(), content, message.getModelClassName(), message.getMessageId(), subject, body, serviceContext); return message; }