List of usage examples for com.liferay.portal.kernel.util UnicodeProperties UnicodeProperties
public UnicodeProperties()
From source file:com.abubusoft.liferay.linkedin.action.AddLinkedinExpandoFieldsAction.java
License:Open Source License
protected void doRun(long companyId) throws Exception { ExpandoTable expandoTable = null;/* w w w . j av a2 s . c o m*/ try { expandoTable = ExpandoTableLocalServiceUtil.addTable(companyId, User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME); } catch (Exception e) { expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME); } try { UnicodeProperties properties = new UnicodeProperties(); properties.setProperty("hidden", "true"); properties.setProperty("visible-with-update-permission", "false"); addColumn(expandoTable.getTableId(), LinkedinConstants.LINKEDIN_ID_COLUMN_NAME, properties); if (_log.isInfoEnabled()) { _log.info("Custom field '" + LinkedinConstants.LINKEDIN_ID_COLUMN_NAME + "' added to User entity"); } } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug("Couldn't add custom field '" + LinkedinConstants.LINKEDIN_ID_COLUMN_NAME + "'"); } } }
From source file:com.abubusoft.liferay.twitter.action.AddTwitterExpandoFieldsAction.java
License:Open Source License
protected void doRun(long companyId) throws Exception { ExpandoTable expandoTable = null;/*from w w w. j a v a2 s .c o m*/ try { expandoTable = ExpandoTableLocalServiceUtil.addTable(companyId, User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME); } catch (Exception e) { expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME); } try { UnicodeProperties properties = new UnicodeProperties(); properties.setProperty("hidden", "true"); properties.setProperty("visible-with-update-permission", "false"); addColumn(expandoTable.getTableId(), TwitterConstants.TWITTER_ID_COLUMN_NAME, properties); if (_log.isInfoEnabled()) { _log.info("Custom field '" + TwitterConstants.TWITTER_ID_COLUMN_NAME + "' added to User entity"); } } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug("Couldn't add custom field '" + TwitterConstants.TWITTER_ID_COLUMN_NAME + "'"); } } }
From source file:com.liferay.content.targeting.service.test.util.GroupTestUtil.java
License:Open Source License
public static Group updateDisplaySettings(long groupId, Locale[] availableLocales, Locale defaultLocale) throws Exception { UnicodeProperties typeSettingsProperties = new UnicodeProperties(); boolean inheritLocales = false; if ((availableLocales == null) && (defaultLocale == null)) { inheritLocales = true;/*from www . j av a 2 s . co m*/ } typeSettingsProperties.put("inheritLocales", String.valueOf(inheritLocales)); if (availableLocales != null) { typeSettingsProperties.put(PropsKeys.LOCALES, StringUtil.merge(LocaleUtil.toLanguageIds(availableLocales))); } if (defaultLocale != null) { typeSettingsProperties.put("languageId", LocaleUtil.toLanguageId(defaultLocale)); } Group group = GroupLocalServiceUtil.updateGroup(groupId, typeSettingsProperties.toString()); ThreadLocalCacheManager.clearAll(Lifecycle.REQUEST); return group; }
From source file:com.liferay.document.library.internal.exportimport.data.handler.test.RepositoryStagedModelDataHandlerTest.java
License:Open Source License
@Override protected Map<String, List<StagedModel>> addDependentStagedModelsMap(Group group) throws Exception { Map<String, List<StagedModel>> dependentStagedModelsMap = new HashMap<>(); long classNameId = PortalUtil.getClassNameId(LiferayRepository.class.getName()); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(group.getGroupId(), TestPropsValues.getUserId()); Folder mountFolder = DLAppServiceUtil.addFolder(group.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString(), RandomTestUtil.randomString(), serviceContext); _repository = RepositoryLocalServiceUtil.addRepository(TestPropsValues.getUserId(), group.getGroupId(), classNameId, mountFolder.getFolderId(), RandomTestUtil.randomString(), RandomTestUtil.randomString(), RandomTestUtil.randomString(), new UnicodeProperties(), false, serviceContext);/*w w w . ja v a 2s. com*/ RepositoryEntry repositoryEntry = RepositoryEntryLocalServiceUtil.addRepositoryEntry( TestPropsValues.getUserId(), group.getGroupId(), _repository.getRepositoryId(), RandomTestUtil.randomString(), serviceContext); addDependentStagedModel(dependentStagedModelsMap, RepositoryEntry.class, repositoryEntry); return dependentStagedModelsMap; }
From source file:com.liferay.document.library.service.test.DLFileEntryFinderTest.java
License:Open Source License
@Before public void setUp() throws Exception { _user = UserTestUtil.addUser();/*from w ww.j a v a2s .c o m*/ long classNameId = PortalUtil.getClassNameId(LiferayRepository.class.getName()); _group = GroupTestUtil.addGroup(); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId()); _repository = RepositoryLocalServiceUtil.addRepository(TestPropsValues.getUserId(), _group.getGroupId(), classNameId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Repository A", StringPool.BLANK, "Test Portlet", new UnicodeProperties(), true, serviceContext); Object[] objects = setUp(_group.getGroupId(), StringPool.BLANK, serviceContext); _defaultRepositoryFolder = (Folder) objects[0]; _defaultRepositoryDLFileVersion = (DLFileVersion) objects[1]; objects = setUp(_repository.getRepositoryId(), "-NewRepository", serviceContext); _newRepositoryFolder = (Folder) objects[0]; }
From source file:com.liferay.document.library.service.test.DLFolderFinderTest.java
License:Open Source License
@Before public void setUp() throws Exception { _group = GroupTestUtil.addGroup();/*from w w w .j a v a2s .co m*/ ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId(), TestPropsValues.getUserId()); long classNameId = PortalUtil.getClassNameId(PortletRepository.class.getName()); RepositoryLocalServiceUtil.addRepository(TestPropsValues.getUserId(), _group.getGroupId(), classNameId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Test Repository", StringUtil.randomString(), StringUtil.randomString(), new UnicodeProperties(), false, serviceContext); _folder = DLAppLocalServiceUtil.addFolder(TestPropsValues.getUserId(), _group.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Folder A", StringPool.BLANK, serviceContext); DLAppLocalServiceUtil.addFolder(TestPropsValues.getUserId(), _group.getGroupId(), _folder.getFolderId(), "Folder B", StringPool.BLANK, serviceContext); Folder folder = DLAppLocalServiceUtil.addFolder(TestPropsValues.getUserId(), _group.getGroupId(), _folder.getFolderId(), "Folder C", StringPool.BLANK, serviceContext); DLTrashServiceUtil.moveFolderToTrash(folder.getFolderId()); FileEntry fileEntry = addFileEntry(_group.getGroupId(), _folder.getFolderId(), "FE1.txt", ContentTypes.TEXT_PLAIN); _fileShortcut = DLAppLocalServiceUtil.addFileShortcut(TestPropsValues.getUserId(), _group.getGroupId(), fileEntry.getFolderId(), fileEntry.getFileEntryId(), serviceContext); addFileEntry(_group.getGroupId(), _folder.getFolderId(), "FE2.html", ContentTypes.TEXT_HTML); fileEntry = addFileEntry(_group.getGroupId(), _folder.getFolderId(), "FE3.txt", ContentTypes.TEXT_PLAIN); DLTrashServiceUtil.moveFileEntryToTrash(fileEntry.getFileEntryId()); }
From source file:com.liferay.document.library.web.exportimport.data.handler.test.DLPortletDataHandlerTest.java
License:Open Source License
protected void addRepositoryEntries() throws Exception { long classNameId = PortalUtil.getClassNameId(LiferayRepository.class.getName()); Repository repository = RepositoryLocalServiceUtil.addRepository(TestPropsValues.getUserId(), stagingGroup.getGroupId(), classNameId, DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, PortletKeys.BACKGROUND_TASK, StringPool.BLANK, PortletKeys.BACKGROUND_TASK, new UnicodeProperties(), true, ServiceContextTestUtil.getServiceContext()); ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(stagingGroup.getGroupId(), TestPropsValues.getUserId()); Folder folder = DLAppServiceUtil.addFolder(repository.getRepositoryId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString(), RandomTestUtil.randomString(), serviceContext); DLAppLocalServiceUtil.addFileEntry(TestPropsValues.getUserId(), repository.getRepositoryId(), folder.getFolderId(), RandomTestUtil.randomString() + ".txt", ContentTypes.TEXT_PLAIN, RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE), serviceContext); }
From source file:com.liferay.faces.demos.hook.RegisterExpandoAction.java
License:Open Source License
protected void addExpandoColumn(long companyId, String modelClassName, String expandoColumnName, int expandoColumnType, boolean indexable) throws PortalException, SystemException { ExpandoTable expandoTable = null;/*from w ww . j a v a2 s. c o m*/ try { expandoTable = ExpandoTableLocalServiceUtil.getDefaultTable(companyId, modelClassName); } catch (NoSuchTableException e) { expandoTable = ExpandoTableLocalServiceUtil.addDefaultTable(companyId, modelClassName); logger.debug("Added expando table for modelClassName=[{0}]", modelClassName); } ExpandoColumn expandoColumn = null; expandoColumn = ExpandoColumnLocalServiceUtil.getColumn(expandoTable.getTableId(), expandoColumnName); if (expandoColumn != null) { logger.debug("Expando column=[{0}] exists for modelClassName=[{1}]", expandoColumnName, modelClassName); } else { expandoColumn = ExpandoColumnLocalServiceUtil.addColumn(expandoTable.getTableId(), expandoColumnName, expandoColumnType); logger.debug("Added expando column=[{0}] to modelClassName=[{1}]", expandoColumnName, modelClassName); } if (indexable) { UnicodeProperties properties; properties = new UnicodeProperties(); properties.setProperty(ExpandoColumnConstants.INDEX_TYPE, String.valueOf(ExpandoColumnConstants.INDEX_TYPE_TEXT)); expandoColumn.setTypeSettingsProperties(properties); ExpandoColumnLocalServiceUtil.updateExpandoColumn(expandoColumn); } if (expandoColumn != null) { // Add permissions to the column so that all users can VIEW and UPDATE. Role userRole = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER); String resourceId = ExpandoColumn.class.getName(); String primKey = String.valueOf(expandoColumn.getColumnId()); String[] actionKeys = new String[] { ActionKeys.VIEW, ActionKeys.UPDATE }; PermissionUtil.grantPermissions(companyId, userRole.getRoleId(), resourceId, ResourceConstants.SCOPE_INDIVIDUAL, primKey, actionKeys); } }
From source file:com.liferay.google.action.AddGoogleExpandoFieldsAction.java
License:Open Source License
protected void doRun(long companyId) throws Exception { ExpandoTable expandoTable = null;//from www.jav a2 s .com try { expandoTable = ExpandoTableLocalServiceUtil.addTable(companyId, User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME); } catch (Exception e) { expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME); } UnicodeProperties properties = new UnicodeProperties(); properties.setProperty("hidden", "true"); properties.setProperty("visible-with-update-permission", "false"); addColumn(expandoTable.getTableId(), GoogleOAuth.GOOGLE_ACCESS_TOKEN, properties); addColumn(expandoTable.getTableId(), GoogleOAuth.GOOGLE_REFRESH_TOKEN, properties); addColumn(expandoTable.getTableId(), GoogleOAuth.GOOGLE_USER_ID, properties); }
From source file:com.liferay.google.login.hook.events.AddGoogleExpandoColumnsAction.java
License:Open Source License
protected void doRun(long companyId) throws Exception { ExpandoTable expandoTable = null;//from w w w.ja v a2 s .com try { expandoTable = ExpandoTableLocalServiceUtil.addTable(companyId, User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME); } catch (Exception e) { expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, User.class.getName(), ExpandoTableConstants.DEFAULT_TABLE_NAME); } UnicodeProperties properties = new UnicodeProperties(); properties.setProperty("hidden", "true"); properties.setProperty("visible-with-update-permission", "false"); addExpandoColumn(expandoTable, "googleAccessToken", properties); addExpandoColumn(expandoTable, "googleRefreshToken", properties); addExpandoColumn(expandoTable, "googleUserId", properties); }