1
22
23 package com.liferay.portlet.softwarecatalog.action;
24
25 import com.liferay.portal.kernel.util.ParamUtil;
26 import com.liferay.portal.util.PortalUtil;
27 import com.liferay.portal.util.WebKeys;
28 import com.liferay.portlet.softwarecatalog.model.SCFrameworkVersion;
29 import com.liferay.portlet.softwarecatalog.model.SCLicense;
30 import com.liferay.portlet.softwarecatalog.model.SCProductEntry;
31 import com.liferay.portlet.softwarecatalog.model.SCProductVersion;
32 import com.liferay.portlet.softwarecatalog.service.SCFrameworkVersionServiceUtil;
33 import com.liferay.portlet.softwarecatalog.service.SCLicenseServiceUtil;
34 import com.liferay.portlet.softwarecatalog.service.SCProductEntryServiceUtil;
35 import com.liferay.portlet.softwarecatalog.service.SCProductVersionServiceUtil;
36
37 import javax.portlet.ActionRequest;
38 import javax.portlet.RenderRequest;
39
40 import javax.servlet.http.HttpServletRequest;
41
42
48 public class ActionUtil {
49
50 public static void getFrameworkVersion(ActionRequest actionRequest)
51 throws Exception {
52
53 HttpServletRequest request = PortalUtil.getHttpServletRequest(
54 actionRequest);
55
56 getFrameworkVersion(request);
57 }
58
59 public static void getFrameworkVersion(RenderRequest renderRequest)
60 throws Exception {
61
62 HttpServletRequest request = PortalUtil.getHttpServletRequest(
63 renderRequest);
64
65 getFrameworkVersion(request);
66 }
67
68 public static void getFrameworkVersion(HttpServletRequest request)
69 throws Exception {
70
71 long frameworkVersionId = ParamUtil.getLong(
72 request, "frameworkVersionId");
73
74 SCFrameworkVersion frameworkVersion = null;
75
76 if (frameworkVersionId > 0) {
77 frameworkVersion =
78 SCFrameworkVersionServiceUtil.getFrameworkVersion(
79 frameworkVersionId);
80 }
81
82 request.setAttribute(
83 WebKeys.SOFTWARE_CATALOG_FRAMEWORK_VERSION, frameworkVersion);
84 }
85
86 public static void getLicense(ActionRequest actionRequest)
87 throws Exception {
88
89 HttpServletRequest request = PortalUtil.getHttpServletRequest(
90 actionRequest);
91
92 getLicense(request);
93 }
94
95 public static void getLicense(RenderRequest renderRequest)
96 throws Exception {
97
98 HttpServletRequest request = PortalUtil.getHttpServletRequest(
99 renderRequest);
100
101 getLicense(request);
102 }
103
104 public static void getLicense(HttpServletRequest request) throws Exception {
105 long licenseId = ParamUtil.getLong(request, "licenseId");
106
107 SCLicense license = null;
108
109 if (licenseId > 0) {
110 license = SCLicenseServiceUtil.getLicense(licenseId);
111 }
112
113 request.setAttribute(WebKeys.SOFTWARE_CATALOG_LICENSE, license);
114 }
115
116 public static void getProductEntry(ActionRequest actionRequest)
117 throws Exception {
118
119 HttpServletRequest request = PortalUtil.getHttpServletRequest(
120 actionRequest);
121
122 getProductEntry(request);
123 }
124
125 public static void getProductEntry(RenderRequest renderRequest)
126 throws Exception {
127
128 HttpServletRequest request = PortalUtil.getHttpServletRequest(
129 renderRequest);
130
131 getProductEntry(request);
132 }
133
134 public static void getProductEntry(HttpServletRequest request)
135 throws Exception {
136
137 long productEntryId = ParamUtil.getLong(request, "productEntryId");
138
139 SCProductEntry productEntry = null;
140
141 if (productEntryId > 0) {
142 productEntry = SCProductEntryServiceUtil.getProductEntry(
143 productEntryId);
144 }
145
146 request.setAttribute(
147 WebKeys.SOFTWARE_CATALOG_PRODUCT_ENTRY, productEntry);
148 }
149
150 public static void getProductVersion(ActionRequest actionRequest)
151 throws Exception {
152
153 HttpServletRequest request = PortalUtil.getHttpServletRequest(
154 actionRequest);
155
156 getProductVersion(request);
157 }
158
159 public static void getProductVersion(RenderRequest renderRequest)
160 throws Exception {
161
162 HttpServletRequest request = PortalUtil.getHttpServletRequest(
163 renderRequest);
164
165 getProductVersion(request);
166 }
167
168 public static void getProductVersion(HttpServletRequest request)
169 throws Exception {
170
171 long productVersionId = ParamUtil.getLong(request, "productVersionId");
172 long copyProductVersionId = ParamUtil.getLong(
173 request, "copyProductVersionId");
174
175 SCProductVersion productVersion = null;
176 SCProductEntry productEntry = null;
177
178 if (productVersionId > 0) {
179 productVersion = SCProductVersionServiceUtil.getProductVersion(
180 productVersionId);
181
182 productEntry = SCProductEntryServiceUtil.getProductEntry(
183 productVersion.getProductEntryId());
184
185 request.setAttribute(
186 WebKeys.SOFTWARE_CATALOG_PRODUCT_VERSION, productVersion);
187
188 request.setAttribute(
189 WebKeys.SOFTWARE_CATALOG_PRODUCT_ENTRY, productEntry);
190 }
191 else if (copyProductVersionId > 0) {
192 productVersion = SCProductVersionServiceUtil.getProductVersion(
193 copyProductVersionId);
194
195 productEntry = SCProductEntryServiceUtil.getProductEntry(
196 productVersion.getProductEntryId());
197
198 request.setAttribute(
199 WebKeys.SOFTWARE_CATALOG_PRODUCT_VERSION, productVersion);
200
201 request.setAttribute(
202 WebKeys.SOFTWARE_CATALOG_PRODUCT_ENTRY, productEntry);
203 }
204 else {
205 getProductEntry(request);
206 }
207 }
208
209 }