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