List of usage examples for com.liferay.portal.kernel.atom AtomRequestContext getLongParameter
public long getLongParameter(String name);
From source file:com.liferay.blogs.internal.atom.BlogsEntryAtomCollectionAdapter.java
License:Open Source License
@Override protected Iterable<BlogsEntry> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception { long groupId = atomRequestContext.getLongParameter("groupId"); int status = WorkflowConstants.STATUS_APPROVED; int max = atomRequestContext.getIntParameter("max", SearchContainer.DEFAULT_DELTA); if (groupId > 0) { int page = atomRequestContext.getIntParameter("page"); if (page == 0) { return _blogsEntryService.getGroupEntries(groupId, status, max); }//from w w w .ja v a 2 s .co m int count = _blogsEntryService.getGroupEntriesCount(groupId, new Date(), status); AtomPager atomPager = new AtomPager(page, max, count); AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager); return _blogsEntryService.getGroupEntries(groupId, new Date(), status, atomPager.getStart(), atomPager.getEnd() + 1); } long organizationId = atomRequestContext.getLongParameter("organizationId"); if (organizationId > 0) { return _blogsEntryService.getOrganizationEntries(organizationId, new Date(), status, max); } long companyId = CompanyThreadLocal.getCompanyId(); if (companyId > 0) { return _blogsEntryService.getCompanyEntries(companyId, new Date(), status, max); } return Collections.emptyList(); }
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);/* w w w . jav a 2 s .c om*/ 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.document.library.internal.atom.FileEntryAtomCollectionAdapter.java
License:Open Source License
@Override protected Iterable<FileEntry> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception { long folderId = atomRequestContext.getLongParameter("folderId"); long repositoryId = 0; if (folderId != 0) { Folder folder = _dlAppService.getFolder(folderId); repositoryId = folder.getRepositoryId(); } else {//from www .j a va 2 s . co m repositoryId = atomRequestContext.getLongParameter("repositoryId"); } int count = _dlAppService.getFileEntriesCount(repositoryId, folderId); AtomPager atomPager = new AtomPager(atomRequestContext, count); AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager); return _dlAppService.getFileEntries(repositoryId, folderId, atomPager.getStart(), atomPager.getEnd() + 1, new RepositoryModelTitleComparator<FileEntry>()); }
From source file:com.liferay.document.library.internal.atom.FileEntryAtomCollectionAdapter.java
License:Open Source License
@Override protected FileEntry doPostEntry(String title, String summary, String content, Date date, AtomRequestContext atomRequestContext) throws Exception { long folderId = atomRequestContext.getLongParameter("folderId"); long repositoryId = 0; if (folderId != 0) { Folder folder = _dlAppService.getFolder(folderId); repositoryId = folder.getRepositoryId(); } else {/*from w w w.jav a 2 s. c o m*/ repositoryId = atomRequestContext.getLongParameter("repositoryId"); } String mimeType = atomRequestContext.getHeader("Media-Content-Type"); if (mimeType == null) { mimeType = MimeTypesUtil.getContentType(title); } byte[] contentDecoded = Base64.decode(content); ByteArrayInputStream contentInputStream = new ByteArrayInputStream(contentDecoded); ServiceContext serviceContext = new ServiceContext(); FileEntry fileEntry = _dlAppService.addFileEntry(repositoryId, folderId, title, mimeType, title, summary, null, contentInputStream, contentDecoded.length, serviceContext); return fileEntry; }
From source file:com.liferay.document.library.internal.atom.FileEntryAtomCollectionAdapter.java
License:Open Source License
@Override protected FileEntry doPostMedia(String mimeType, String slug, InputStream inputStream, AtomRequestContext atomRequestContext) throws Exception { long folderId = atomRequestContext.getLongParameter("folderId"); long repositoryId = 0; if (folderId != 0) { Folder folder = _dlAppService.getFolder(folderId); repositoryId = folder.getRepositoryId(); } else {// w w w . j a v a2 s . c o m repositoryId = atomRequestContext.getLongParameter("repositoryId"); } String title = atomRequestContext.getHeader("Title"); String description = atomRequestContext.getHeader("Summary"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); StreamUtil.transfer(inputStream, byteArrayOutputStream); byte[] content = byteArrayOutputStream.toByteArray(); ByteArrayInputStream contentInputStream = new ByteArrayInputStream(content); ServiceContext serviceContext = new ServiceContext(); FileEntry fileEntry = _dlAppService.addFileEntry(repositoryId, folderId, title, mimeType, title, description, null, contentInputStream, content.length, serviceContext); return fileEntry; }
From source file:com.liferay.document.library.internal.atom.FolderAtomCollectionAdapter.java
License:Open Source License
@Override protected Iterable<Folder> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception { long repositoryId = 0L; long parentFolderId = atomRequestContext.getLongParameter("parentFolderId"); if (parentFolderId != 0) { Folder parentFolder = _dlAppService.getFolder(parentFolderId); repositoryId = parentFolder.getRepositoryId(); } else {// ww w. j a va2 s. c o m repositoryId = atomRequestContext.getLongParameter("repositoryId"); } int count = _dlAppService.getFoldersCount(repositoryId, parentFolderId); AtomPager atomPager = new AtomPager(atomRequestContext, count); AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager); return _dlAppService.getFolders(repositoryId, parentFolderId, atomPager.getStart(), atomPager.getEnd() + 1, new FolderNameComparator()); }
From source file:com.liferay.document.library.internal.atom.FolderAtomCollectionAdapter.java
License:Open Source License
@Override protected Folder doPostEntry(String title, String summary, String content, Date date, AtomRequestContext atomRequestContext) throws Exception { long repositoryId = 0L; long parentFolderId = atomRequestContext.getLongParameter("parentFolderId"); if (parentFolderId != 0) { Folder parentFolder = _dlAppService.getFolder(parentFolderId); repositoryId = parentFolder.getRepositoryId(); } else {// w ww . j av a2 s . c om repositoryId = atomRequestContext.getLongParameter("repositoryId"); } ServiceContext serviceContext = new ServiceContext(); Folder folder = _dlAppService.addFolder(repositoryId, parentFolderId, title, summary, serviceContext); return folder; }
From source file:com.liferay.journal.atom.JournalArticleAtomCollectionProvider.java
License:Open Source License
@Override protected void doDeleteEntry(String resourceName, AtomRequestContext atomRequestContext) throws Exception { long groupId = atomRequestContext.getLongParameter("groupId"); String articleId = resourceName; ServiceContext serviceContext = new ServiceContext(); _journalArticleService.deleteArticle(groupId, articleId, null, serviceContext); }
From source file:com.liferay.journal.atom.JournalArticleAtomCollectionProvider.java
License:Open Source License
@Override protected JournalArticle doGetEntry(String resourceName, AtomRequestContext atomRequestContext) throws Exception { long groupId = atomRequestContext.getLongParameter("groupId"); String articleId = resourceName; return _journalArticleService.getArticle(groupId, articleId); }
From source file:com.liferay.journal.atom.JournalArticleAtomCollectionProvider.java
License:Open Source License
@Override protected Iterable<JournalArticle> doGetFeedEntries(AtomRequestContext atomRequestContext) throws Exception { List<JournalArticle> journalArticles = new ArrayList<>(); long companyId = CompanyThreadLocal.getCompanyId(); long groupId = atomRequestContext.getLongParameter("groupId"); if ((companyId <= 0) || (groupId <= 0)) { return journalArticles; }// www. ja v a2s . co m List<Long> folderIds = Collections.emptyList(); long classNameId = 0; String keywords = null; Double version = null; String ddmStructureKey = null; String ddmTemplateKey = null; Date displayDateGT = null; Date displayDateLT = new Date(); int status = WorkflowConstants.STATUS_APPROVED; Date reviewDate = null; OrderByComparator<JournalArticle> obc = new ArticleVersionComparator(); int count = _journalArticleService.searchCount(companyId, groupId, folderIds, classNameId, keywords, version, ddmStructureKey, ddmTemplateKey, displayDateGT, displayDateLT, status, reviewDate); AtomPager atomPager = new AtomPager(atomRequestContext, count); AtomUtil.saveAtomPagerInRequest(atomRequestContext, atomPager); journalArticles = _journalArticleService.search(companyId, groupId, folderIds, classNameId, keywords, version, ddmStructureKey, ddmTemplateKey, displayDateGT, displayDateLT, status, reviewDate, atomPager.getStart(), atomPager.getEnd() + 1, obc); return journalArticles; }