List of usage examples for com.liferay.portal.kernel.util ObjectValuePair ObjectValuePair
public ObjectValuePair(K key, V value)
From source file:com.cd.learning.hook.MBMailMessage.java
License:Open Source License
public void addBytes(String fileName, byte[] bytes) { _bytesOVPs.add(new ObjectValuePair<String, byte[]>(fileName, bytes)); }
From source file:com.cd.learning.hook.MBMailMessage.java
License:Open Source License
public List<ObjectValuePair<String, InputStream>> getInputStreamOVPs() { List<ObjectValuePair<String, InputStream>> inputStreamOVPs = new ArrayList<ObjectValuePair<String, InputStream>>( _bytesOVPs.size());//from w w w . ja v a 2 s . c om for (ObjectValuePair<String, byte[]> bytesOVP : _bytesOVPs) { String key = bytesOVP.getKey(); byte[] bytes = bytesOVP.getValue(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); ObjectValuePair<String, InputStream> inputStreamOVP = new ObjectValuePair<String, InputStream>(key, byteArrayInputStream); inputStreamOVPs.add(inputStreamOVP); } return inputStreamOVPs; }
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
protected List<ObjectValuePair<Long, Integer>> getArticleVersionStatuses(List<JournalArticle> articles) { List<ObjectValuePair<Long, Integer>> articleVersionStatusOVPs = new ArrayList<>(articles.size()); for (JournalArticle article : articles) { int status = article.getStatus(); if (status == WorkflowConstants.STATUS_PENDING) { status = WorkflowConstants.STATUS_DRAFT; }//from w ww .ja v a2 s . c om ObjectValuePair<Long, Integer> articleVersionStatusOVP = new ObjectValuePair<>(article.getId(), status); articleVersionStatusOVPs.add(articleVersionStatusOVP); } return articleVersionStatusOVPs; }
From source file:com.liferay.journal.service.impl.JournalFolderLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) @Override/* w w w. ja va 2 s .c o m*/ public JournalFolder updateFolder(long userId, long groupId, long folderId, long parentFolderId, String name, String description, long[] ddmStructureIds, int restrictionType, boolean mergeWithParentFolder, ServiceContext serviceContext) throws PortalException { JournalFolder folder = null; Set<Long> originalDDMStructureIds = new HashSet<>(); if (folderId > JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) { originalDDMStructureIds = getDDMStructureIds(ddmStructureLinkLocalService .getStructureLinks(classNameLocalService.getClassNameId(JournalFolder.class), folderId)); folder = doUpdateFolder(userId, folderId, parentFolderId, name, description, ddmStructureIds, restrictionType, mergeWithParentFolder, serviceContext); } List<ObjectValuePair<Long, String>> workflowDefinitionOVPs = new ArrayList<>(); if (restrictionType == JournalFolderConstants.RESTRICTION_TYPE_DDM_STRUCTURES_AND_WORKFLOW) { workflowDefinitionOVPs.add(new ObjectValuePair<Long, String>( JournalArticleConstants.DDM_STRUCTURE_ID_ALL, StringPool.BLANK)); for (long ddmStructureId : ddmStructureIds) { String workflowDefinition = ParamUtil.getString(serviceContext, "workflowDefinition" + ddmStructureId); workflowDefinitionOVPs.add(new ObjectValuePair<Long, String>(ddmStructureId, workflowDefinition)); } } else if (restrictionType == JournalFolderConstants.RESTRICTION_TYPE_INHERIT) { if (originalDDMStructureIds.isEmpty()) { originalDDMStructureIds.add(JournalArticleConstants.DDM_STRUCTURE_ID_ALL); } for (long originalDDMStructureId : originalDDMStructureIds) { workflowDefinitionOVPs .add(new ObjectValuePair<Long, String>(originalDDMStructureId, StringPool.BLANK)); } } else if (restrictionType == JournalFolderConstants.RESTRICTION_TYPE_WORKFLOW) { String workflowDefinition = ParamUtil.getString(serviceContext, "workflowDefinition" + JournalArticleConstants.DDM_STRUCTURE_ID_ALL); workflowDefinitionOVPs.add(new ObjectValuePair<Long, String>( JournalArticleConstants.DDM_STRUCTURE_ID_ALL, workflowDefinition)); for (long originalDDMStructureId : originalDDMStructureIds) { workflowDefinitionOVPs .add(new ObjectValuePair<Long, String>(originalDDMStructureId, StringPool.BLANK)); } } workflowDefinitionLinkLocalService.updateWorkflowDefinitionLinks(userId, serviceContext.getCompanyId(), groupId, JournalFolder.class.getName(), folderId, workflowDefinitionOVPs); return folder; }
From source file:com.liferay.message.boards.internal.exportimport.data.handler.MBMessageStagedModelDataHandler.java
License:Open Source License
protected List<ObjectValuePair<String, InputStream>> getAttachments(PortletDataContext portletDataContext, Element messageElement, MBMessage message) { boolean hasAttachmentsFileEntries = GetterUtil .getBoolean(messageElement.attributeValue("hasAttachmentsFileEntries")); if (!hasAttachmentsFileEntries) { return Collections.emptyList(); }/*from w w w . jav a 2s.c om*/ List<ObjectValuePair<String, InputStream>> inputStreamOVPs = new ArrayList<>(); List<Element> attachmentElements = portletDataContext.getReferenceDataElements(messageElement, DLFileEntry.class, PortletDataContext.REFERENCE_TYPE_WEAK); for (Element attachmentElement : attachmentElements) { String path = attachmentElement.attributeValue("path"); FileEntry fileEntry = (FileEntry) portletDataContext.getZipEntryAsObject(path); InputStream inputStream = null; String binPath = attachmentElement.attributeValue("bin-path"); if (Validator.isNull(binPath) && portletDataContext.isPerformDirectBinaryImport()) { try { inputStream = FileEntryUtil.getContentStream(fileEntry); } catch (Exception e) { } } else { inputStream = portletDataContext.getZipEntryAsInputStream(binPath); } if (inputStream == null) { if (_log.isWarnEnabled()) { _log.warn("Unable to import attachment for file entry " + fileEntry.getFileEntryId()); } continue; } ObjectValuePair<String, InputStream> inputStreamOVP = new ObjectValuePair<>(fileEntry.getTitle(), inputStream); inputStreamOVPs.add(inputStreamOVP); } if (inputStreamOVPs.isEmpty()) { _log.error("Could not find attachments for message " + message.getMessageId()); } return inputStreamOVPs; }
From source file:com.liferay.message.boards.internal.util.MBMailMessage.java
License:Open Source License
public void addBytes(String fileName, byte[] bytes) { try {//from w ww .ja v a 2 s . co m fileName = MimeUtility.decodeText(fileName); } catch (UnsupportedEncodingException uee) { if (_log.isWarnEnabled()) { _log.warn("Unable to decode file name " + fileName, uee); } } _bytesOVPs.add(new ObjectValuePair<String, byte[]>(fileName, bytes)); }
From source file:com.liferay.message.boards.internal.util.MBMailMessage.java
License:Open Source License
public List<ObjectValuePair<String, InputStream>> getInputStreamOVPs() { List<ObjectValuePair<String, InputStream>> inputStreamOVPs = new ArrayList<>(_bytesOVPs.size()); for (ObjectValuePair<String, byte[]> bytesOVP : _bytesOVPs) { String key = bytesOVP.getKey(); byte[] bytes = bytesOVP.getValue(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); ObjectValuePair<String, InputStream> inputStreamOVP = new ObjectValuePair<>(key, byteArrayInputStream); inputStreamOVPs.add(inputStreamOVP); }// www . j a v a2 s . c om return inputStreamOVPs; }
From source file:com.liferay.message.boards.test.util.MBTestUtil.java
License:Open Source License
public static List<ObjectValuePair<String, InputStream>> getInputStreamOVPs(String fileName, Class<?> clazz, String keywords) {/*from ww w .j a v a 2 s. c o m*/ List<ObjectValuePair<String, InputStream>> inputStreamOVPs = new ArrayList<>(1); InputStream inputStream = clazz.getResourceAsStream("dependencies/" + fileName); ObjectValuePair<String, InputStream> inputStreamOVP = null; if (Validator.isBlank(keywords)) { inputStreamOVP = new ObjectValuePair<>(fileName, inputStream); } else { inputStreamOVP = new ObjectValuePair<>(keywords, inputStream); } inputStreamOVPs.add(inputStreamOVP); return inputStreamOVPs; }
From source file:com.liferay.message.boards.web.internal.portlet.action.EditMessageMVCActionCommand.java
License:Open Source License
protected MBMessage updateMessage(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); long messageId = ParamUtil.getLong(actionRequest, "messageId"); long groupId = themeDisplay.getScopeGroupId(); long categoryId = ParamUtil.getLong(actionRequest, "mbCategoryId"); long threadId = ParamUtil.getLong(actionRequest, "threadId"); long parentMessageId = ParamUtil.getLong(actionRequest, "parentMessageId"); String subject = ParamUtil.getString(actionRequest, "subject"); String body = ParamUtil.getString(actionRequest, "body"); MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings.getInstance(groupId); List<ObjectValuePair<String, InputStream>> inputStreamOVPs = new ArrayList<>(5); try {/*from w w w. j a v a 2s .c o m*/ UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); for (int i = 1; i <= 5; i++) { String fileName = uploadPortletRequest.getFileName("msgFile" + i); InputStream inputStream = uploadPortletRequest.getFileAsStream("msgFile" + i); if ((inputStream == null) || Validator.isNull(fileName)) { continue; } ObjectValuePair<String, InputStream> inputStreamOVP = new ObjectValuePair<>(fileName, inputStream); inputStreamOVPs.add(inputStreamOVP); } boolean question = ParamUtil.getBoolean(actionRequest, "question"); boolean anonymous = ParamUtil.getBoolean(actionRequest, "anonymous"); double priority = ParamUtil.getDouble(actionRequest, "priority"); boolean allowPingbacks = ParamUtil.getBoolean(actionRequest, "allowPingbacks"); ServiceContext serviceContext = ServiceContextFactory.getInstance(MBMessage.class.getName(), actionRequest); boolean preview = ParamUtil.getBoolean(actionRequest, "preview"); serviceContext.setAttribute("preview", preview); MBMessage message = null; if (messageId <= 0) { if (PropsValues.CAPTCHA_CHECK_PORTLET_MESSAGE_BOARDS_EDIT_MESSAGE) { CaptchaUtil.check(actionRequest); } if (threadId <= 0) { // Post new thread message = _mbMessageService.addMessage(groupId, categoryId, subject, body, mbGroupServiceSettings.getMessageFormat(), inputStreamOVPs, anonymous, priority, allowPingbacks, serviceContext); if (question) { _mbThreadLocalService.updateQuestion(message.getThreadId(), true); } } else { // Post reply message = _mbMessageService.addMessage(parentMessageId, subject, body, mbGroupServiceSettings.getMessageFormat(), inputStreamOVPs, anonymous, priority, allowPingbacks, serviceContext); } } else { List<String> existingFiles = new ArrayList<>(); for (int i = 1; i <= 5; i++) { String path = ParamUtil.getString(actionRequest, "existingPath" + i); if (Validator.isNotNull(path)) { existingFiles.add(path); } } // Update message message = _mbMessageService.updateMessage(messageId, subject, body, inputStreamOVPs, existingFiles, priority, allowPingbacks, serviceContext); if (message.isRoot()) { _mbThreadLocalService.updateQuestion(message.getThreadId(), question); } } PermissionChecker permissionChecker = themeDisplay.getPermissionChecker(); boolean subscribe = ParamUtil.getBoolean(actionRequest, "subscribe"); if (!preview && subscribe && MBMessagePermission.contains(permissionChecker, message, ActionKeys.SUBSCRIBE)) { _mbMessageService.subscribeMessage(message.getMessageId()); } return message; } finally { for (ObjectValuePair<String, InputStream> inputStreamOVP : inputStreamOVPs) { InputStream inputStream = inputStreamOVP.getValue(); StreamUtil.cleanUp(inputStream); } } }
From source file:com.liferay.notifications.hook.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
protected List<ObjectValuePair<String, Long>> getSubscribersOVPs(BlogsEntry blogsEntry) throws SystemException { List<ObjectValuePair<String, Long>> subscribersOVPs = new ArrayList<ObjectValuePair<String, Long>>(); subscribersOVPs.add(new ObjectValuePair<String, Long>(_BLOGS_ENTRY_CLASS_NAME, blogsEntry.getGroupId())); return subscribersOVPs; }