当前位置: 首页>>代码示例>>Java>>正文


Java PortalUtil类代码示例

本文整理汇总了Java中com.liferay.portal.util.PortalUtil的典型用法代码示例。如果您正苦于以下问题:Java PortalUtil类的具体用法?Java PortalUtil怎么用?Java PortalUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PortalUtil类属于com.liferay.portal.util包,在下文中一共展示了PortalUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _notityMail

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
private void _notityMail(String context, Throwable e) {

		try {
			String errorMailTo =
				PrefsPropsUtil.getString(
					PortletPropsKeys.MQTT_ERRORS_SEND_MAIL_TO,
					PortletPropsValues.MQTT_ERRORS_SEND_MAIL_TO);

			if (Validator.isNotNull(errorMailTo)) {
				MailMessage mailMessage = new MailMessage();

				long companyId = PortalUtil.getDefaultCompanyId();

				String fromAddress = PrefsPropsUtil.getString(
					companyId, PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

				mailMessage.setHTMLFormat(false);
				mailMessage.setTo(new InternetAddress(errorMailTo));
				mailMessage.setSubject(String.format(
					"%s Mqtt connector error", PortalUtil.getComputerName()));
				mailMessage.setFrom(new InternetAddress(fromAddress));

				StringWriter sw = new StringWriter();
				PrintWriter pw = new PrintWriter(sw);
				e.printStackTrace(pw);

				mailMessage.setBody(String.format(
					"context: %s\nerror: %s\n stacktrace:%s\n", context,
					e.getMessage(), sw.toString()));

				MailServiceUtil.sendEmail(mailMessage);
			}
		}
		catch (Exception e1) {
			_log.error(e1);
		}
	}
 
开发者ID:baxtheman,项目名称:mqtt-liferay-plugins,代码行数:38,代码来源:MqttLocalServiceImpl.java

示例2: uploadPHPFile

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
private void uploadPHPFile(ResourceRequest resourceRequest,
          ResourceResponse resourceResponse) throws IOException {
      UploadRequest uploadRequest = PortalUtil.getUploadPortletRequest(resourceRequest);
      File objFile = uploadRequest.getFile("PHPFILE");
      String objFileName = uploadRequest.getFileName("PHPFILE");
      _log.info("objFile: [" + objFile + "], objFileName: [" + objFileName + "]");        

      InputStream is = new FileInputStream(objFile);
          
      byte[] buff = new byte[is.available()];
      is.read(buff);
      is.close();
      String publicKeyStr = new String(buff);
resourceResponse.setContentType("text/html");
      PrintWriter writer = resourceResponse.getWriter();
      JSONObject jsonObject =  JSONFactoryUtil.createJSONObject();
      String[] arrStr = publicKeyStr.split("-----BEGIN PUBLIC KEY-----");
      publicKeyStr = arrStr[1];
      arrStr = publicKeyStr.split("-----END PUBLIC KEY-----");
      jsonObject.put("publicKey", arrStr[0]);
      phpPublicKey = arrStr[0];
      writer.print(jsonObject.toString());
      writer.flush();
      writer.close();
  }
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:26,代码来源:RSAToolPortlet.java

示例3: prettify

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
protected String prettify(PortletRequest request) throws IOException,
		PortletException {
	UploadPortletRequest uploadPortletRequest = PortalUtil
			.getUploadPortletRequest(request);

	String liferayVersion = ParamUtil.getString(uploadPortletRequest,
			"liferayVersion", "7.0.4-ga5");
	boolean printDefaultValue = ParamUtil.getBoolean(uploadPortletRequest,
			"printDefaultValue");

	Properties customProperties = PropertiesUtil.load(
			uploadPortletRequest.getFileAsStream("portalPropertiesFile"),
			"UTF-8");

	String prettyProperties = prettier.prettify(customProperties,
			liferayVersion, printDefaultValue);

	incrementCounter(request);

	return prettyProperties;
}
 
开发者ID:tmoreira2020,项目名称:portal-properties-prettier-app,代码行数:22,代码来源:PortalPropertiesPrettierPortlet.java

示例4: edit

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
public void edit(ActionRequest request, ActionResponse response)
		throws PortalException, SystemException, IOException {
	long editId = ParamUtil.getLong(request,
			JobPosKeys.BaseJobPosAttributes.EDIT_ID,
			PortletKeys.LONG_DEFAULT);

	JobPos application = JobPosLocalServiceUtil
			.getJobPos(editId);
	setParameterIntoResponse(response, application);

	if (!SessionErrors.isEmpty(request)) {
		response.sendRedirect(ParamUtil.getString(request,
				PortletKeys.REDIRECT_PAGE));
	} else {
		PortalUtil.copyRequestParameters(request, response);
	}
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:18,代码来源:JobPosPortlet.java

示例5: createCourse

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
@JSONWebService
public Course createCourse(long groupId,String title, String description,boolean published,String summary,int evaluationmethod,int calificationType,int template,int registermethod,int maxusers, Date startregistrationdate,Date endregistrationdate) throws PortalException, SystemException
{
	User user=getUser();
	
	java.util.Date ahora=new java.util.Date(System.currentTimeMillis());
	ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
	serviceContext.setUserId(user.getUserId());
	serviceContext.setScopeGroupId(groupId);
	String groupName = GroupConstants.GUEST;
	long companyId = PortalUtil.getDefaultCompanyId();
	
	if( getPermissionChecker().hasPermission(groupId, "com.liferay.lms.coursemodel",groupId,"ADD_COURSE"))
	{
		Course course = com.liferay.lms.service.CourseLocalServiceUtil.addCourse(
				title, description, summary, StringPool.BLANK,
				user.getLocale(), ahora, startregistrationdate, endregistrationdate,template,registermethod,evaluationmethod,
				calificationType,maxusers,serviceContext,false);
		com.liferay.lms.service.CourseLocalServiceUtil.setVisible(course.getCourseId(), published);
		return course;
	}
	else
	{
		return null;
	}
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:27,代码来源:CourseServiceImpl.java

示例6: addEditAppRole

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
public void addEditAppRole(ActionRequest request, ActionResponse response) throws SystemException, PortalException, IOException {
	validateParamsIntoSessionError(request);
	
	if (SessionErrors.isEmpty(request)) {
		ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
		long applicationId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.APPLICATION_ID, PortletKeys.LONG_DEFAULT);
		String roleCode = ParamUtil.getString(request, AppRoleKeys.AddEditAttributes.ROLE_CODE, PortletKeys.TEXT_BOX);
		String roleName = ParamUtil.getString(request, AppRoleKeys.AddEditAttributes.ROLE_NAME, PortletKeys.TEXT_BOX);
		
		Long editId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.EDIT_ID, PortletKeys.LONG_DEFAULT);
		if (editId == PortletKeys.LONG_DEFAULT) {
			AppRoleLocalServiceUtil.addAppRole(applicationId, roleCode, roleName, serviceContext);
			SessionMessages.add(request, AppRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_SUCCESS_ADDNEW);	
		} else {
			AppRoleLocalServiceUtil.updateAppRole(editId, applicationId, roleCode, roleName, serviceContext);
			SessionMessages.add(request, AppRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_SUCCESS_UPDATE);	
		}
	}
	SessionMessages.add(request, PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); 		
	if (!SessionErrors.isEmpty(request)) {
		PortalUtil.copyRequestParameters(request, response);
	} else {
		response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
	}
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:26,代码来源:AppRolePortlet.java

示例7: addEditAppRole2JobPos

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
public void addEditAppRole2JobPos(ActionRequest request, ActionResponse response) throws SystemException, PortalException, IOException {
	if (SessionErrors.isEmpty(request)) {
		ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext();
		long appRoleId = ParamUtil.getLong(request, AppRole2JobPosKeys.AddEditAttributes.APPROLE_ID, PortletKeys.LONG_DEFAULT);
		long jobPosId = ParamUtil.getLong(request, AppRole2JobPosKeys.AddEditAttributes.JOBPOS_ID, PortletKeys.LONG_DEFAULT);
		
		Long editId = ParamUtil.getLong(request, AppRole2JobPosKeys.AddEditAttributes.EDIT_ID, PortletKeys.LONG_DEFAULT);
		if (editId == PortletKeys.LONG_DEFAULT) {
			AppRole2JobPosLocalServiceUtil.addAppRole2JobPos(appRoleId, jobPosId, serviceContext);
			SessionMessages.add(request, AssignRoleKeys.SuccessMessageKeys.ORG_OEP_SSOMGT_PORTLET_APPROLE_ASSIGNROLE2JOBPOS_SUCCESS_ADDNEW);	
		} else {
		}
	}
	SessionMessages.add(request, PortalUtil.getPortletId(request) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE); 		
	if (!SessionErrors.isEmpty(request)) {
		PortalUtil.copyRequestParameters(request, response);
	} else {
		response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
	}
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:21,代码来源:AppRolePortlet.java

示例8: sendFile

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
/**
 * Send file.
 *
 * @param name the name
 * @param mimeType the mime type
 * @param contents the contents
 * @param request the request
 * @param response the response
 */
protected void sendFile(final String name, final String mimeType,
        final byte[] contents, final ActionRequest request,
        final ActionResponse response) {
	try {
		if (name != null && mimeType != null && contents != null) {
			final HttpServletRequest httpServletRequest = PortalUtil
			        .getHttpServletRequest(request);
			final HttpServletResponse httpServletResponse = PortalUtil
			        .getHttpServletResponse(response);

			httpServletResponse.setContentType(mimeType);
			httpServletResponse.setHeader("Expires", "0");
			httpServletResponse.setHeader("Cache-Control",
			        "must-revalidate, post-check=0, pre-check=0");
			httpServletResponse.setHeader("Pragma", "public");
			httpServletResponse.setContentLength(contents.length);
			ServletResponseUtil.sendFile(httpServletRequest,
			        httpServletResponse, name, contents);
		}
	} catch (final Throwable t) {
		t.printStackTrace();
	}
}
 
开发者ID:fraunhoferfokus,项目名称:particity,代码行数:33,代码来源:BaseController.java

示例9: isUserLoggedIn

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
@Override
public boolean isUserLoggedIn(HttpServletRequest request) {
    try {
        return PortalUtil.getUser(request) != null;
    } catch (PortalException | SystemException e) {
        return false;
    }
}
 
开发者ID:finalist,项目名称:liferay-oidc-plugin,代码行数:9,代码来源:Liferay62Adapter.java

示例10: getURLCreateActivity

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
public static final PortletURL getURLCreateActivity(LiferayPortletRequest liferayPortletRequest,
		LiferayPortletResponse liferayPortletResponse, Module module) throws Exception {
	PortletURL portletURL = null;
	if(module!=null){
		long plid = PortalUtil.getPlidFromPortletId(module.getGroupId(), ACTIVITY_VIEWER_PORTLET_ID);
	     
		log.debug("PLID: "+plid);
		
		if (plid == LayoutConstants.DEFAULT_PLID) {
			throw new NoSuchLayoutException();
		}		

		portletURL = liferayPortletResponse.createLiferayPortletURL(plid, LMS_EDITACTIVITY_PORTLET_ID, PortletRequest.RENDER_PHASE);
		portletURL.setWindowState(WindowState.NORMAL);
		portletURL.setParameter("actionEditingActivity", StringPool.TRUE);
		portletURL.setParameter("actionEditingDetails", StringPool.FALSE);
		portletURL.setParameter("mvcPath", "/html/lmsactivitieslist/newactivity.jsp");
		portletURL.setParameter("resModuleId",Long.toString(module.getModuleId())); 	
		portletURL.setParameter("actId",Long.toString(0)); 
		portletURL.setParameter("resId",Long.toString(0)); 
		portletURL.setParameter("p_o_p_id",ACTIVITY_VIEWER_PORTLET_ID);
		
		log.debug(" getURLCreateActivity: "+portletURL);
		
	}
	
	return portletURL;		
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:29,代码来源:LmsActivitiesList.java

示例11: editInscriptionDates

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
public void editInscriptionDates(ActionRequest actionRequest,
		ActionResponse actionResponse) throws Exception 
{

	long courseId = ParamUtil.getLong(actionRequest, "courseId", 0);
	long userId = ParamUtil.getLong(actionRequest, "userId", 0);
	User user = UserLocalServiceUtil.getUser(userId);
	Course course = CourseLocalServiceUtil.getCourse(courseId);
	int startMonth = ParamUtil.getInteger(actionRequest, "startMon");
	int startYear = ParamUtil.getInteger(actionRequest, "startYear");
	int startDay = ParamUtil.getInteger(actionRequest, "startDay");
	int stopMonth = ParamUtil.getInteger(actionRequest, "stopMon");
	int stopYear = ParamUtil.getInteger(actionRequest, "stopYear");
	int stopDay = ParamUtil.getInteger(actionRequest, "stopDay");
	boolean startDateEnabled=ParamUtil.getBoolean(actionRequest,"startdate-enabled",false);
	boolean stopDateEnabled=ParamUtil.getBoolean(actionRequest,"stopdate-enabled",false);
	Date allowStartDate = PortalUtil.getDate(startMonth, startDay, startYear,
			0, 0, user.getTimeZone(),
			new EntryDisplayDateException());
	
	if(!startDateEnabled)
    {
		allowStartDate=null;
    }
	
	Date allowFinishDate = PortalUtil.getDate(stopMonth, stopDay, stopYear,
			0, 0, user.getTimeZone(),
			new EntryDisplayDateException());
	if(!stopDateEnabled)
    {
		allowFinishDate=null;
    }
	CourseServiceUtil.editUserInscriptionDates(courseId,userId,allowStartDate,allowFinishDate);
	actionResponse.setRenderParameters(actionRequest.getParameterMap());
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:36,代码来源:CourseAdmin.java

示例12: upmodule

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
public void upmodule(ActionRequest actionRequest, ActionResponse actionResponse)
		throws Exception {

	ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
	long userIdAction = themeDisplay.getUserId();
	String portletId = PortalUtil.getPortletId(actionRequest);
	long moduleId = ParamUtil.getLong(actionRequest, "resourcePrimKey",0);

	if(moduleId>0)
	{
		com.liferay.lms.service.ModuleLocalServiceUtil.goUpModule(moduleId,userIdAction);
	}

}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:15,代码来源:modulePortlet.java

示例13: editApplication

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
public void editApplication(ActionRequest request, ActionResponse response) throws PortalException, SystemException, IOException {
	long editId = ParamUtil.getLong(request, ApplicationKeys.BaseApplicationAttributes.EDIT_ID, PortletKeys.LONG_DEFAULT);
	
	Application application = ApplicationLocalServiceUtil.getApplication(editId);
	setParameterIntoResponse(response, application);
	
	if (!SessionErrors.isEmpty(request)) {
		response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
	} else {
		PortalUtil.copyRequestParameters(request, response);
	}
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:13,代码来源:ApplicationManagementPortlet.java

示例14: serveResource

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
public void serveResource(ResourceRequest resourceRequest,
		ResourceResponse resourceResponse) throws IOException,
		PortletException {
	
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	
	try {
		
		ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest
				.getAttribute(WebKeys.THEME_DISPLAY);
		
		loadFonts();
		
		write_IEC_Pdf(baos,themeDisplay,PortalUtil.getHttpServletRequest(resourceRequest));
	    
		ServletResponseUtil.sendFile(PortalUtil.getHttpServletRequest(resourceRequest),
				 PortalUtil.getHttpServletResponse(resourceResponse),
				 fileName,
				 baos.toByteArray(), 
				 ContentTypes.APPLICATION_PDF);
			
	} catch (Exception e) {
		e.printStackTrace();
		SessionErrors.add(resourceRequest, "export.pdf.userstats.error");
	} finally{
		baos.close();
	}
	
}
 
开发者ID:TelefonicaED,项目名称:liferaylms-portlet,代码行数:30,代码来源:UserProgress.java

示例15: editAppRole

import com.liferay.portal.util.PortalUtil; //导入依赖的package包/类
public void editAppRole(ActionRequest request, ActionResponse response) throws PortalException, SystemException, IOException {
	long editId = ParamUtil.getLong(request, AppRoleKeys.AddEditAttributes.EDIT_ID, PortletKeys.LONG_DEFAULT);
	
	AppRole appRole = AppRoleLocalServiceUtil.getAppRole(editId);
	setParameterIntoResponse(response, appRole);
	
	if (!SessionErrors.isEmpty(request)) {
		response.sendRedirect(ParamUtil.getString(request, PortletKeys.REDIRECT_PAGE));
	} else {
		PortalUtil.copyRequestParameters(request, response);
	}
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:13,代码来源:AppRolePortlet.java


注:本文中的com.liferay.portal.util.PortalUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。