001
014
015 package com.liferay.portal.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.json.JSONArray;
020 import com.liferay.portal.kernel.json.JSONFactoryUtil;
021 import com.liferay.portal.kernel.json.JSONObject;
022 import com.liferay.portal.model.Portlet;
023 import com.liferay.portal.model.PortletApp;
024 import com.liferay.portal.model.RoleConstants;
025 import com.liferay.portal.security.auth.PrincipalException;
026 import com.liferay.portal.service.base.PortletServiceBaseImpl;
027
028 import java.util.List;
029
030
033 public class PortletServiceImpl extends PortletServiceBaseImpl {
034
035 public JSONArray getWARPortlets() {
036 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
037
038 List<Portlet> portlets = portletLocalService.getPortlets();
039
040 for (Portlet portlet : portlets) {
041 PortletApp portletApp = portlet.getPortletApp();
042
043 if (portletApp.isWARFile()) {
044 JSONObject jsonObject = JSONFactoryUtil.createJSONObject();
045
046 jsonObject.put("portlet_name", portlet.getPortletName());
047 jsonObject.put(
048 "servlet_context_name",
049 portletApp.getServletContextName());
050
051 jsonArray.put(jsonObject);
052 }
053 }
054
055 return jsonArray;
056 }
057
058 public Portlet updatePortlet(
059 long companyId, String portletId, String roles, boolean active)
060 throws PortalException, SystemException {
061
062 if (!roleLocalService.hasUserRole(
063 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
064
065 throw new PrincipalException();
066 }
067
068 return portletLocalService.updatePortlet(
069 companyId, portletId, roles, active);
070 }
071
072 }