List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants ACTION_PUBLISH
int ACTION_PUBLISH
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants ACTION_PUBLISH.
Click Source Link
From source file:com.liferay.wiki.ratings.test.WikiPageRatingsTest.java
License:Open Source License
@Override protected BaseModel<?> getParentBaseModel(Group group, ServiceContext serviceContext) throws Exception { serviceContext = (ServiceContext) serviceContext.clone(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); return WikiNodeLocalServiceUtil.addNode(TestPropsValues.getUserId(), RandomTestUtil.randomString(), RandomTestUtil.randomString(), serviceContext); }
From source file:com.liferay.wiki.trash.test.WikiNodeTrashHandlerTest.java
License:Open Source License
@Override protected BaseModel<?> addBaseModelWithWorkflow(BaseModel<?> parentBaseModel, ServiceContext serviceContext) throws Exception { serviceContext = (ServiceContext) serviceContext.clone(); serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH); return WikiNodeLocalServiceUtil.addNode(TestPropsValues.getUserId(), _NODE_NAME, RandomTestUtil.randomString(), serviceContext); }
From source file:com.liferay.wiki.web.internal.portlet.action.EditPageMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String cmd = ParamUtil.getString(actionRequest, Constants.CMD); WikiPage page = null;/*from w ww . j av a2s. com*/ try { if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) { page = updatePage(actionRequest); } else if (cmd.equals(Constants.DELETE)) { deletePage(actionRequest, false); } else if (cmd.equals(Constants.MOVE_TO_TRASH)) { deletePage(actionRequest, true); } else if (cmd.equals(Constants.RESTORE)) { restorePage(actionRequest); } else if (cmd.equals(Constants.REVERT)) { revertPage(actionRequest); } else if (cmd.equals(Constants.SUBSCRIBE)) { subscribePage(actionRequest); } else if (cmd.equals(Constants.UNSUBSCRIBE)) { unsubscribePage(actionRequest); } if (Validator.isNotNull(cmd)) { String redirect = ParamUtil.getString(actionRequest, "redirect"); int workflowAction = ParamUtil.getInteger(actionRequest, "workflowAction", WorkflowConstants.ACTION_PUBLISH); if (page != null) { if (workflowAction == WorkflowConstants.ACTION_SAVE_DRAFT) { redirect = getSaveAndContinueRedirect(actionRequest, actionResponse, page, redirect); } else if (redirect.endsWith("title=")) { redirect += page.getTitle(); } } sendRedirect(actionRequest, actionResponse, redirect); } } catch (Exception e) { if (e instanceof NoSuchNodeException || e instanceof NoSuchPageException || e instanceof PrincipalException) { SessionErrors.add(actionRequest, e.getClass()); } else if (e instanceof DuplicatePageException || e instanceof PageContentException || e instanceof PageVersionException || e instanceof PageTitleException || e instanceof SanitizerException) { SessionErrors.add(actionRequest, e.getClass()); } else if (e instanceof AssetCategoryException || e instanceof AssetTagException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { Throwable cause = e.getCause(); if (cause instanceof SanitizerException) { SessionErrors.add(actionRequest, SanitizerException.class); } else { throw e; } } } }
From source file:org.liferay.jukebox.service.impl.AlbumLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) public Album addAlbum(long userId, long artistId, String name, int year, InputStream inputStream, ServiceContext serviceContext) throws PortalException, SystemException { long groupId = serviceContext.getScopeGroupId(); User user = userPersistence.findByPrimaryKey(userId); Date now = new Date(); validate(name);/*from w ww. j a va2 s . c om*/ long albumId = counterLocalService.increment(); Album album = albumPersistence.create(albumId); album.setUuid(serviceContext.getUuid()); album.setGroupId(groupId); album.setCompanyId(user.getCompanyId()); album.setUserId(user.getUserId()); album.setUserName(user.getFullName()); album.setCreateDate(serviceContext.getCreateDate(now)); album.setModifiedDate(serviceContext.getModifiedDate(now)); album.setArtistId(artistId); album.setName(name); album.setYear(year); album.setExpandoBridgeAttributes(serviceContext); albumPersistence.update(album); if (inputStream != null) { PortletFileRepositoryUtil.addPortletFileEntry(groupId, userId, Album.class.getName(), album.getAlbumId(), Constants.JUKEBOX_PORTLET_REPOSITORY, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, inputStream, String.valueOf(album.getAlbumId()), StringPool.BLANK, true); } // Resources if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) { addEntryResources(album, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions()); } else { addEntryResources(album, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); } // Message boards mbMessageLocalService.addDiscussionMessage(userId, album.getUserName(), groupId, Album.class.getName(), albumId, WorkflowConstants.ACTION_PUBLISH); // Asset updateAsset(userId, album, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds()); return album; }
From source file:org.liferay.jukebox.service.impl.ArtistLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) public Artist addArtist(long userId, String name, String bio, InputStream inputStream, ServiceContext serviceContext) throws PortalException, SystemException { long groupId = serviceContext.getScopeGroupId(); User user = userPersistence.findByPrimaryKey(userId); Date now = new Date(); validate(name);// w ww . ja v a 2s . c om long artistId = counterLocalService.increment(); Artist artist = artistPersistence.create(artistId); artist.setUuid(serviceContext.getUuid()); artist.setGroupId(groupId); artist.setCompanyId(user.getCompanyId()); artist.setUserId(user.getUserId()); artist.setUserName(user.getFullName()); artist.setCreateDate(serviceContext.getCreateDate(now)); artist.setModifiedDate(serviceContext.getModifiedDate(now)); artist.setName(name); artist.setBio(bio); artist.setExpandoBridgeAttributes(serviceContext); artistPersistence.update(artist); if (inputStream != null) { PortletFileRepositoryUtil.addPortletFileEntry(groupId, userId, Artist.class.getName(), artist.getArtistId(), Constants.JUKEBOX_PORTLET_REPOSITORY, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, inputStream, String.valueOf(artist.getArtistId()), StringPool.BLANK, true); } // Resources if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) { addEntryResources(artist, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions()); } else { addEntryResources(artist, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); } // Message boards mbMessageLocalService.addDiscussionMessage(userId, artist.getUserName(), groupId, Artist.class.getName(), artistId, WorkflowConstants.ACTION_PUBLISH); // Asset updateAsset(userId, artist, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds()); return artist; }
From source file:org.liferay.jukebox.service.impl.SongLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) public Song addSong(long userId, long albumId, String name, String songFileName, InputStream songInputStream, String lyricsFileName, InputStream lyricsInputStream, ServiceContext serviceContext) throws PortalException, SystemException { long groupId = serviceContext.getScopeGroupId(); User user = userPersistence.findByPrimaryKey(userId); Date now = new Date(); long songId = counterLocalService.increment(); Album album = albumPersistence.findByPrimaryKey(albumId); validate(songId, groupId, album.getArtistId(), albumId, name); Song song = songPersistence.create(songId); song.setUuid(serviceContext.getUuid()); song.setGroupId(groupId);/*w w w . j a v a2 s . co m*/ song.setCompanyId(user.getCompanyId()); song.setUserId(user.getUserId()); song.setUserName(user.getFullName()); song.setCreateDate(serviceContext.getCreateDate(now)); song.setModifiedDate(serviceContext.getModifiedDate(now)); song.setArtistId(album.getArtistId()); song.setAlbumId(albumId); song.setName(name); song.setExpandoBridgeAttributes(serviceContext); songPersistence.update(song); if ((songInputStream != null) || (lyricsInputStream != null)) { Repository repository = PortletFileRepositoryUtil.addPortletRepository(groupId, Constants.JUKEBOX_PORTLET_REPOSITORY, serviceContext); Folder folder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(song.getSongId()), serviceContext); if (songInputStream != null) { Folder songFolder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), folder.getFolderId(), Constants.SONGS_FOLDER_NAME, serviceContext); FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(groupId, userId, Song.class.getName(), song.getSongId(), Constants.JUKEBOX_PORTLET_REPOSITORY, songFolder.getFolderId(), songInputStream, songFileName, StringPool.BLANK, true); DLProcessorRegistryUtil.trigger(fileEntry, null, true); } if (lyricsInputStream != null) { Folder lyricsFolder = PortletFileRepositoryUtil.addPortletFolder(userId, repository.getRepositoryId(), folder.getFolderId(), Constants.LYRICS_FOLDER_NAME, serviceContext); FileEntry fileEntry = PortletFileRepositoryUtil.addPortletFileEntry(groupId, userId, Song.class.getName(), song.getSongId(), Constants.JUKEBOX_PORTLET_REPOSITORY, lyricsFolder.getFolderId(), lyricsInputStream, lyricsFileName, StringPool.BLANK, true); DLProcessorRegistryUtil.trigger(fileEntry, null, true); } } // Resources if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) { addEntryResources(song, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions()); } else { addEntryResources(song, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); } // Message boards mbMessageLocalService.addDiscussionMessage(userId, album.getUserName(), groupId, Song.class.getName(), songId, WorkflowConstants.ACTION_PUBLISH); // Asset updateAsset(userId, song, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds()); return song; }
From source file:se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.java
License:Open Source License
@Override @Transactional(rollbackFor = CreateIdeaException.class) public Idea addIdea(Idea idea, String schemeServerNamePort) throws CreateIdeaException, PortalException, SystemException { // Do the urlTitle and ideaSiteLink before sending to Barium if (idea.getUrlTitle() == null) { idea.setUrlTitle(generateNewUrlTitle(idea.getTitle())); }/* w w w . j a v a 2 s. c o m*/ // idea.setIdeaSiteLink(generateIdeaSiteLink(schemeServerNamePort, idea.getUrlTitle())); idea = checkIfIdeaIsForAnotherPerson(idea); // Create Barium Idea BariumResponse bariumResponse = bariumService.createIdea(idea); // BariumResponse bariumResponse = new BariumResponse(true, "MOCKAD-12345666", ""); if (bariumResponse.getSuccess()) { String bariumId = bariumResponse.getInstanceId(); String phase = bariumService.getIdeaState(bariumId); idea.setPhase(phase); try { idea.setId(bariumId); idea.setStatus(IdeaStatus.PRIVATE_IDEA); // Persist idea idea = ideaRepository.persist(idea); // Use persist to assure it doesn't exist already. // Get references to persisted IdeaContent (public and private) IdeaContent ideaContentPublic = idea.getIdeaContentPublic(); IdeaContent ideaContentPrivate = idea.getIdeaContentPrivate(); boolean addCommunityPermissions = true; boolean addGuestPermissions = true; // Add resource for Idea resourceLocalService.addResources(idea.getCompanyId(), idea.getGroupId(), idea.getUserId(), Idea.class.getName(), idea.getId(), false, addCommunityPermissions, addGuestPermissions); ideaContentPublic.getGroupId(); ideaContentPublic.getId(); // Add public discussion mbMessageLocalService.addDiscussionMessage(idea.getUserId(), String.valueOf(ideaContentPublic.getUserId()), ideaContentPublic.getGroupId(), IdeaContent.class.getName(), ideaContentPublic.getId(), WorkflowConstants.ACTION_PUBLISH); // Add private discussion mbMessageLocalService.addDiscussionMessage(idea.getUserId(), String.valueOf(ideaContentPrivate.getUserId()), ideaContentPrivate.getGroupId(), IdeaContent.class.getName(), ideaContentPrivate.getId(), WorkflowConstants.ACTION_PUBLISH); } catch (SystemException e) { LOGGER.error(e.getMessage(), e); // Delete idea from Barium // Delete message board threads // Set BariumId to blank for idea // Ska vi inte ta bort idn frn db helt isf? throw new CreateIdeaException(e); } catch (PortalException e) { LOGGER.error(e.getMessage(), e); // Delete idea from Barium // Delete message board threads // Set BariumId to blank for idea // Ska vi inte ta bort idn frn db helt isf? // idea.setBariumId(""); throw new CreateIdeaException(e); } } else { throw new CreateIdeaException("Failed to create idea in Barium, bariumRestClient returned: " + bariumResponse.getJsonString()); } return idea; }