portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jf...@apache.org
Subject svn commit: r506175 - in /portals/jetspeed-2/trunk/applications/j2-admin/src: java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java webapp/WEB-INF/view/pam-detail.jsp
Date Sun, 11 Feb 2007 23:37:05 GMT
Author: jford
Date: Sun Feb 11 15:37:05 2007
New Revision: 506175

URL: http://svn.apache.org/viewvc?view=rev&rev=506175
Log:
Added ability to modify security constraint reference

Modified:
    portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java
    portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/pam-detail.jsp

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java?view=diff&rev=506175&r1=506174&r2=506175
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/pam/PortletApplicationDetail.java
Sun Feb 11 15:37:05 2007
@@ -159,20 +159,14 @@
                     selectedPortletTab = (TabBean) pdTabMap.values().iterator().next();
                 }
                 if(selectedPortletTab.getId().equals("pd_security")) {
-                    try
-                    {
-                        List securityContraintRefList = pageManager.getPageSecurity().getSecurityConstraintsDefs();
-                        request.setAttribute("securityContraintRefList", securityContraintRefList);
-                        request.setAttribute("currentSecurityConstraintRef", pdef.getJetspeedSecurityConstraint());
-                    }
-                    catch (Exception e)
-                    {
-                        throw new PortletException("Failed to retrieve security constraint
references.");
-                    }
-                    
+                    setupSecurityContraintContext(request, null, pdef);
                 }
                 request.setAttribute("selected_portlet_tab", selectedPortletTab);
             }
+            else if(selectedTab.getId().equals("pa_details"))
+            {
+                setupSecurityContraintContext(request, pa, null);
+            }
             
             request.setAttribute(PortletApplicationResources.REQUEST_SELECT_TAB, selectedTab);
         }
@@ -180,6 +174,28 @@
         super.doView(request, response);
     }
 
+    private void setupSecurityContraintContext(RenderRequest request, MutablePortletApplication
pa, PortletDefinitionComposite pdef) throws PortletException
+    {
+        try
+        {
+            List securityContraintRefList = pageManager.getPageSecurity().getSecurityConstraintsDefs();
+            request.setAttribute("securityContraintRefList", securityContraintRefList);
+            if(pdef == null)
+            {
+                request.setAttribute("currentSecurityConstraintRef", pa.getJetspeedSecurityConstraint());
+            }
+            else
+            {
+                request.setAttribute("currentSecurityConstraintRef", pdef.getJetspeedSecurityConstraint());
+            }
+        }
+        catch (Exception e)
+        {
+            throw new PortletException("Failed to retrieve security constraint references
from "
+                    + (pdef == null ? "portlet application " + pa.getName() : "portlet definition
" + pdef.getName()));
+        }
+    }
+
     
     public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException, IOException
     {
@@ -223,6 +239,10 @@
                 {
                     processUserAttributeAction(actionRequest, actionResponse, pa, action);
                 }
+                else if(action.endsWith("edit_security_constraint"))
+                {
+                    processSecurityRef(actionRequest, actionResponse, pa, null, action);
+                }
                 searchEngine.update(pa);
             }
             else if(isPortletAction(action))
@@ -262,7 +282,7 @@
                         processContentType(actionRequest, actionResponse, pa, pdef, action);
                     }
                     else if(action.endsWith("edit_security_constraint")) {
-                        processSecurityRef(actionRequest, actionResponse, pa, pdef, action);
+                        processSecurityRef(actionRequest, actionResponse, null, pdef, action);
                     }
                     searchEngine.update(pdef);
                 }
@@ -476,7 +496,7 @@
             catch(RegistryException e)
             {
         	    throw new PortletException("Failed to perform action " + action + " on " 
-        	    		+ (pd == null ? "portlet definition " + pa.getName() : "portlet application
" + pa.getName()) );
+        	    		+ (pd == null ? "portlet application " + pa.getName() : "portlet definition
" + pd.getName()) );
             }
         }
     }
@@ -906,7 +926,15 @@
     private void processSecurityRef(ActionRequest actionRequest, ActionResponse actionResponse,
MutablePortletApplication pa, PortletDefinitionComposite pdef, String action) throws PortletException
     {
         String ref = actionRequest.getParameter("security-constraint-ref");
-        String currentRef = pdef.getJetspeedSecurityConstraint();
+        String currentRef = "";
+        if(pa != null)
+        {
+            currentRef = pa.getJetspeedSecurityConstraint();
+        }
+        else
+        {
+            currentRef = pdef.getJetspeedSecurityConstraint();
+        }
         if(currentRef == null) {
             currentRef = "";
         }
@@ -914,15 +942,25 @@
             if(ref.length() == 0) {
                 ref = null;
             }
-            pdef.setJetspeedSecurityConstraint(ref);
+            
             try
             {
-                registry.savePortletDefinition(pdef);
+                if(pa != null)
+                {
+                    pa.setJetspeedSecurityConstraint(ref);
+                    registry.updatePortletApplication(pa);
+                }
+                else
+                {
+                    pdef.setJetspeedSecurityConstraint(ref);
+                    registry.savePortletDefinition(pdef);
+                }
             }
-            catch (FailedToStorePortletDefinitionException e)
+            catch(RegistryException e)
             {
-                throw new PortletException("Failed to update portlet " + pdef.getName());
-            }
+                throw new PortletException("Failed to perform action " + action + " on "

+                        + (pdef == null ? "portlet application " + pa.getName() : "portlet
definition " + pdef.getName()) );
+            }            
         }
     }
     

Modified: portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/pam-detail.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/pam-detail.jsp?view=diff&rev=506175&r1=506174&r2=506175
==============================================================================
--- portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/pam-detail.jsp
(original)
+++ portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/pam-detail.jsp
Sun Feb 11 15:37:05 2007
@@ -250,6 +250,29 @@
 				</td>
 			</tr>
 		</table>
+		
+		<br />
+	    <portlet:actionURL var="edit_security_constraint" >
+	    </portlet:actionURL>
+	    <form action="<c:out value="${edit_security_constraint}"/>" method="post">
+	      <input type="hidden" name="portlet_action" value="portlet_app.edit_security_constraint"/>
+	      <table>
+	        <tr>
+	          <td class="portlet-section-alternate"><fmt:message key="pam.security_constraint"/></td>
+	          <td>
+			    <select name="security-constraint-ref">
+				  <option value="" <c:if test="${empty currentSecurityConstraintRef}">selected</c:if>
>No Constraint</option>
+				  <c:forEach var="secRef" items="${securityContraintRefList}">
+				    <option value="<c:out value="${secRef.name}"/>"  <c:if test="${secRef.name
== currentSecurityConstraintRef}">selected</c:if>  ><c:out value="${secRef.name}"/></option>
+				  </c:forEach>
+				</select>
+			  </td>
+			  <td>
+			    <input type="submit" value="<fmt:message key="pam.details.update"/>" class="portlet-form-button"/>
+	  	      </td>
+		    </tr>
+		  </table>
+	    </form>
 	
 		
 		<c:if test="${! empty pa.jetspeedServices}">



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message