// TODO: allow for dynamic user url building classes to be injected private void addUsers(Element element, Group suppliedGroup, ThemeDisplay themeDisplay) throws PortalException, SystemException { // get all users List<User> users = UserLocalServiceUtil.getGroupUsers(suppliedGroup.getGroupId()); // we're only displaying users with blogs for now for (User u : users) { Group usersOwnGroup = GroupLocalServiceUtil.getUserGroup(suppliedGroup.getCompanyId(), u.getUserId()); int count = BlogsEntryLocalServiceUtil.getGroupEntriesCount(usersOwnGroup.getGroupId()); List<BlogsEntry> entries = BlogsEntryLocalServiceUtil.getGroupEntries(usersOwnGroup.getGroupId(), 0, count); // only add if the user has blogs if (entries != null && entries.size() > 0) { // index the user, as well StringBuffer baseUrl = new StringBuffer(themeDisplay.getPortalURL()); // TODO figure out where web comes from baseUrl.append("/web"); baseUrl.append(usersOwnGroup.getFriendlyURL()); Element userUrlElement = element.addElement("url"); userUrlElement.addElement("loc").addText(encodeXML(baseUrl.toString())); userUrlElement.addElement("changefreq").addText("daily"); } } }
@Override protected FileEntry addFileEntry( long userId, long groupId, long folderId, String fileName, String contentType, InputStream inputStream, long size, ServiceContext serviceContext) throws PortalException { Folder folder = BlogsEntryLocalServiceUtil.addAttachmentsFolder(userId, groupId); return PortletFileRepositoryUtil.addPortletFileEntry( groupId, userId, BlogsEntry.class.getName(), 0, BlogsConstants.SERVICE_NAME, folder.getFolderId(), inputStream, fileName, contentType, true); }
public BlogsEntryActionableDynamicQuery() throws SystemException { setBaseLocalService(BlogsEntryLocalServiceUtil.getService()); setClass(BlogsEntry.class); setClassLoader(PortalClassLoaderUtil.getClassLoader()); setPrimaryKeyPropertyName("entryId"); }
@Override protected int getNotInTrashBaseModelsCount(BaseModel<?> parentBaseModel) throws Exception { QueryDefinition<BlogsEntry> queryDefinition = new QueryDefinition<>(WorkflowConstants.STATUS_ANY); return BlogsEntryLocalServiceUtil.getGroupEntriesCount( (Long) parentBaseModel.getPrimaryKeyObj(), queryDefinition); }
protected void addBlogsEntry(long groupId, String assetTagName) throws Exception { ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(groupId, TestPropsValues.getUserId()); serviceContext.setAssetTagNames(new String[] {assetTagName}); BlogsEntryLocalServiceUtil.addEntry( TestPropsValues.getUserId(), RandomTestUtil.randomString(), RandomTestUtil.randomString(), serviceContext); }
@Test public void testEmailEntryUpdatedNotSentIfNotSpecified() throws Exception { BlogsEntry entry = BlogsTestUtil.addEntry(_group, true); BlogsEntryLocalServiceUtil.subscribe(_user.getUserId(), _group.getGroupId()); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(entry.getGroupId()); serviceContext.setAttribute("emailEntryUpdatedComment", "This entry was updated."); BlogsTestUtil.updateEntry(entry, StringUtil.randomString(), true, serviceContext); Assert.assertEquals(0, MailServiceTestUtil.getInboxSize()); }
@Override protected FileEntry fetchFileEntry(long userId, long groupId, long folderId, String fileName) throws PortalException { Folder folder = BlogsEntryLocalServiceUtil.addAttachmentsFolder(userId, groupId); try { return PortletFileRepositoryUtil.getPortletFileEntry(groupId, folder.getFolderId(), fileName); } catch (PortalException pe) { if (_log.isDebugEnabled()) { _log.debug(pe, pe); } return null; } }
@Override protected PortletPreferences doDeleteData( PortletDataContext portletDataContext, String portletId, PortletPreferences portletPreferences) throws Exception { if (portletDataContext.addPrimaryKey(BlogsPortletDataHandler.class, "deleteData")) { return portletPreferences; } BlogsEntryLocalServiceUtil.deleteEntries(portletDataContext.getScopeGroupId()); BlogsStatsUserLocalServiceUtil.deleteStatsUserByGroupId(portletDataContext.getScopeGroupId()); return portletPreferences; }
@Test public void testEmailEntryUpdatedSentWithEmptyEmailEntryUpdatedComment() throws Exception { setUpBlogsSettings(); BlogsEntry entry = BlogsTestUtil.addEntry(_group, true); BlogsEntryLocalServiceUtil.subscribe(_user.getUserId(), _group.getGroupId()); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(entry.getGroupId()); serviceContext.setAttribute("sendEmailEntryUpdated", Boolean.TRUE.toString()); BlogsTestUtil.updateEntry(entry, StringUtil.randomString(), true, serviceContext); MailMessage message = MailServiceTestUtil.getLastMailMessage(); Assert.assertEquals(message.getBody(), StringPool.NEW_LINE); }
protected void reindexEntries(long companyId) throws PortalException { final ActionableDynamicQuery actionableDynamicQuery = BlogsEntryLocalServiceUtil.getActionableDynamicQuery(); actionableDynamicQuery.setAddCriteriaMethod( new ActionableDynamicQuery.AddCriteriaMethod() { @Override public void addCriteria(DynamicQuery dynamicQuery) { Property displayDateProperty = PropertyFactoryUtil.forName("displayDate"); dynamicQuery.add(displayDateProperty.lt(new Date())); Property statusProperty = PropertyFactoryUtil.forName("status"); Integer[] statuses = { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_IN_TRASH }; dynamicQuery.add(statusProperty.in(statuses)); } }); actionableDynamicQuery.setCompanyId(companyId); actionableDynamicQuery.setPerformActionMethod( new ActionableDynamicQuery.PerformActionMethod() { @Override public void performAction(Object object) throws PortalException { BlogsEntry entry = (BlogsEntry) object; Document document = getDocument(entry); actionableDynamicQuery.addDocument(document); } }); actionableDynamicQuery.setSearchEngineId(getSearchEngineId()); actionableDynamicQuery.performActions(); }
@Override public boolean isVisible(long classPK, int status) throws Exception { BlogsEntry entry = BlogsEntryLocalServiceUtil.getEntry(classPK); return isVisible(entry.getStatus(), status); }
@Override protected void doReindex(String className, long classPK) throws Exception { BlogsEntry entry = BlogsEntryLocalServiceUtil.getEntry(classPK); doReindex(entry); }
@Override protected BaseModel<?> getBaseModel(long primaryKey) throws Exception { return BlogsEntryLocalServiceUtil.getEntry(primaryKey); }
protected Object[] updateEntry(ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long entryId = ParamUtil.getLong(actionRequest, "entryId"); String title = ParamUtil.getString(actionRequest, "title"); String subtitle = ParamUtil.getString(actionRequest, "subtitle"); String description = StringPool.BLANK; boolean customAbstract = ParamUtil.getBoolean(actionRequest, "customAbstract"); if (customAbstract) { description = ParamUtil.getString(actionRequest, "description"); if (Validator.isNull(description)) { throw new EntryDescriptionException(); } } String content = ParamUtil.getString(actionRequest, "content"); int displayDateMonth = ParamUtil.getInteger(actionRequest, "displayDateMonth"); int displayDateDay = ParamUtil.getInteger(actionRequest, "displayDateDay"); int displayDateYear = ParamUtil.getInteger(actionRequest, "displayDateYear"); int displayDateHour = ParamUtil.getInteger(actionRequest, "displayDateHour"); int displayDateMinute = ParamUtil.getInteger(actionRequest, "displayDateMinute"); int displayDateAmPm = ParamUtil.getInteger(actionRequest, "displayDateAmPm"); if (displayDateAmPm == Calendar.PM) { displayDateHour += 12; } boolean allowPingbacks = ParamUtil.getBoolean(actionRequest, "allowPingbacks"); boolean allowTrackbacks = ParamUtil.getBoolean(actionRequest, "allowTrackbacks"); String[] trackbacks = StringUtil.split(ParamUtil.getString(actionRequest, "trackbacks")); long coverImageFileEntryId = ParamUtil.getLong(actionRequest, "coverImageFileEntryId"); String coverImageURL = ParamUtil.getString(actionRequest, "coverImageURL"); String coverImageFileEntryCropRegion = ParamUtil.getString(actionRequest, "coverImageFileEntryCropRegion"); String coverImageCaption = ParamUtil.getString(actionRequest, "coverImageCaption"); ImageSelector coverImageImageSelector = new ImageSelector(coverImageFileEntryId, coverImageURL, coverImageFileEntryCropRegion); long smallImageFileEntryId = ParamUtil.getLong(actionRequest, "smallImageFileEntryId"); String smallImageURL = ParamUtil.getString(actionRequest, "smallImageURL"); ImageSelector smallImageImageSelector = new ImageSelector(smallImageFileEntryId, smallImageURL, null); ServiceContext serviceContext = ServiceContextFactory.getInstance(BlogsEntry.class.getName(), actionRequest); BlogsEntry entry = null; String oldUrlTitle = StringPool.BLANK; List<BlogsEntryAttachmentFileEntryReference> blogsEntryAttachmentFileEntryReferences = new ArrayList<>(); if (entryId <= 0) { // Add entry entry = BlogsEntryServiceUtil.addEntry( title, subtitle, description, content, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, allowPingbacks, allowTrackbacks, trackbacks, coverImageCaption, coverImageImageSelector, smallImageImageSelector, serviceContext); BlogsEntryAttachmentFileEntryHelper blogsEntryAttachmentFileEntryHelper = new BlogsEntryAttachmentFileEntryHelper(); List<FileEntry> tempBlogsEntryAttachments = blogsEntryAttachmentFileEntryHelper.getTempBlogsEntryAttachmentFileEntries(content); if (!tempBlogsEntryAttachments.isEmpty()) { Folder folder = BlogsEntryLocalServiceUtil.addAttachmentsFolder( themeDisplay.getUserId(), entry.getGroupId()); blogsEntryAttachmentFileEntryReferences = blogsEntryAttachmentFileEntryHelper.addBlogsEntryAttachmentFileEntries( entry.getGroupId(), themeDisplay.getUserId(), entry.getEntryId(), folder.getFolderId(), tempBlogsEntryAttachments); content = blogsEntryAttachmentFileEntryHelper.updateContent( content, blogsEntryAttachmentFileEntryReferences); entry.setContent(content); BlogsEntryLocalServiceUtil.updateBlogsEntry(entry); } for (FileEntry tempBlogsEntryAttachment : tempBlogsEntryAttachments) { PortletFileRepositoryUtil.deletePortletFileEntry(tempBlogsEntryAttachment.getFileEntryId()); } } else { // Update entry boolean sendEmailEntryUpdated = ParamUtil.getBoolean(actionRequest, "sendEmailEntryUpdated"); serviceContext.setAttribute("sendEmailEntryUpdated", sendEmailEntryUpdated); String emailEntryUpdatedComment = ParamUtil.getString(actionRequest, "emailEntryUpdatedComment"); serviceContext.setAttribute("emailEntryUpdatedComment", emailEntryUpdatedComment); entry = BlogsEntryLocalServiceUtil.getEntry(entryId); String tempOldUrlTitle = entry.getUrlTitle(); BlogsEntryAttachmentFileEntryHelper blogsEntryAttachmentHelper = new BlogsEntryAttachmentFileEntryHelper(); List<FileEntry> tempBlogsEntryAttachmentFileEntries = blogsEntryAttachmentHelper.getTempBlogsEntryAttachmentFileEntries(content); if (!tempBlogsEntryAttachmentFileEntries.isEmpty()) { Folder folder = BlogsEntryLocalServiceUtil.addAttachmentsFolder( themeDisplay.getUserId(), entry.getGroupId()); blogsEntryAttachmentFileEntryReferences = blogsEntryAttachmentHelper.addBlogsEntryAttachmentFileEntries( entry.getGroupId(), themeDisplay.getUserId(), entry.getEntryId(), folder.getFolderId(), tempBlogsEntryAttachmentFileEntries); content = blogsEntryAttachmentHelper.updateContent( content, blogsEntryAttachmentFileEntryReferences); } entry = BlogsEntryServiceUtil.updateEntry( entryId, title, subtitle, description, content, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, allowPingbacks, allowTrackbacks, trackbacks, coverImageCaption, coverImageImageSelector, smallImageImageSelector, serviceContext); for (FileEntry tempBlogsEntryAttachmentFileEntry : tempBlogsEntryAttachmentFileEntries) { PortletFileRepositoryUtil.deletePortletFileEntry( tempBlogsEntryAttachmentFileEntry.getFileEntryId()); } if (!tempOldUrlTitle.equals(entry.getUrlTitle())) { oldUrlTitle = tempOldUrlTitle; } } return new Object[] {entry, oldUrlTitle, blogsEntryAttachmentFileEntryReferences}; }
@Override protected void moveBaseModelToTrash(long primaryKey) throws Exception { BlogsEntryLocalServiceUtil.moveEntryToTrash(TestPropsValues.getUserId(), primaryKey); }
private String formatJournalArticleURL() { /* This checks if the object is viewable by the current user and, if so, works out * the original url for the search results. The "visible" flag variable is set for each one. */ Long lGroupId; Long lArticleId; Long lUserId; String strJournalURL = Global.strNoURLReturned; JournalContentSearchLocalServiceUtil jcslu = new JournalContentSearchLocalServiceUtil(); LayoutLocalServiceUtil llsu = new LayoutLocalServiceUtil(); List<Long> listLayouts = new ArrayList<Long>(); Layout layLayout; User user; int iCount = 0; this.isVisible = false; try { this.context = FacesContext.getCurrentInstance(); this.portletRequest = (PortletRequest) context.getExternalContext().getRequest(); this.themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); } catch (Exception e) { System.out.println(e); } try { lGroupId = Long.decode(this.getGroupId()); } catch (NumberFormatException n) { lGroupId = 0l; // zero long, not letter O } try { lArticleId = Long.decode(this.getArticleId()); } catch (NumberFormatException n) { lArticleId = 0l; // zero long, not letter O } try { lUserId = Long.decode(this.getUserId()); } catch (NumberFormatException n) { lUserId = 0l; // zero long, not letter O } if ((lGroupId != 0) && (lArticleId != 0)) { try { try { permissionChecker = themeDisplay.getPermissionChecker(); this.setIsVisible( permissionChecker.hasPermission( lGroupId, this.entryClassName, this.rootEntryClassPK, ActionKeys.VIEW)); if (this.isIsVisible()) { if (getEntryClassName().equalsIgnoreCase(JournalArticle.class.getName())) { iCount = jcslu.getLayoutIdsCount(lGroupId, false, articleId); listLayouts = jcslu.getLayoutIds(lGroupId, false, articleId); if (iCount > 0) { layLayout = llsu.getLayout(lGroupId, false, listLayouts.get(0)); layoutFriendlyURL = PortalUtil.getLayoutFriendlyURL(layLayout, themeDisplay); layoutFullURL = PortalUtil.getLayoutActualURL(layLayout, themeDisplay.getPathMain()); strHost = portletRequest.getServerName(); iServerPort = portletRequest.getServerPort(); strScheme = portletRequest.getScheme(); if (layoutFullURL.startsWith("http://")) { strJournalURL = layoutFullURL; } else { if (strHost.equalsIgnoreCase("localhost")) { strJournalURL = strScheme + "://" + strHost + ":" + iServerPort + layoutFriendlyURL; } else { strJournalURL = layoutFriendlyURL; } } } } else if (getEntryClassName().equalsIgnoreCase(BlogsEntry.class.getName())) { BlogsEntry entry = BlogsEntryLocalServiceUtil.getEntry(lArticleId); Group trgtGroup = GroupLocalServiceUtil.getGroup(lGroupId); String strFrUrl = trgtGroup.getFriendlyURL(); String strUrlPath; user = UserLocalServiceUtil.getUser(lUserId); if (strFrUrl.equalsIgnoreCase("/fishnet")) { strUrlPath = "/home/-/blogs/"; } else if (strFrUrl.equalsIgnoreCase("/fishlink")) { strUrlPath = "/home/-/blogs/"; } else if (strFrUrl.equalsIgnoreCase("/freshwater-biological-association")) { strUrlPath = "/home/-/blogs/"; } else { strUrlPath = "/blog/-/blogs/"; } layoutFriendlyURL = "/web" + strFrUrl + strUrlPath + entry.getUrlTitle(); strHost = portletRequest.getServerName(); iServerPort = portletRequest.getServerPort(); strScheme = portletRequest.getScheme(); strJournalURL = strScheme + "://" + strHost + ":" + iServerPort + layoutFriendlyURL; } else if (getEntryClassName().equalsIgnoreCase(WikiPage.class.getName())) { WikiPageResource pageResource = WikiPageResourceLocalServiceUtil.getPageResource(lArticleId); WikiPage wikiPage = WikiPageLocalServiceUtil.getPage( pageResource.getNodeId(), pageResource.getTitle()); WikiNode wikiNode = WikiNodeLocalServiceUtil.getNode(pageResource.getNodeId()); String strWikiNodeName = wikiNode.getName(); String strWikiTitle = wikiPage.getTitle(); Long lPageGroupId = wikiPage.getGroupId(); Group trgtGroup = GroupLocalServiceUtil.getGroup(lPageGroupId); String strFrUrl = trgtGroup.getFriendlyURL(); strHost = portletRequest.getServerName(); iServerPort = portletRequest.getServerPort(); strScheme = portletRequest.getScheme(); // Extremely nasty hack! if (strFrUrl.equalsIgnoreCase("/tera")) { String strReplacedTitle = strWikiTitle.replaceAll("\\s", "\\+"); layoutFriendlyURL = "/web" + strFrUrl + "/home?p_p_id=54_INSTANCE_rU18&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_54_INSTANCE_rU18_struts_action=%2Fwiki_display%2Fview&_54_INSTANCE_rU18_nodeName=" + strWikiNodeName + "&_54_INSTANCE_rU18_title=" + strReplacedTitle; } else if (strFrUrl.equalsIgnoreCase("/fwl")) { layoutFriendlyURL = "/web" + strFrUrl + "/wiki/-/wiki/" + strWikiNodeName + "/" + strWikiTitle; } else if (strFrUrl.equalsIgnoreCase("/fishlink")) { layoutFriendlyURL = "/web" + strFrUrl + strFrUrl + "-wiki/-/wiki/" + strWikiNodeName + "/" + strWikiTitle; } else { layoutFriendlyURL = "/freshwater-wiki/-/wiki/" + strWikiNodeName + "/" + strWikiTitle; } // </hack> strJournalURL = strScheme + "://" + strHost + ":" + iServerPort + layoutFriendlyURL; } else if (getEntryClassName().equalsIgnoreCase(DLFileEntry.class.getName())) { DLFileEntry fileEntry = DLFileEntryLocalServiceUtil.getFileEntry(lArticleId); lGroupId = fileEntry.getGroupId(); AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(getEntryClassName(), lArticleId); Long lEntryId = assetEntry.getEntryId(); strHost = portletRequest.getServerName(); iServerPort = portletRequest.getServerPort(); strScheme = portletRequest.getScheme(); // Another hack layoutFriendlyURL = "/fwl/documents/-/asset_publisher/8Ztl/document/id/" + lEntryId; strJournalURL = strScheme + "://" + strHost + ":" + iServerPort + "/web" + layoutFriendlyURL; if (fileEntry.getTitle().isEmpty()) { this.setTitle("From Document Library"); } else { this.setTitle(fileEntry.getTitle()); } // } else if (getEntryClassName().equalsIgnoreCase(IGImage.class.getName())) { IGImage image = IGImageLocalServiceUtil.getImage(lArticleId); strHost = portletRequest.getServerName(); iServerPort = portletRequest.getServerPort(); strScheme = portletRequest.getScheme(); layoutFriendlyURL = "igimage.fba.org.uk"; // if (layoutFullURL.startsWith("http://")) { // strJournalURL = layoutFullURL; // } else { strJournalURL = strScheme + "://" + strHost + ":" + iServerPort + layoutFriendlyURL; // } // PortletURL viewImageURL = new PortletURLImpl(request, PortletKeys.IMAGE_GALLERY, // plid, PortletRequest.RENDER_PHASE); // viewImageURL.setWindowState(WindowState.MAXIMIZED); // viewImageURL.setParameter("struts_action", "/image_gallery/view"); // viewImageURL.setParameter("folderId", String.valueOf(image.getFolderId())); } else if (getEntryClassName().equalsIgnoreCase(MBMessage.class.getName())) { MBMessage message = MBMessageLocalServiceUtil.getMessage(lArticleId); String aHref = "<a href=" + themeDisplay.getPathMain() + "/message_boards/find_message?messageId=" + message.getMessageId() + ">"; strHost = portletRequest.getServerName(); iServerPort = portletRequest.getServerPort(); strScheme = portletRequest.getScheme(); layoutFriendlyURL = "mbmessage.fba.org.uk"; // if (layoutFullURL.startsWith("http://")) { // strJournalURL = layoutFullURL; // } else { strJournalURL = strScheme + "://" + strHost + ":" + iServerPort + layoutFriendlyURL; // } } else if (getEntryClassName().equalsIgnoreCase(BookmarksEntry.class.getName())) { BookmarksEntry entry = BookmarksEntryLocalServiceUtil.getEntry(lArticleId); String entryURL = themeDisplay.getPathMain() + "/bookmarks/open_entry?entryId=" + entry.getEntryId(); strHost = portletRequest.getServerName(); iServerPort = portletRequest.getServerPort(); strScheme = portletRequest.getScheme(); layoutFriendlyURL = "bookmarks.fba.org.uk"; // if (layoutFullURL.startsWith("http://")) { // strJournalURL = layoutFullURL; // } else { strJournalURL = strScheme + "://" + strHost + ":" + iServerPort + layoutFriendlyURL; // } } } } catch (PortalException ex) { Logger.getLogger(Liferay.class.getName()).log(Level.SEVERE, null, ex); } } catch (SystemException ex) { Logger.getLogger(Liferay.class.getName()).log(Level.SEVERE, null, ex); } } return strJournalURL; }
protected Object[] updateEntry(ActionRequest actionRequest) throws Exception { long entryId = ParamUtil.getLong(actionRequest, "entryId"); String title = ParamUtil.getString(actionRequest, "title"); String description = ParamUtil.getString(actionRequest, "description"); String content = ParamUtil.getString(actionRequest, "content"); int displayDateMonth = ParamUtil.getInteger(actionRequest, "displayDateMonth"); int displayDateDay = ParamUtil.getInteger(actionRequest, "displayDateDay"); int displayDateYear = ParamUtil.getInteger(actionRequest, "displayDateYear"); int displayDateHour = ParamUtil.getInteger(actionRequest, "displayDateHour"); int displayDateMinute = ParamUtil.getInteger(actionRequest, "displayDateMinute"); int displayDateAmPm = ParamUtil.getInteger(actionRequest, "displayDateAmPm"); if (displayDateAmPm == Calendar.PM) { displayDateHour += 12; } boolean allowPingbacks = ParamUtil.getBoolean(actionRequest, "allowPingbacks"); boolean allowTrackbacks = ParamUtil.getBoolean(actionRequest, "allowTrackbacks"); String[] trackbacks = StringUtil.split(ParamUtil.getString(actionRequest, "trackbacks")); boolean smallImage = false; String smallImageURL = null; String smallImageFileName = null; InputStream smallImageInputStream = null; BlogsEntry entry = null; String oldUrlTitle = null; try { boolean ajax = ParamUtil.getBoolean(actionRequest, "ajax"); if (!ajax) { smallImage = ParamUtil.getBoolean(actionRequest, "smallImage"); smallImageURL = ParamUtil.getString(actionRequest, "smallImageURL"); if (smallImage && Validator.isNull(smallImageURL)) { boolean attachments = ParamUtil.getBoolean(actionRequest, "attachments"); if (attachments) { UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); smallImageFileName = uploadPortletRequest.getFileName("smallFile"); smallImageInputStream = uploadPortletRequest.getFileAsStream("smallFile"); } } } ServiceContext serviceContext = ServiceContextFactory.getInstance(BlogsEntry.class.getName(), actionRequest); entry = null; oldUrlTitle = StringPool.BLANK; if (entryId <= 0) { // Add entry entry = BlogsEntryServiceUtil.addEntry( title, description, content, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, allowPingbacks, allowTrackbacks, trackbacks, smallImage, smallImageURL, smallImageFileName, smallImageInputStream, serviceContext); AssetPublisherUtil.addAndStoreSelection( actionRequest, BlogsEntry.class.getName(), entry.getEntryId(), -1); } else { // Update entry entry = BlogsEntryLocalServiceUtil.getEntry(entryId); String tempOldUrlTitle = entry.getUrlTitle(); entry = BlogsEntryServiceUtil.updateEntry( entryId, title, description, content, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, allowPingbacks, allowTrackbacks, trackbacks, smallImage, smallImageURL, smallImageFileName, smallImageInputStream, serviceContext); if (!tempOldUrlTitle.equals(entry.getUrlTitle())) { oldUrlTitle = tempOldUrlTitle; } AssetPublisherUtil.addAndStoreSelection( actionRequest, BlogsEntry.class.getName(), entry.getEntryId(), -1); } } finally { StreamUtil.cleanUp(smallImageInputStream); } return new Object[] {entry, oldUrlTitle}; }