List of usage examples for com.liferay.portal.kernel.service ServiceContext getModifiedDate
public Date getModifiedDate()
From source file:com.liferay.ide.utils.library.listener.service.impl.LibraryLocalServiceImpl.java
License:Open Source License
public Library updateLibrary(long libraryId, long repositoryId, String libraryGroupId, String libraryArtifactId, String latestVersion, String lastUpdated, String currentVersion, String resources, boolean enableListener, ServiceContext serviceContext) throws PortalException { Library library = libraryPersistence.fetchByPrimaryKey(libraryId); library.setUserId(serviceContext.getUserId()); library.setUserName(userLocalService.getUser(serviceContext.getUserId()).getFullName()); library.setRepositoryId(repositoryId); library.setLibraryGroupId(libraryGroupId); library.setLibraryArtifactId(libraryArtifactId); library.setLatestVersion(latestVersion); library.setLastUpdated(lastUpdated); library.setCurrentVersion(currentVersion); library.setResources(resources);/*from w ww. ja v a2 s. c o m*/ library.setEnableListener(enableListener); library.setModifiedDate(serviceContext.getModifiedDate()); libraryPersistence.update(library); return library; }
From source file:com.liferay.ide.utils.library.listener.service.impl.RepositoryLocalServiceImpl.java
License:Open Source License
public Repository updateRepository(long repositoryId, String repositoryName, String repositoryRootUrl, String repositoryUserName, String repositoryPassword, ServiceContext serviceContext) throws PortalException { Repository repository = repositoryPersistence.fetchByPrimaryKey(repositoryId); repository.setUserId(serviceContext.getUserId()); repository.setUserName(userLocalService.getUser(serviceContext.getUserId()).getFullName()); repository.setRepositoryName(repositoryName); repository.setRepositoryRootUrl(repositoryRootUrl); repository.setRepositoryUserName(repositoryUserName); repository.setRepositoryPassword(repositoryPassword); repository.setModifiedDate(serviceContext.getModifiedDate()); repositoryPersistence.update(repository); return repository; }
From source file:com.liferay.message.boards.internal.service.MBDiscussionMBMessageLocalServiceWrapper.java
License:Open Source License
@Override public MBMessage addDiscussionMessage(long userId, String userName, long groupId, String className, long classPK, long threadId, long parentMessageId, String subject, String body, ServiceContext serviceContext) throws PortalException { super.addDiscussionMessage(userId, userName, groupId, className, classPK, threadId, parentMessageId, subject, body, serviceContext); // Message/*from w w w . ja v a 2 s . co m*/ validateDiscussionMaxComments(className, classPK); long categoryId = MBCategoryConstants.DISCUSSION_CATEGORY_ID; subject = getDiscussionMessageSubject(subject, body); List<ObjectValuePair<String, InputStream>> inputStreamOVPs = Collections.emptyList(); boolean anonymous = false; double priority = 0.0; boolean allowPingbacks = false; serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setAttribute("className", className); serviceContext.setAttribute("classPK", String.valueOf(classPK)); Date now = new Date(); if (serviceContext.getCreateDate() == null) { serviceContext.setCreateDate(now); } if (serviceContext.getModifiedDate() == null) { serviceContext.setModifiedDate(now); } MBMessage message = addMessage(userId, userName, groupId, categoryId, threadId, parentMessageId, subject, body, PropsValues.DISCUSSION_COMMENTS_FORMAT, inputStreamOVPs, anonymous, priority, allowPingbacks, serviceContext); // Discussion if (parentMessageId == MBMessageConstants.DEFAULT_PARENT_MESSAGE_ID) { long classNameId = _classNameLocalService.getClassNameId(className); MBDiscussion discussion = _mbDiscussionLocalService.fetchDiscussion(classNameId, classPK); if (discussion == null) { _mbDiscussionLocalService.addDiscussion(userId, groupId, classNameId, classPK, message.getThreadId(), serviceContext); } } return message; }
From source file:com.liferay.pokedex.service.impl.PokemonLocalServiceImpl.java
License:Open Source License
@Override public Pokemon addPokemon(String originalName, String customName, String description, String type, long order, String frontImageURL, String frontShinyImageURL, String backImageURL, String backShinyImageURL, ServiceContext serviceContext) throws PortalException { // Entry//from w ww . j a v a 2 s. c o m User user = userPersistence.findByPrimaryKey(serviceContext.getUserId()); long groupId = user.getGroupId(); long id = counterLocalService.increment(); Pokemon pokemon = pokemonPersistence.create(id); pokemon.setUuid(serviceContext.getUuid()); pokemon.setGroupId(groupId); pokemon.setCompanyId(user.getCompanyId()); pokemon.setUserId(user.getUserId()); pokemon.setUserName(user.getFullName()); pokemon.setOriginalName(originalName); pokemon.setCustomName(customName); pokemon.setDescription(description); pokemon.setType(type); pokemon.setOrder(order); pokemon.setCreateDate(serviceContext.getCreateDate()); pokemon.setModifiedDate(serviceContext.getModifiedDate()); pokemon.setFrontImageURL(frontImageURL); pokemon.setFrontShinyImageURL(frontShinyImageURL); pokemon.setBackImageURL(backImageURL); pokemon.setBackShinyImageURL(backShinyImageURL); return pokemonPersistence.update(pokemon); }
From source file:com.liferay.pokedex.service.impl.PokemonLocalServiceImpl.java
License:Open Source License
@Override public Pokemon updatePokemon(long id, String customName, String description, ServiceContext serviceContext) throws PortalException { // Entry//from w ww.j av a 2 s . c o m User user = userPersistence.findByPrimaryKey(serviceContext.getUserId()); long groupId = serviceContext.getScopeGroupId(); Pokemon pokemon = pokemonPersistence.findByPrimaryKey(id); pokemon.setCustomName(customName); pokemon.setDescription(description); pokemon.setModifiedDate(serviceContext.getModifiedDate()); return pokemonPersistence.update(pokemon); }
From source file:com.liferay.roster.service.impl.RosterLocalServiceImpl.java
License:Open Source License
public Roster addRoster(long clubId, String name, ServiceContext serviceContext) { Roster roster = rosterLocalService.createRoster(counterLocalService.increment()); roster.setClubId(clubId);/*from w ww.j ava 2 s . co m*/ roster.setName(name); roster.setCreateDate(serviceContext.getCreateDate()); roster.setModifiedDate(serviceContext.getModifiedDate()); return rosterLocalService.addRoster(roster); }
From source file:com.liferay.roster.service.impl.RosterLocalServiceImpl.java
License:Open Source License
public Roster updateRoster(long rosterId, long clubId, String name, ServiceContext serviceContext) throws PortalException { Roster roster = rosterLocalService.getRoster(rosterId); roster.setClubId(clubId);/*from w w w. j av a2 s. co m*/ roster.setName(name); roster.setCreateDate(serviceContext.getCreateDate()); roster.setModifiedDate(serviceContext.getModifiedDate()); return rosterLocalService.updateRoster(roster); }
From source file:org.sidate.qanda.service.impl.AnswerLocalServiceImpl.java
License:Open Source License
public Answer addAnswer(String text, long questionId, ServiceContext serviceContext) { String portletId = serviceContext.getPortletId(); long groupId = serviceContext.getScopeGroupId(); long answerId = counterLocalService.increment(); Date createDate = serviceContext.getCreateDate(); Date modifiedDate = serviceContext.getModifiedDate(); String uuid = serviceContext.getUuid(); long userId = serviceContext.getUserId(); Answer answer = answerPersistence.create(answerId); answer.setUuid(uuid);/*from w w w .j a v a 2 s .c o m*/ answer.setCreateDate(createDate); answer.setModifiedDate(modifiedDate); answer.setUserId(userId); answer.setGroupId(groupId); answer.setExpandoBridgeAttributes(serviceContext); answer.setPortletId(portletId); answer.setQuestionId(questionId); answerPersistence.update(answer); try { resourceLocalService.addModelResources(answer, serviceContext); assetEntryLocalService.updateEntry(userId, answer.getGroupId(), answer.getCreateDate(), answer.getModifiedDate(), Answer.class.getName(), answer.getPrimaryKey(), answer.getUuid(), 0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, true, null, null, null, null, ContentTypes.TEXT_HTML, QuestionLocalServiceUtil.getQuestion(questionId).getTitle(), text, null, null, null, 0, 0, 0D); // Indexing Indexer<Answer> indexer = IndexerRegistryUtil.nullSafeGetIndexer(Answer.class); indexer.reindex(answer); socialActivityLocalService.addActivity(userId, groupId, Question.class.getName(), questionId, 2, "", QuestionLocalServiceUtil.getQuestion(questionId).getUserId()); } catch (PortalException e) { e.printStackTrace(); } return answer; }
From source file:org.sidate.qanda.service.impl.QuestionLocalServiceImpl.java
License:Open Source License
public Question addQuestion(String title, String text, boolean isQuestionToProcedure, long ProcedureId, ServiceContext serviceContext) throws PortalException { String portletId = serviceContext.getPortletId(); long groupId = serviceContext.getScopeGroupId(); long questionId = counterLocalService.increment(); Date createDate = serviceContext.getCreateDate(); Date modifiedDate = serviceContext.getModifiedDate(); String uuid = serviceContext.getUuid(); Question question = questionPersistence.create(questionId); long userId = serviceContext.getUserId(); question.setUserName(UserLocalServiceUtil.fetchUser(userId).getFullName()); question.setUuid(uuid);/* w w w. j a va 2 s . c o m*/ question.setCreateDate(createDate); question.setModifiedDate(modifiedDate); question.setUserId(userId); question.setGroupId(groupId); question.setExpandoBridgeAttributes(serviceContext); question.setIsAnswered(false); question.setPortletId(portletId); question.setIsQuestionToProcedure(isQuestionToProcedure); question.setProcedureId(ProcedureId); questionPersistence.update(question); resourceLocalService.addModelResources(question, serviceContext); assetEntryLocalService.updateEntry(serviceContext.getUserId(), question.getGroupId(), question.getCreateDate(), question.getModifiedDate(), Question.class.getName(), question.getPrimaryKey(), question.getUuid(), 0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), true, true, null, null, null, null, ContentTypes.TEXT_HTML, title, text, "", null, null, 0, 0, 0D); Indexer<Question> indexer = IndexerRegistryUtil.nullSafeGetIndexer(Question.class); indexer.reindex(question); socialActivityLocalService.addActivity(userId, groupId, Question.class.getName(), questionId, 1, "", 0); log.info("Question " + questionId + " has been added and indexed."); return question; }