本文整理汇总了Java中com.liferay.portal.kernel.util.PortalUtil类的典型用法代码示例。如果您正苦于以下问题:Java PortalUtil类的具体用法?Java PortalUtil怎么用?Java PortalUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PortalUtil类属于com.liferay.portal.kernel.util包,在下文中一共展示了PortalUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processLifecycleEvent
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
@Override
public void processLifecycleEvent(LifecycleEvent lifecycleEvent) throws ActionException {
User user;
try {
user = PortalUtil.getUser(lifecycleEvent.getRequest());
PrincipalThreadLocal.setName(user.getUserId());
PermissionChecker permissionChecker;
permissionChecker = PermissionCheckerFactoryUtil.create(user);
PermissionThreadLocal.setPermissionChecker(permissionChecker);
String friendlyUrl = user.getSiteGroups().get(0).getFriendlyURL();
lifecycleEvent.getResponse().sendRedirect("/group" + friendlyUrl);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例2: buildFields
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
/**
* Build content field
*
* @param groupId Company group ID
* @param locales locales
* @param baseArticle content data
* @return DDMStructure applied content XML strings
* @throws Exception
*/
public String buildFields(long groupId, String[] locales, String baseArticle) throws Exception {
DDMStructure ddmStructure =
_DDMStructureLocalService.getStructure(
groupId,
PortalUtil.getClassNameId(JournalArticle.class),
LDFPortletKeys._DDM_STRUCTURE_KEY
);
Map<String, Serializable> fieldsMap = Maps.newConcurrentMap();
fieldsMap.put(DDM_CONTENT, baseArticle);
Fields fields = _ddmLocalUtil.toFields(
ddmStructure.getStructureId(),
fieldsMap,
locales,
LocaleUtil.getDefault());
return _journalConverter.getContent(ddmStructure, fields);
}
示例3: runSQL
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
/**
* Performs a SQL query.
*
* @param sql the sql query
*/
protected void runSQL(String sql) {
try {
DataSource dataSource = regionPersistence.getDataSource();
DB db = DBManagerUtil.getDB();
sql = db.buildSQL(sql);
sql = PortalUtil.transformSQL(sql);
SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
sql);
sqlUpdate.update();
}
catch (Exception e) {
throw new SystemException(e);
}
}
示例4: runSQL
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
/**
* Performs a SQL query.
*
* @param sql the sql query
*/
protected void runSQL(String sql) {
try {
DataSource dataSource = countryPersistence.getDataSource();
DB db = DBManagerUtil.getDB();
sql = db.buildSQL(sql);
sql = PortalUtil.transformSQL(sql);
SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
sql);
sqlUpdate.update();
}
catch (Exception e) {
throw new SystemException(e);
}
}
示例5: runSQL
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
/**
* Performs a SQL query.
*
* @param sql the sql query
*/
protected void runSQL(String sql) {
try {
DataSource dataSource = fooPersistence.getDataSource();
DB db = DBManagerUtil.getDB();
sql = db.buildSQL(sql);
sql = PortalUtil.transformSQL(sql);
SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
sql);
sqlUpdate.update();
}
catch (Exception e) {
throw new SystemException(e);
}
}
示例6: isRelatedEntry
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
@Override
protected boolean isRelatedEntry(Data data) {
long groupId = data.getGroupId();
long repositoryId = data.get("repositoryId", -1L);
boolean hiddenFolder = isHiddenFolder(groupId, repositoryId);
if (!hiddenFolder) {
return false;
}
long classNameId = data.get("classNameId", 0L);
if (classNameId == 0) {
return false;
}
String permissionsClassName = PortalUtil.getClassName(classNameId);
return ArrayUtil.contains(
validPermissionClassNames, permissionsClassName);
}
示例7: isRelatedEntry
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
@Override
protected boolean isRelatedEntry(Data data) {
long categoryId = data.get("categoryId", 0L);
if (categoryId != MBCategoryConstants.DISCUSSION_CATEGORY_ID) {
return false;
}
long classNameId = data.get("classNameId", 0L);
if (classNameId == 0) {
return false;
}
String permissionsClassName = PortalUtil.getClassName(classNameId);
return ArrayUtil.contains(
validPermissionClassNames, permissionsClassName);
}
示例8: EmployeeFileTerm
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
public EmployeeFileTerm(ActionRequest actionRequest) {
UploadPortletRequest request = PortalUtil.getUploadPortletRequest(actionRequest);
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
fileName= request.getFileName("uploadedFile");
file = request.getFile("uploadedFile");
mimeType = request.getContentType("uploadedFile");
employeeFileId = ParamUtil.getLong(request, EMPLOYEE_FILE_ID);
groupId = themeDisplay.getScopeGroupId();
companyId = themeDisplay.getCompanyId();
userId = themeDisplay.getUserId();
userName = themeDisplay.getUser().getFullName();
createDate = ParamUtil.getDate(request, CREATE_DATE,
DateTimeUtils.getDateTimeFormat(DateTimeUtils._VN_DATE_TIME_FORMAT));
modifiedDate = ParamUtil.getDate(request, MODIFIED_DATE,
DateTimeUtils.getDateTimeFormat(DateTimeUtils._VN_DATE_TIME_FORMAT));
employeeId = ParamUtil.getLong(request, EMPLOYEE_ID);
fileEntryId = ParamUtil.getLong(request, FILE_ENTRY_ID);
documentName = ParamUtil.getString(request, DOCUMENT_NAME);
if(Validator.isNull(documentName)){
documentName = fileName;
}
}
示例9: getCurrentLayoutFriendlyURL
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
/**
* Get current layout friendly URL
*
* @return String friendly URL for the current layout
* @throws PortalException
*/
public static String getCurrentLayoutFriendlyURL(PortletRequest portletRequest)
throws PortalException {
ThemeDisplay themeDisplay =
(ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
Layout selectedLayout =
LayoutLocalServiceUtil.getLayout(themeDisplay.getPlid());
return PortalUtil.getLayoutFriendlyURL(selectedLayout, themeDisplay);
}
示例10: getNotLayoutBoundJournalArticleUrl
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
/**
* Get a view url for an article which is not bound to a layout or has a
* default view page.
*
* @return url string
* @throws PortalException
*/
protected String getNotLayoutBoundJournalArticleUrl()
throws PortalException {
ThemeDisplay themeDisplay =
(ThemeDisplay) _portletRequest.getAttribute(WebKeys.THEME_DISPLAY);
Layout layout = GSearchUtil.getLayoutByFriendlyURL(
_portletRequest, _assetPublisherPageFriendlyURL);
String assetPublisherInstanceId =
GSearchUtil.findDefaultAssetPublisherInstanceId(layout);
JournalArticle journalArticle = getJournalArticle();
StringBundler sb = new StringBundler();
sb.append(PortalUtil.getLayoutFriendlyURL(layout, themeDisplay));
sb.append("/-/asset_publisher/");
sb.append(assetPublisherInstanceId);
sb.append("/content/");
sb.append(journalArticle.getUrlTitle());
sb.append("?_");
sb.append(AssetPublisherPortletKeys.ASSET_PUBLISHER);
sb.append("_INSTANCE_");
sb.append(assetPublisherInstanceId);
sb.append("_groupId=");
sb.append(journalArticle.getGroupId());
return sb.toString();
}
示例11: getLink
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String getLink() {
StringBundler sb = new StringBundler();
sb.append(PortalUtil.getPortalURL(_portletRequest));
sb.append("/documents/");
sb.append(_document.get(Field.SCOPE_GROUP_ID));
sb.append("/");
sb.append(_document.get(Field.FOLDER_ID));
sb.append("/");
sb.append(_document.get("path"));
return sb.toString();
}
示例12: doLogin
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
@Override
protected String[] doLogin(
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String[] credentials = null;
long companyId = PortalUtil.getCompanyId(request);
User autoLoginUser = null;
try {
autoLoginUser = _userLocalService.getUserByEmailAddress(
companyId, "[email protected]");
}
catch (Exception e) {
}
if (autoLoginUser != null) {
credentials = new String[3];
credentials[0] = Long.toString(autoLoginUser.getUserId());
credentials[1] = autoLoginUser.getPassword();
credentials[2] = Boolean.toString(true);
}
return credentials;
}
示例13: generateSQLCriterion
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
public static Criterion generateSQLCriterion(String sql) {
if (Validator.isNull(sql)) {
return null;
}
sql = PortalUtil.transformSQL(sql);
return RestrictionsFactoryUtil.sqlRestriction(sql);
}
示例14: addDDLRecordSet
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
private static void addDDLRecordSet(final DdlRecordset recordSet, final long groupId)
throws SystemException, PortalException {
LOG.info("Adding DDLRecordSet " + recordSet.getName());
Map<Locale, String> nameMap = new HashMap<>();
Locale siteDefaultLocale = PortalUtil.getSiteDefaultLocale(groupId);
nameMap.put(siteDefaultLocale, recordSet.getName());
Map<Locale, String> descMap = new HashMap<>();
descMap.put(siteDefaultLocale, recordSet.getDescription());
DDLRecordSet ddlRecordSet = null;
try {
ddlRecordSet = DDLRecordSetLocalServiceUtil.fetchRecordSet(groupId, recordSet.getKey());
} catch (SystemException e) {
LOG.error("Error while trying to find DDLRecordSet with key: " + recordSet.getKey(), e);
}
if (ddlRecordSet != null) {
LOG.info("DDLRecordSet already exists and will be overwritten.");
ddlRecordSet.setNameMap(nameMap);
ddlRecordSet.setDescriptionMap(descMap);
ddlRecordSet.setDDMStructureId(ResolverUtil
.getStructureId(recordSet.getDdlStructureKey(), groupId, DDLRecordSet.class, false));
DDLRecordSetLocalServiceUtil.updateDDLRecordSet(ddlRecordSet);
LOG.info("DDLRecordSet successfully updated: " + recordSet.getName());
return;
}
DDLRecordSet newDDLRecordSet = DDLRecordSetLocalServiceUtil.addRecordSet(
LiferaySetup.getRunAsUserId(), groupId,
ResolverUtil.getStructureId(recordSet.getDdlStructureKey(), groupId,
DDLRecordSet.class, false),
recordSet.getDdlStructureKey(), nameMap, descMap, MIN_DISPLAY_ROWS, 0,
new ServiceContext());
LOG.info("Added DDLRecordSet: " + newDDLRecordSet.getName());
}
示例15: getDefaultLocale
import com.liferay.portal.kernel.util.PortalUtil; //导入依赖的package包/类
public static Locale getDefaultLocale(final long groupId, final String locationHint) {
Locale siteDefaultLocale = null;
try {
siteDefaultLocale = PortalUtil.getSiteDefaultLocale(groupId);
} catch (PortalException | SystemException e) {
LOG.error("Error Reading Locale while for " + locationHint);
}
return siteDefaultLocale;
}