1
19
20 package com.liferay.portal.service.impl;
21
22 import com.liferay.portal.PortalException;
23 import com.liferay.portal.SystemException;
24 import com.liferay.portal.kernel.json.JSONArray;
25 import com.liferay.portal.kernel.json.JSONFactoryUtil;
26 import com.liferay.portal.kernel.json.JSONObject;
27 import com.liferay.portal.model.Portlet;
28 import com.liferay.portal.model.PortletApp;
29 import com.liferay.portal.model.RoleConstants;
30 import com.liferay.portal.security.auth.PrincipalException;
31 import com.liferay.portal.service.base.PortletServiceBaseImpl;
32
33 import java.util.List;
34
35
41 public class PortletServiceImpl extends PortletServiceBaseImpl {
42
43 public JSONArray getWARPortlets() {
44 JSONArray jsonArray = JSONFactoryUtil.createJSONArray();
45
46 List<Portlet> portlets = portletLocalService.getPortlets();
47
48 for(Portlet portlet : portlets) {
49 PortletApp portletApp = portlet.getPortletApp();
50
51 if (portletApp.isWARFile()) {
52 JSONObject jsonObject= JSONFactoryUtil.createJSONObject();
53
54 jsonObject.put("portlet_name", portlet.getPortletName());
55 jsonObject.put(
56 "servlet_context_name",
57 portletApp.getServletContextName());
58
59 jsonArray.put(jsonObject);
60 }
61 }
62
63 return jsonArray;
64 }
65
66 public Portlet updatePortlet(
67 long companyId, String portletId, String roles, boolean active)
68 throws PortalException, SystemException {
69
70 if (!roleLocalService.hasUserRole(
71 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
72
73 throw new PrincipalException();
74 }
75
76 return portletLocalService.updatePortlet(
77 companyId, portletId, roles, active);
78 }
79
80 }