List of usage examples for com.liferay.portal.kernel.repository.model Folder getFolderId
public long getFolderId();
From source file:com.liferay.portlet.imagegallerydisplay.util.IGUtil.java
License:Open Source License
public static void addPortletBreadcrumbEntries(Folder folder, HttpServletRequest request, RenderResponse renderResponse) throws Exception { String strutsAction = ParamUtil.getString(request, "struts_action"); PortletURL portletURL = renderResponse.createRenderURL(); if (strutsAction.equals("/image_gallery_display/select_folder")) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); portletURL.setWindowState(LiferayWindowState.POP_UP); portletURL.setParameter("struts_action", strutsAction); PortalUtil.addPortletBreadcrumbEntry(request, themeDisplay.translate("home"), portletURL.toString()); } else {// ww w.ja v a2 s . c o m portletURL.setParameter("struts_action", "/image_gallery_display/view"); } List<Folder> ancestorFolders = folder.getAncestors(); Collections.reverse(ancestorFolders); for (Folder ancestorFolder : ancestorFolders) { portletURL.setParameter("folderId", String.valueOf(ancestorFolder.getFolderId())); PortalUtil.addPortletBreadcrumbEntry(request, ancestorFolder.getName(), portletURL.toString()); } portletURL.setParameter("folderId", String.valueOf(folder.getFolderId())); if (strutsAction.equals("/journal/select_image_gallery")) { portletURL.setParameter("groupId", String.valueOf(folder.getGroupId())); } PortalUtil.addPortletBreadcrumbEntry(request, folder.getName(), portletURL.toString()); }
From source file:com.liferay.portlet.wiki.model.impl.WikiNodeImpl.java
License:Open Source License
@Override public Folder addAttachmentsFolder() throws PortalException, SystemException { if (_attachmentsFolderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return PortletFileRepositoryUtil.getPortletFolder(_attachmentsFolderId); }// w ww . ja v a 2 s . co m ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); Repository repository = PortletFileRepositoryUtil.addPortletRepository(getGroupId(), PortletKeys.WIKI, serviceContext); Folder folder = PortletFileRepositoryUtil.addPortletFolder(getUserId(), repository.getRepositoryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(getNodeId()), serviceContext); _attachmentsFolderId = folder.getFolderId(); return folder; }
From source file:com.liferay.portlet.wiki.model.impl.WikiNodeImpl.java
License:Open Source License
@Override public long getAttachmentsFolderId() throws SystemException { if (_attachmentsFolderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) { return _attachmentsFolderId; }/*from w w w. j ava 2 s. c o m*/ ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); Repository repository = PortletFileRepositoryUtil.fetchPortletRepository(getGroupId(), PortletKeys.WIKI); if (repository == null) { return DLFolderConstants.DEFAULT_PARENT_FOLDER_ID; } try { Folder folder = PortletFileRepositoryUtil.getPortletFolder(getUserId(), repository.getRepositoryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, String.valueOf(getNodeId()), serviceContext); _attachmentsFolderId = folder.getFolderId(); } catch (Exception e) { } return _attachmentsFolderId; }
From source file:com.liferay.repository.external.model.ExtRepositoryObjectAdapter.java
License:Open Source License
public List<Long> getAncestorFolderIds() throws PortalException { List<Long> folderIds = new ArrayList<Long>(); Folder folder = getParentFolder(); while (!folder.isRoot()) { folderIds.add(folder.getFolderId()); folder = folder.getParentFolder(); }//from w w w . j a v a 2 s.co m return folderIds; }
From source file:com.liferay.sevencogs.hook.upgrade.v1_0_0.UpgradeCompany.java
License:Open Source License
protected Organization setupOrganizations(long companyId, long defaultUserId) throws Exception { // 7Cogs, Inc. organization long userId = defaultUserId; long parentOrganizationId = OrganizationConstants.DEFAULT_PARENT_ORGANIZATION_ID; String name = "7Cogs, Inc."; String type = OrganizationConstants.TYPE_REGULAR_ORGANIZATION; boolean recursable = true; long regionId = 0; long countryId = 0; int statusId = GetterUtil .getInteger(PropsUtil.get("sql.data.com.liferay.portal.model.ListType.organization.status")); String comments = null;//from ww w .ja v a 2s. com ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); Organization organization = OrganizationLocalServiceUtil.addOrganization(userId, parentOrganizationId, name, type, recursable, regionId, countryId, statusId, comments, true, serviceContext); // Group Group group = organization.getGroup(); GroupLocalServiceUtil.updateFriendlyURL(group.getGroupId(), "/7cogs"); serviceContext.setScopeGroupId(group.getGroupId()); // Layout set LayoutSetLocalServiceUtil.updateLogo(group.getGroupId(), false, true, getInputStream("/sample/images/logo.png")); LayoutSetLocalServiceUtil.updateLookAndFeel(group.getGroupId(), false, "sevencogs_WAR_sevencogstheme", "01", "", false); // Asset AssetVocabulary topicAssetVocabulary = addAssetVocabulary(defaultUserId, "Topic", serviceContext); AssetVocabulary imageAssetVocabulary = addAssetVocabulary(defaultUserId, "Image Type", serviceContext); AssetCategory iconAssetCategory = addAssetCategory(defaultUserId, 0, "Icon", imageAssetVocabulary.getVocabularyId(), serviceContext); AssetCategory bannerAssetCategory = addAssetCategory(defaultUserId, 0, "Banner", imageAssetVocabulary.getVocabularyId(), serviceContext); AssetCategory learningAssetCategory = addAssetCategory(defaultUserId, 0, "Learning", topicAssetVocabulary.getVocabularyId(), serviceContext); AssetCategory productsAssetCategory = addAssetCategory(defaultUserId, 0, "Products", topicAssetVocabulary.getVocabularyId(), serviceContext); AssetCategory liferayAssetCategory = addAssetCategory(defaultUserId, 0, "Liferay", topicAssetVocabulary.getVocabularyId(), serviceContext); _assetCategories = new HashMap<String, AssetCategory>(); _assetCategories.put("Icon", iconAssetCategory); _assetCategories.put("Banner", bannerAssetCategory); _assetCategories.put("Learning", learningAssetCategory); _assetCategories.put("Products", productsAssetCategory); _assetCategories.put("Liferay", liferayAssetCategory); // Journal addJournalStructure(defaultUserId, group.getGroupId(), "/sample/journal/structures/single_image.xml"); addJournalTemplate(defaultUserId, group.getGroupId(), "/sample/journal/templates/single_image.xml"); // Image gallery serviceContext.setScopeGroupId(group.getGroupId()); Folder folder = DLAppLocalServiceUtil.addFolder(defaultUserId, group.getGroupId(), 0, "7Cogs Web Content", "Images used for content", serviceContext); serviceContext.setAssetTagNames(new String[] { "icons" }); serviceContext.setAssetCategoryIds(new long[] { iconAssetCategory.getCategoryId() }); FileEntry cogBlueIconFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/sample/images/cog_blue.png", serviceContext); FileEntry cogLightBlueIconFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/sample/images/cog_light_blue.png", serviceContext); FileEntry cogOrangeIconFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/sample/images/cog_orange.png", serviceContext); serviceContext.setAssetTagNames(new String[] { "home page", "blogs" }); serviceContext.setAssetCategoryIds(new long[] { iconAssetCategory.getCategoryId() }); FileEntry blogsIconFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/sample/images/blogs_icon.png", serviceContext); serviceContext.setAssetTagNames(new String[] { "home page" }); serviceContext.setAssetCategoryIds(new long[] { productsAssetCategory.getCategoryId() }); FileEntry cogNetworkAdFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/sample/images/cog_network_advertisement.png", serviceContext); serviceContext.setAssetTagNames(new String[] { "home page", "forums" }); serviceContext.setAssetCategoryIds(new long[] { iconAssetCategory.getCategoryId() }); FileEntry forumsIconFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/sample/images/forums_icon.png", serviceContext); serviceContext.setAssetTagNames(new String[] { "liferay", "logo" }); serviceContext.setAssetCategoryIds(new long[] { liferayAssetCategory.getCategoryId() }); FileEntry liferayLogoFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/sample/images/liferay_logo.png", serviceContext); serviceContext.setAssetTagNames(new String[] { "home page" }); serviceContext.setAssetCategoryIds(new long[] { bannerAssetCategory.getCategoryId() }); FileEntry homePageBannerFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/sample/images/home_page_banner.png", serviceContext); serviceContext.setAssetTagNames(new String[] { "home page", "products" }); serviceContext.setAssetCategoryIds(new long[] { iconAssetCategory.getCategoryId() }); FileEntry productsIconFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/sample/images/products_icon.png", serviceContext); serviceContext.setAssetTagNames(new String[] { "products" }); serviceContext.setAssetCategoryIds(new long[] { productsAssetCategory.getCategoryId() }); FileEntry productLandingFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/sample/images/product_landing.png", serviceContext); // Home layout Layout layout = addLayout(group, "Home", false, "/home", "home"); // Home Page Banner content portlet String portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-1"); removePortletBorder(layout, portletId); serviceContext.setAssetTagNames(new String[] { "liferay", "7cogs" }); JournalArticle journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Banner", "/sample/journal/articles/home_page_banner.xml", serviceContext); String content = StringUtil.replace(journalArticle.getContent(), new String[] { "[$GROUP_ID$]", "[$HOME_PAGE_BANNER_R_FE_UUID$]" }, new String[] { String.valueOf(group.getGroupId()), String.valueOf(homePageBannerFileEntry.getUuid()) }); JournalArticleLocalServiceUtil.updateContent(group.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion(), content); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Home Page Products Button content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-2"); removePortletBorder(layout, portletId); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Products Button", "/sample/journal/articles/home_page_products_button.xml", serviceContext); content = StringUtil.replace(journalArticle.getContent(), new String[] { "[$GROUP_ID$]", "[$HOME_PAGE_PRODUCTS_R_FE_UUID$]" }, new String[] { String.valueOf(group.getGroupId()), String.valueOf(productsIconFileEntry.getUuid()) }); JournalArticleLocalServiceUtil.updateContent(group.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion(), content); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Home Page Blogs Button content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-3"); removePortletBorder(layout, portletId); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Blogs Button", "/sample/journal/articles/home_page_blogs_button.xml", serviceContext); content = StringUtil.replace(journalArticle.getContent(), new String[] { "[$GROUP_ID$]", "[$HOME_PAGE_BLOGS_R_FE_UUID$]" }, new String[] { String.valueOf(group.getGroupId()), String.valueOf(blogsIconFileEntry.getUuid()) }); JournalArticleLocalServiceUtil.updateContent(group.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion(), content); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Home Page Forums Button content porltet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-4"); removePortletBorder(layout, portletId); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Forums Button", "/sample/journal/articles/home_page_forums_button.xml", serviceContext); content = StringUtil.replace(journalArticle.getContent(), new String[] { "[$GROUP_ID$]", "[$HOME_PAGE_FORUMS_R_FE_UUID$]" }, new String[] { String.valueOf(group.getGroupId()), String.valueOf(forumsIconFileEntry.getUuid()) }); JournalArticleLocalServiceUtil.updateContent(group.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion(), content); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Home Page Intro content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-5"); removePortletBorder(layout, portletId); serviceContext.setAssetTagNames(new String[] { "front" }); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Home Page Intro", "/sample/journal/articles/home_page_intro.xml", serviceContext); content = StringUtil.replace(journalArticle.getContent(), new String[] { "[$GROUP_ID$]", "[$PRODUCT_LANDING_R_FE_UUID$]" }, new String[] { String.valueOf(group.getGroupId()), String.valueOf(productLandingFileEntry.getUuid()) }); JournalArticleLocalServiceUtil.updateContent(group.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion(), content); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Cog Network Ad content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-6"); removePortletBorder(layout, portletId); serviceContext.setAssetTagNames(new String[] { "liferay", "enterprise" }); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Cog Network Ad", "/sample/journal/articles/home_cog_network_ad.xml", serviceContext); content = StringUtil.replace(journalArticle.getContent(), new String[] { "[$GROUP_ID$]", "[$COG_NETWORK_AD_R_FE_UUID$]" }, new String[] { String.valueOf(group.getGroupId()), String.valueOf(cogNetworkAdFileEntry.getUuid()) }); JournalArticleLocalServiceUtil.updateContent(group.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion(), content); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Products layout layout = addLayout(group, "Products", false, "/products", "1_2_columns_ii"); // Products Banner content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-1"); removePortletBorder(layout, portletId); serviceContext.setAssetTagNames(new String[] { "Vix-998", "7cogs" }); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Products Banner", "/sample/journal/articles/products_banner.xml", serviceContext); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Products Landing Intro content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-2"); removePortletBorder(layout, portletId); serviceContext.setAssetTagNames(new String[] { "products" }); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Products Landing Intro", "/sample/journal/articles/products_landing_intro.xml", serviceContext); content = StringUtil.replace(journalArticle.getContent(), new String[] { "[$GROUP_ID$]", "[$PRODUCT_LANDING_R_FE_UUID$]" }, new String[] { String.valueOf(group.getGroupId()), String.valueOf(productLandingFileEntry.getUuid()) }); JournalArticleLocalServiceUtil.updateContent(group.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion(), content); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Products Landing Intro Info content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-2"); removePortletBorder(layout, portletId); serviceContext.setAssetTagNames(new String[] { "products" }); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Products Landing Intro Info", "/sample/journal/articles/products_landing_intro_info.xml", serviceContext); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Introducing Vix content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-3"); removePortletBorder(layout, portletId); serviceContext.setAssetTagNames(new String[] { "Vix-998", "7cogs" }); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Products Catalog", "/sample/journal/articles/products_catalog.xml", serviceContext); content = StringUtil.replace(journalArticle.getContent(), new String[] { "[$COG_BLUE_R_FE_UUID$]", "[$COG_LIGHT_BLUE_R_FE_UUID$]", "[$COG_ORANGE_R_FE_UUID$]", "[$GROUP_ID$]" }, new String[] { String.valueOf(cogBlueIconFileEntry.getUuid()), String.valueOf(cogLightBlueIconFileEntry.getUuid()), String.valueOf(cogOrangeIconFileEntry.getUuid()), String.valueOf(group.getGroupId()) }); JournalArticleLocalServiceUtil.updateContent(group.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion(), content); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Blogs layout layout = addLayout(group, "Blogs", false, "/blogs", "1_2_columns_i"); // Blogs Banner content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-1"); removePortletBorder(layout, portletId); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Blogs Banner", "/sample/journal/articles/blogs_banner.xml", serviceContext); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Recent Bloggers portlet addPortletId(layout, PortletKeys.RECENT_BLOGGERS, "column-2"); // Blogs Aggregator portlet portletId = addPortletId(layout, PortletKeys.BLOGS_AGGREGATOR, "column-3"); configurePortletTitle(layout, portletId, "Blogs"); // Wiki layout layout = addLayout(group, "Wiki", false, "/wiki", "1_column"); // Wiki Banner content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-1"); removePortletBorder(layout, portletId); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Wiki Banner", "/sample/journal/articles/wiki_banner.xml", serviceContext); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Wiki portlet portletId = addPortletId(layout, PortletKeys.WIKI, "column-1"); removePortletBorder(layout, portletId); WikiNode wikiNode = WikiNodeLocalServiceUtil.addNode(defaultUserId, "Main", StringPool.BLANK, serviceContext); serviceContext.setAssetTagNames(new String[] { "new", "features" }); serviceContext.setAssetCategoryIds(new long[] { learningAssetCategory.getCategoryId() }); addWikiPage(defaultUserId, wikiNode.getNodeId(), "FrontPage", "/sample/wiki/FrontPage.xml", serviceContext); serviceContext.setAssetTagNames(new String[] { "vix-998", "features" }); serviceContext.setAssetCategoryIds(new long[] { productsAssetCategory.getCategoryId() }); addWikiPage(defaultUserId, wikiNode.getNodeId(), "Vix-998", "/sample/wiki/Vix-998.xml", serviceContext); // Forums layout layout = addLayout(group, "Forums", false, "/forums", "1_column"); // Forums Banner content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-1"); removePortletBorder(layout, portletId); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Forums Banner", "/sample/journal/articles/forums_banner.xml", serviceContext); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Message Boards portlet portletId = addPortletId(layout, PortletKeys.MESSAGE_BOARDS, "column-1"); removePortletBorder(layout, portletId); // Dashboard layout layout = addLayout(group, "Dashboard", false, "/dashboard", "2_columns_ii"); portletId = addPortletId(layout, PortletKeys.USER_STATISTICS, "column-1"); configureUserStatistics(layout, portletId, new String[] { "user.message-posts", "user.blogs", "user.wikis" }); // Group Statistics portlet portletId = addPortletId(layout, PortletKeys.GROUP_STATISTICS, "column-2"); String[][] chartData = new String[3][4]; chartData[0] = new String[] { "user.message-posts", "area", "12months", "40" }; chartData[1] = new String[] { "asset.activities", "pie", "12months", "50" }; chartData[2] = new String[] { "asset.activities", "tag-cloud", "12months", "40" }; configureGroupStatistics(layout, portletId, chartData); // Activities portlet portletId = addPortletId(layout, PortletKeys.ACTIVITIES, "column-2"); // About Us layout layout = addLayout(group, "About Us", false, "/about_us", "1_2_columns_ii"); // About Us Banner content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-1"); removePortletBorder(layout, portletId); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "About Us Banner", "/sample/journal/articles/about_us_banner.xml", serviceContext); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // About Us content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-2"); highlightPortlet(layout, portletId); serviceContext.setAssetTagNames(new String[] { "liferay" }); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "About Us", "/sample/journal/articles/home_7cogs_about_us.xml", serviceContext); content = StringUtil.replace(journalArticle.getContent(), new String[] { "[$GROUP_ID$]", "[$LIFERAY_LOGO_R_FE_UUID$]" }, new String[] { String.valueOf(group.getGroupId()), String.valueOf(liferayLogoFileEntry.getUuid()) }); JournalArticleLocalServiceUtil.updateContent(group.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion(), content); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Google Maps portletId = addPortletId(layout, "1_WAR_googlemapsportlet", "column-2"); Map<String, String> preferences = new HashMap<String, String>(); preferences.put("mapAddress", "Los Angeles, USA"); preferences.put("height", "300"); updatePortletSetup(layout, portletId, preferences); // Web Form addPortletId(layout, "1_WAR_webformportlet", "column-3"); // Home layout layout = addLayout(group, "Home", true, "/home", "2_columns_ii"); portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-1"); highlightPortlet(layout, portletId); serviceContext.setAssetTagNames(new String[] { "7cogs", "tips" }); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Home", "/sample/journal/articles/home_7cogs_private_pages.xml", serviceContext); configureJournalContent(layout, portletId, journalArticle.getArticleId()); portletId = addPortletId(layout, PortletKeys.ACTIVITIES, "column-2"); configurePortletTitle(layout, portletId, "Last Activities in 7Cogs Organization"); // Documents layout layout = addLayout(group, "Documents", true, "/documents", "2_columns_iii"); addPortletId(layout, PortletKeys.DOCUMENT_LIBRARY, "column-1"); addPortletId(layout, PortletKeys.MEDIA_GALLERY_DISPLAY, "column-1"); portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-2"); highlightPortlet(layout, portletId); serviceContext.setAssetTagNames(new String[] { "documents", "sharing" }); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Shared Documents", "/sample/journal/articles/documents_shared_docs.xml", serviceContext); configureJournalContent(layout, portletId, journalArticle.getArticleId()); return organization; }
From source file:com.liferay.sevencogs.hook.upgrade.v1_0_0.UpgradeCompany.java
License:Open Source License
protected void setupSites(long companyId, long defaultUserId) throws Exception { // Guest site Group group = GroupLocalServiceUtil.getGroup(companyId, GroupConstants.GUEST); // Journal/*from ww w .j a va2 s.c om*/ addJournalStructure(defaultUserId, group.getGroupId(), "/guest/journal/structures/single_image.xml"); addJournalTemplate(defaultUserId, group.getGroupId(), "/guest/journal/templates/single_image.xml"); // Image gallery ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(true); serviceContext.setAddGuestPermissions(true); serviceContext.setScopeGroupId(group.getGroupId()); Folder folder = DLAppLocalServiceUtil.addFolder(defaultUserId, group.getGroupId(), 0, "Web Content", "Images used for content", serviceContext); FileEntry cellBgFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/cell_bg.png", serviceContext); FileEntry customer1FileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/customer_1.png", serviceContext); FileEntry customer2FileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/customer_2.png", serviceContext); FileEntry customer3FileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/customer_3.png", serviceContext); FileEntry customer4FileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/customer_4.png", serviceContext); FileEntry customer5FileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/customer_5.png", serviceContext); FileEntry customer6FileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/customer_6.png", serviceContext); FileEntry customer7FileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/customer_7.png", serviceContext); FileEntry portalMashupFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/portal_mashup.png", serviceContext); FileEntry sevenCogsAdFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/sevencogs_ad.png", serviceContext); FileEntry sharedWorkspacesFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/shared_workspaces.png", serviceContext); FileEntry socialNetworkingFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/social_network.png", serviceContext); FileEntry webPublishingFileEntry = addDLFileEntry(defaultUserId, folder.getFolderId(), "/guest/images/web_publishing.png", serviceContext); // Site theme settings String noPortletBorders = "lfr-theme:regular:portlet-setup-show-borders-default=false"; LayoutSetLocalServiceUtil.updateSettings(group.getGroupId(), false, noPortletBorders); // Welcome layout Layout layout = addLayout(group, "Welcome", false, "/home", "2_columns_iii"); // Welcome content portlet String portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-1"); removePortletBorder(layout, portletId); serviceContext.setAssetTagNames(new String[] { "liferay", "welcome" }); JournalArticle journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Welcome", "/guest/journal/articles/welcome.xml", serviceContext); String content = StringUtil.replace(journalArticle.getContent(), new String[] { "[$CELL_BG_R_FE_UUID$]", "[$CUSTOMER_1_R_FE_UUID$]", "[$CUSTOMER_2_R_FE_UUID$]", "[$CUSTOMER_3_R_FE_UUID$]", "[$CUSTOMER_4_R_FE_UUID$]", "[$CUSTOMER_5_R_FE_UUID$]", "[$CUSTOMER_6_R_FE_UUID$]", "[$CUSTOMER_7_R_FE_UUID$]", "[$GROUP_ID$]", "[$PORTAL_MASHUPS_R_FE_UUID$]", "[$SHARED_WORKSPACES_R_FE_UUID$]", "[$SOCIAL_NETWORKING_R_FE_UUID$]", "[$WEB_PUBLISHING_R_FE_UUID$]" }, new String[] { String.valueOf(cellBgFileEntry.getUuid()), String.valueOf(customer1FileEntry.getUuid()), String.valueOf(customer2FileEntry.getUuid()), String.valueOf(customer3FileEntry.getUuid()), String.valueOf(customer4FileEntry.getUuid()), String.valueOf(customer5FileEntry.getUuid()), String.valueOf(customer6FileEntry.getUuid()), String.valueOf(customer7FileEntry.getUuid()), String.valueOf(group.getGroupId()), String.valueOf(portalMashupFileEntry.getUuid()), String.valueOf(sharedWorkspacesFileEntry.getUuid()), String.valueOf(socialNetworkingFileEntry.getUuid()), String.valueOf(webPublishingFileEntry.getUuid()) }); JournalArticleLocalServiceUtil.updateContent(group.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion(), content); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // 7Cogs Ad content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-2"); removePortletBorder(layout, portletId); serviceContext.setAssetTagNames(new String[] { "liferay", "7cogs" }); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "7Cogs Ad", "/guest/journal/articles/sample_site_ad.xml", serviceContext); content = StringUtil.replace(journalArticle.getContent(), new String[] { "[$GROUP_ID$]", "[$GROUP_URL$]", "[$R_FE_UUID$]" }, new String[] { String.valueOf(group.getGroupId()), "/web/7cogs/home", String.valueOf(sevenCogsAdFileEntry.getUuid()) }); JournalArticleLocalServiceUtil.updateContent(group.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion(), content); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Welcome Note content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-2"); removePortletBorder(layout, portletId); serviceContext.setAssetTagNames(new String[] { "welcome" }); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Welcome Note", "/guest/journal/articles/welcome_note.xml", serviceContext); configureJournalContent(layout, portletId, journalArticle.getArticleId()); // Welcome Login content portlet portletId = addPortletId(layout, PortletKeys.JOURNAL_CONTENT, "column-2"); serviceContext.setAssetTagNames(new String[] { "login", "users", "welcome" }); journalArticle = addJournalArticle(defaultUserId, group.getGroupId(), "Welcome Login", "/guest/journal/articles/welcome_login.xml", serviceContext); content = StringUtil.replace(journalArticle.getContent(), "[$COMPANY_ID$]", String.valueOf(companyId)); JournalArticleLocalServiceUtil.updateContent(group.getGroupId(), journalArticle.getArticleId(), journalArticle.getVersion(), content); configureJournalContent(layout, portletId, journalArticle.getArticleId()); configurePortletTitle(layout, portletId, "Current Users"); // Login portlet addPortletId(layout, PortletKeys.LOGIN, "column-2"); }
From source file:com.liferay.sevencogs.hook.upgrade.v1_0_0.UpgradeCompany.java
License:Open Source License
protected List<User> setupUsers(long companyId) throws Exception { // Roles//from w w w.ja va2 s.c o m Role adminRole = RoleLocalServiceUtil.getRole(companyId, RoleConstants.ADMINISTRATOR); Role portalContentReviewer = RoleLocalServiceUtil.getRole(companyId, "Portal Content Reviewer"); Role powerUserRole = RoleLocalServiceUtil.getRole(companyId, RoleConstants.POWER_USER); Role publisherRole = RoleLocalServiceUtil.getRole(companyId, "Publisher"); Role writerRole = RoleLocalServiceUtil.getRole(companyId, "Writer"); // Users long[] roleIds = { adminRole.getRoleId(), powerUserRole.getRoleId() }; User brunoUser = addUser(companyId, "bruno", "Bruno", "Admin", true, "Administrator", roleIds); List<User> users = new ArrayList<User>(); users.add(brunoUser); roleIds = new long[] { powerUserRole.getRoleId() }; User kendraUser = addUser(companyId, "kendra", "Kendra", "Regular", true, "Employee", roleIds); users.add(kendraUser); roleIds = new long[] { powerUserRole.getRoleId(), writerRole.getRoleId() }; User michelleUser = addUser(companyId, "michelle", "Michelle", "Writer", false, "Writer", roleIds); users.add(michelleUser); roleIds = new long[] { powerUserRole.getRoleId(), publisherRole.getRoleId(), portalContentReviewer.getRoleId() }; User richardUser = addUser(companyId, "richard", "Richard", "Publisher", true, "Publisher", roleIds); users.add(richardUser); // Asset AssetCategory learningAssetCategory = _assetCategories.get("Learning"); AssetCategory liferayAssetCategory = _assetCategories.get("Liferay"); // Blogs ServiceContext serviceContext = new ServiceContext(); serviceContext.setAssetTagNames(new String[] { "new", "features", "control panel" }); serviceContext.setAssetCategoryIds( new long[] { learningAssetCategory.getCategoryId(), liferayAssetCategory.getCategoryId() }); serviceContext.setScopeGroupId(brunoUser.getGroupId()); addBlogsEntry(brunoUser.getUserId(), "New Control Panel!!", "/users/blogs/controlpanel.xml", serviceContext); serviceContext.setAssetCategoryIds( new long[] { learningAssetCategory.getCategoryId(), liferayAssetCategory.getCategoryId() }); serviceContext.setAssetTagNames(new String[] { "configuration", "portal.properties", "customization" }); addBlogsEntry(brunoUser.getUserId(), "Configuration of the portal: portal.properties", "/users/blogs/portalproperties.xml", serviceContext); serviceContext.setAssetCategoryIds( new long[] { learningAssetCategory.getCategoryId(), liferayAssetCategory.getCategoryId() }); serviceContext.setAssetTagNames(new String[] { "new", "wiki", "knowledge" }); serviceContext.setScopeGroupId(kendraUser.getGroupId()); addBlogsEntry(kendraUser.getUserId(), "Using the wiki", "/users/blogs/wiki.xml", serviceContext); serviceContext.setAssetCategoryIds( new long[] { learningAssetCategory.getCategoryId(), liferayAssetCategory.getCategoryId() }); serviceContext.setAssetTagNames(new String[] { "new", "chat", "communications", "features" }); serviceContext.setScopeGroupId(michelleUser.getGroupId()); addBlogsEntry(michelleUser.getUserId(), "We have an amazing Chat!", "/users/blogs/chat.xml", serviceContext); // Document library Folder folder = addDLFolder(brunoUser.getUserId(), brunoUser.getGroupId(), "Important Documents", "Documents related with the company"); serviceContext.setAssetTagNames(new String[] { "document", "budget", "2009" }); addDLFileEntry(brunoUser.getUserId(), folder.getGroupId(), folder.getFolderId(), "/users/document_library/Budget.xls", "Budget.xls", ContentTypes.APPLICATION_VND_MS_EXCEL, "Budget", "Budgets for the current year", serviceContext); addDLFolder(michelleUser.getUserId(), michelleUser.getGroupId(), "My Documents", "Personal docs"); folder = addDLFolder(michelleUser.getUserId(), michelleUser.getGroupId(), "Work Documents", "Works docs"); serviceContext.setAssetTagNames(new String[] { "document", "notes", "meeting" }); addDLFileEntry(michelleUser.getUserId(), folder.getGroupId(), folder.getFolderId(), "/users/document_library/Notes from the last meeting.doc", "Notes from the last meeting.doc", ContentTypes.APPLICATION_MSWORD, "Notes from the last meeting", "Important notes", serviceContext); addDLFolder(richardUser.getUserId(), richardUser.getGroupId(), "Documentation", StringPool.BLANK); folder = addDLFolder(richardUser.getUserId(), richardUser.getGroupId(), "Innovation", "New things"); serviceContext.setAssetTagNames(new String[] { "new", "features", "2009" }); addDLFileEntry(richardUser.getUserId(), folder.getGroupId(), folder.getFolderId(), "/users/document_library/New Features.ppt", "New Features.ppt", ContentTypes.APPLICATION_VND_MS_POWERPOINT, "New Features", "Features for the current year", serviceContext); // Message boards Organization sevenCogsOrganization = OrganizationLocalServiceUtil.getOrganization(companyId, "7Cogs, Inc."); serviceContext.setScopeGroupId(sevenCogsOrganization.getGroupId()); MBCategory mbCategory = addMBCategory(brunoUser.getUserId(), "Using the forum", "Some advice on using the forum", serviceContext); serviceContext.setAssetTagNames(new String[] { "forums", "liferay", "7cogs" }); addMBMessage(brunoUser.getUserId(), brunoUser.getFullName(), mbCategory.getGroupId(), mbCategory.getCategoryId(), 0, 0, "Nice Forums", "/sample/message_boards/general.xml", serviceContext); mbCategory = addMBCategory(brunoUser.getUserId(), "General Questions", "Product questions and more!", serviceContext); serviceContext.setAssetTagNames(new String[] { "vix-998", "liferay" }); MBMessage vix1Message = addMBMessage(brunoUser.getUserId(), brunoUser.getFullName(), mbCategory.getGroupId(), mbCategory.getCategoryId(), 0, 0, "About the Vix-998", "/sample/message_boards/vix1.xml", serviceContext); serviceContext.setAssetTagNames(new String[] { "vix-998", "latin" }); MBMessage vix2Message = addMBMessage(richardUser.getUserId(), richardUser.getFullName(), mbCategory.getGroupId(), mbCategory.getCategoryId(), vix1Message.getThreadId(), vix1Message.getMessageId(), "RE: About the Vix-998", "/sample/message_boards/vix2.xml", serviceContext); serviceContext.setAssetTagNames(new String[] { "vix-998", "vulgo" }); addMBMessage(michelleUser.getUserId(), michelleUser.getFullName(), mbCategory.getGroupId(), mbCategory.getCategoryId(), vix1Message.getThreadId(), vix2Message.getMessageId(), "RE: About the Vix-998", "/sample/message_boards/vix3.xml", serviceContext); // Social addSocialRequest(michelleUser, brunoUser, true); addSocialRequest(michelleUser, kendraUser, true); addSocialRequest(michelleUser, richardUser, true); addSocialRequest(kendraUser, brunoUser, false); addSocialRequest(kendraUser, richardUser, false); return users; }
From source file:com.liferay.so.hook.upgrade.v2_0_0.UpgradeDocumentLibrary.java
License:Open Source License
protected void moveDocumentsAndFolders(long groupId, long rootFolderId) throws Exception { boolean deleteFolder = true; List<FileEntry> fileEntries = DLAppLocalServiceUtil.getFileEntries(groupId, rootFolderId); for (FileEntry fileEntry : fileEntries) { ServiceContext serviceContext = new ServiceContext(); try {//from w ww . ja v a 2s . c o m DLAppLocalServiceUtil.moveFileEntry(fileEntry.getUserId(), fileEntry.getFileEntryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, serviceContext); } catch (Exception e) { deleteFolder = false; } } List<Folder> folders = DLAppLocalServiceUtil.getFolders(groupId, rootFolderId); for (Folder folder : folders) { ServiceContext serviceContext = new ServiceContext(); try { DLAppLocalServiceUtil.updateFolder(folder.getFolderId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, folder.getName(), folder.getDescription(), serviceContext); } catch (Exception e) { deleteFolder = false; } } if (deleteFolder) { DLAppLocalServiceUtil.deleteFolder(rootFolderId); } }
From source file:com.liferay.sync.internal.servlet.SyncDownloadServlet.java
License:Open Source License
protected void addZipFolderEntry(long userId, long repositoryId, long folderId, String folderPath, ZipWriter zipWriter) throws Exception { List<FileEntry> fileEntries = _dlAppService.getFileEntries(repositoryId, folderId); for (FileEntry fileEntry : fileEntries) { try (InputStream inputStream = _dlFileEntryLocalService.getFileAsStream(userId, fileEntry.getFileEntryId(), fileEntry.getVersion(), false)) { String filePath = folderPath + fileEntry.getTitle(); zipWriter.addEntry(filePath, inputStream); }//from ww w .j a v a 2 s . co m } List<Folder> childFolders = _dlAppService.getFolders(repositoryId, folderId); for (Folder childFolder : childFolders) { String childFolderPath = folderPath + childFolder.getName() + StringPool.FORWARD_SLASH; addZipFolderEntry(userId, repositoryId, childFolder.getFolderId(), childFolderPath, zipWriter); } }
From source file:com.liferay.sync.messaging.DLSyncEventMessageListener.java
License:Open Source License
protected void restoreFolder(long repositoryId, long folderId, long userId, String userName, long modifiedTime) throws Exception { List<Object> foldersAndFileEntriesAndFileShortcuts = DLAppServiceUtil .getFoldersAndFileEntriesAndFileShortcuts(repositoryId, folderId, WorkflowConstants.STATUS_APPROVED, false, QueryUtil.ALL_POS, QueryUtil.ALL_POS); for (Object folderAndFileEntryAndFileShortcut : foldersAndFileEntriesAndFileShortcuts) { Folder folder = null; SyncDLObject syncDLObject = null; if (folderAndFileEntryAndFileShortcut instanceof FileEntry) { FileEntry fileEntry = (FileEntry) folderAndFileEntryAndFileShortcut; syncDLObject = SyncUtil.toSyncDLObject(fileEntry, SyncConstants.EVENT_RESTORE, true); } else if (folderAndFileEntryAndFileShortcut instanceof Folder) { folder = (Folder) folderAndFileEntryAndFileShortcut; if (!SyncUtil.isSupportedFolder(folder)) { continue; }/*from ww w. j a v a2 s . c om*/ syncDLObject = SyncUtil.toSyncDLObject(folder, SyncConstants.EVENT_RESTORE); } syncDLObject.setUserId(userId); syncDLObject.setUserName(userName); syncDLObject.setModifiedTime(modifiedTime); addSyncDLObject(syncDLObject); if (folderAndFileEntryAndFileShortcut instanceof Folder) { restoreFolder(repositoryId, folder.getFolderId(), userId, userName, modifiedTime); } } }