List of usage examples for com.liferay.portal.kernel.service ServiceContext setScopeGroupId
public void setScopeGroupId(long scopeGroupId)
From source file:ch.inofix.referencemanager.service.impl.ReferenceLocalServiceImpl.java
License:Open Source License
public void match(Reference reference) throws PortalException { _log.info("match"); long defaultGroupId = GetterUtil.getLong(PropsUtil.get("default.group.id")); Hits hits = search(reference.getUserId(), defaultGroupId, -1, null, reference.getTitle(), null, WorkflowConstants.STATUS_ANY, null, false, 0, 20, null); _log.info("hits.getLength() = " + hits.getLength()); if (hits.getLength() == 0) { // not yet in the pool of common references _log.info("not yet in the global references "); // TODO: strip the private fields from the reference String bibTeX = reference.getBibTeX(); ServiceContext serviceContext = new ServiceContext(); serviceContext.setScopeGroupId(defaultGroupId); Reference globalReference = addReference(reference.getUserId(), bibTeX, serviceContext); refRefRelationLocalService.addRefRefRelation(reference.getUserId(), globalReference.getReferenceId(), reference.getReferenceId(), new ServiceContext()); }/* w w w . j a v a2s . c o m*/ }
From source file:com.bemis.portal.fileuploader.service.impl.FileUploaderLocalServiceImpl.java
License:Open Source License
/** * Uploads the file into the destination folder * If the file does not exist, adds the file. If exists, updates the existing file * Adds tags and categories to documents * * @param companyId/*from ww w. ja v a2 s .c o m*/ * @param groupId * @param userId * @param file * @param fileDescription * @param title * @param folderId * @param changeLog * @param assetTagNames * @return FileEntry * @throws PortalException */ public FileEntry uploadFile(long companyId, long groupId, long userId, File file, String fileDescription, String title, long folderId, String changeLog, String[] assetTagNames) throws PortalException { ServiceContext serviceContext = new ServiceContext(); serviceContext.setCompanyId(companyId); serviceContext.setScopeGroupId(groupId); serviceContext.setUserId(userId); serviceContext.setAssetTagNames(assetTagNames); serviceContext.setAttribute(FileUploaderConstants.DESTINATION_FOLDER_ID, folderId); return uploadFile(file, fileDescription, title, changeLog, serviceContext); }
From source file:com.liferay.asset.categories.admin.web.internal.exportimport.data.handler.AssetCategoryStagedModelDataHandler.java
License:Open Source License
protected ServiceContext createServiceContext(PortletDataContext portletDataContext, AssetCategory category) { ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setCreateDate(category.getCreateDate()); serviceContext.setModifiedDate(category.getModifiedDate()); serviceContext.setScopeGroupId(portletDataContext.getScopeGroupId()); return serviceContext; }
From source file:com.liferay.asset.categories.admin.web.internal.exportimport.data.handler.AssetVocabularyStagedModelDataHandler.java
License:Open Source License
protected ServiceContext createServiceContext(PortletDataContext portletDataContext, AssetVocabulary vocabulary) {//from w ww. j a v a 2 s .c o m ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setCreateDate(vocabulary.getCreateDate()); serviceContext.setModifiedDate(vocabulary.getModifiedDate()); serviceContext.setScopeGroupId(portletDataContext.getScopeGroupId()); return serviceContext; }
From source file:com.liferay.asset.tags.internal.exportimport.data.handler.AssetTagStagedModelDataHandler.java
License:Open Source License
protected ServiceContext createServiceContext(PortletDataContext portletDataContext, AssetTag assetTag) { ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setCreateDate(assetTag.getCreateDate()); serviceContext.setModifiedDate(assetTag.getModifiedDate()); serviceContext.setScopeGroupId(portletDataContext.getScopeGroupId()); return serviceContext; }
From source file:com.liferay.asset.test.util.BaseAssetSearchTestCase.java
License:Open Source License
protected List<BaseModel<?>> addBaseModels(Group[] groups, String keywords, ServiceContext serviceContext) throws Exception { List<BaseModel<?>> baseModels = new ArrayList<>(); for (Group group : groups) { User user = UserTestUtil.getAdminUser(group.getCompanyId()); serviceContext.setCompanyId(group.getCompanyId()); serviceContext.setScopeGroupId(group.getGroupId()); serviceContext.setUserId(user.getUserId()); BaseModel<?> parentBaseModel = getParentBaseModel(group, serviceContext); baseModels.add(addBaseModel(parentBaseModel, keywords, serviceContext)); }/*from w w w .j a v a 2 s .c o m*/ return baseModels; }
From source file:com.liferay.blogs.demo.data.creator.internal.BaseBlogsEntryDemoDataCreator.java
License:Open Source License
public BlogsEntry createBlogsEntry(long userId, long groupId, String title, String subtitle, String content) throws IOException, PortalException { ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setScopeGroupId(groupId); ImageSelector imageSelector = new ImageSelector(_getRandomImageBytes(userId, groupId), StringUtil.randomString() + ".jpeg", "image/jpeg", StringPool.BLANK); BlogsEntry blogsEntry = blogsEntryLocalService.addEntry(userId, title, subtitle, null, content, _getRandomDate(), false, false, null, null, imageSelector, null, serviceContext); entryIds.add(blogsEntry.getEntryId()); return blogsEntry; }
From source file:com.liferay.blogs.internal.atom.BlogsEntryAtomCollectionAdapter.java
License:Open Source License
@Override protected BlogsEntry doPostEntry(String title, String summary, String content, Date date, AtomRequestContext atomRequestContext) throws Exception { long groupId = atomRequestContext.getLongParameter("groupId"); Calendar cal = Calendar.getInstance(); cal.setTime(date);//from w w w.j a v a 2 s . co m int displayDateMonth = cal.get(Calendar.MONTH); int displayDateDay = cal.get(Calendar.DAY_OF_MONTH); int displayDateYear = cal.get(Calendar.YEAR); int displayDateHour = cal.get(Calendar.HOUR_OF_DAY); int displayDateMinute = cal.get(Calendar.MINUTE); boolean allowPingbacks = true; boolean allowTrackbacks = true; String[] trackbacks = new String[0]; ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setScopeGroupId(groupId); return _blogsEntryService.addEntry(title, StringPool.BLANK, summary, content, displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, allowPingbacks, allowTrackbacks, trackbacks, StringPool.BLANK, null, null, serviceContext); }
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
@Override public void checkEntries() throws PortalException { Date now = new Date(); int count = blogsEntryPersistence.countByLtD_S(now, WorkflowConstants.STATUS_SCHEDULED); if (count == 0) { return;/*from w w w.ja v a2s. c o m*/ } List<BlogsEntry> entries = blogsEntryPersistence.findByLtD_S(now, WorkflowConstants.STATUS_SCHEDULED); for (BlogsEntry entry : entries) { ServiceContext serviceContext = new ServiceContext(); String[] trackbacks = StringUtil.split(entry.getTrackbacks()); serviceContext.setAttribute("trackbacks", trackbacks); serviceContext.setCommand(Constants.UPDATE); String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.VIEW); if (Validator.isNotNull(portletId)) { String layoutFullURL = PortalUtil.getLayoutFullURL(entry.getGroupId(), portletId); serviceContext.setLayoutFullURL(layoutFullURL); } serviceContext.setScopeGroupId(entry.getGroupId()); blogsEntryLocalService.updateStatus(entry.getStatusByUserId(), entry.getEntryId(), WorkflowConstants.STATUS_APPROVED, serviceContext, new HashMap<String, Serializable>()); } }
From source file:com.liferay.blogs.service.test.BlogsEntryStatusTransitionTest.java
License:Open Source License
protected ServiceContext getServiceContext(BlogsEntry entry) throws Exception { ServiceContext serviceContext = new ServiceContext(); String[] trackbacks = StringUtil.split(entry.getTrackbacks()); serviceContext.setAttribute("trackbacks", trackbacks); serviceContext.setCommand(Constants.UPDATE); String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.VIEW); String layoutFullURL = PortalUtil.getLayoutFullURL(entry.getGroupId(), portletId); serviceContext.setLayoutFullURL(layoutFullURL); serviceContext.setScopeGroupId(entry.getGroupId()); return serviceContext; }