cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r321120 - in /cocoon/blocks: portal-sample/trunk/samples/tools/plugins/userManagement/ portal/trunk/java/org/apache/cocoon/portal/tools/ portal/trunk/java/org/apache/cocoon/portal/tools/userManagement/
Date Fri, 14 Oct 2005 13:57:18 GMT
Author: cziegeler
Date: Fri Oct 14 06:57:11 2005
New Revision: 321120

URL: http://svn.apache.org/viewcvs?rev=321120&view=rev
Log:
Remove dependency to auth-fw

Modified:
    cocoon/blocks/portal-sample/trunk/samples/tools/plugins/userManagement/flow.js
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/PortalToolManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/userManagement/ContextGrabber.java

Modified: cocoon/blocks/portal-sample/trunk/samples/tools/plugins/userManagement/flow.js
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/tools/plugins/userManagement/flow.js?rev=321120&r1=321119&r2=321120&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/tools/plugins/userManagement/flow.js (original)
+++ cocoon/blocks/portal-sample/trunk/samples/tools/plugins/userManagement/flow.js Fri Oct
14 06:57:11 2005
@@ -15,26 +15,18 @@
  */
 cocoon.load("resource://org/apache/cocoon/portal/tools/ptm.js");
 
-/* component authenticationManager contains the data from the file 'sunrise-user.xml' */
-
 function getContext () {
-	var contextMan = 
-	cocoon.getComponent(Packages.org.apache.cocoon.webapps.session.ContextManager.ROLE);
-	var context = contextMan.getContext("authentication");
-
-	var authenticationManager = cocoon.getComponent("org.apache.cocoon.webapps.authentication.AuthenticationManager");
-	/* get current user data */
-	var context = authenticationManager.getState().getHandler().getContext();
+	var service = 
+	cocoon.getComponent(Packages.org.apache.cocoon.portal.PortalService.ROLE);
 
 	var grabber = new Packages.org.apache.cocoon.portal.tools.userManagement.ContextGrabber();
-	var obj = grabber.grab(context);
+	var obj = grabber.grab(service);
 	
 	var pic = obj.getContextItem ("picture");
 	if (pic != null)
 		obj.setPicture (pic);
 	
-	cocoon.releaseComponent(contextMan);
-	cocoon.releaseComponent(authenticationManager);
+	cocoon.releaseComponent(service);
 	return obj;
 }
 
@@ -68,12 +60,8 @@
  */
 function addUser() {
 	
-	var authenticationManager = cocoon.getComponent("org.apache.cocoon.webapps.authentication.AuthenticationManager");
-	
 	/* get current user data */
 	var obj = new Packages.org.apache.cocoon.portal.tools.userManagement.UserBean();
-	var context = authenticationManager.getState().getHandler().getContext();
-	createDefaultKeys (context.getXML("/authentication/"),0,obj);
 	
 	var mf = obj.getContext();
 	for(var it = mf.iterator();it.hasNext();) {
@@ -86,61 +74,4 @@
 	form.createBinding("cocoon:/page/binding/userData?mode=add");
     form.load(obj);
     form.showForm("page/form/userData?mode=add");
-
-    cocoon.releaseComponent(authenticationManager);
-}
-
-/* internal function: creating an empty context of user data from the authenticationManager
- */
-function createDefaultKeys (node,lev, obj) {
-	
-	node = node.firstChild;
-	while (node != null)
-	{
-		if (node.nodeName == '#text')
-		{
-			createDefaultKeys(node,lev+1,obj);
-		}
-		else if (node.firstChild == null) 
-		{
-			obj.addContext (node.nodeName,"");
-		}
-		else if (node.firstChild.nodeValue == null)
-		{
-			createDefaultKeys(node,lev+1,obj);
-		}
-		else
-		{
-			obj.addContext (node.nodeName,"");
-		}
-		node = node.nextSibling;
-	}
 }
-
-/* internal function: creates the context of the user data from the authenticationManager
- */
-function printRek (node,lev, obj)
-{
-	node = node.firstChild;
-	while (node != null)
-	{
-		if (node.nodeName == '#text')
-		{
-			printRek(node,lev+1,obj);
-		}
-		else if (node.firstChild == null) 
-		{
-			obj.addContext (node.nodeName,"");
-		}
-		else if (node.firstChild.nodeValue == null)
-		{
-			printRek(node,lev+1,obj);
-		}
-		else
-		{
-			obj.addContext (node.nodeName,node.firstChild.nodeValue);
-		}
-		node = node.nextSibling;
-	}
-
-}
\ No newline at end of file

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/PortalToolManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/PortalToolManager.java?rev=321120&r1=321119&r2=321120&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/PortalToolManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/PortalToolManager.java
Fri Oct 14 06:57:11 2005
@@ -23,6 +23,7 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.configuration.Configuration;
@@ -40,15 +41,11 @@
 import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.tools.helper.PortalObjects;
 import org.apache.cocoon.portal.tools.service.UserRightsService;
-import org.apache.cocoon.webapps.session.ContextManager;
-import org.apache.cocoon.webapps.session.context.SessionContext;
 import org.apache.excalibur.source.ModifiableSource;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.excalibur.source.SourceUtil;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Text;
 import org.xml.sax.SAXException;
 
 /**
@@ -59,7 +56,7 @@
 
 	public static final String ROLE = PortalToolManager.class.getName();
 
-	private HashMap tools = new HashMap();
+	private Map tools = new HashMap();
 
 	private ServiceManager manager;
 
@@ -75,11 +72,12 @@
 	private Configuration configuration;
 	private UserRightsService userRightsService;
 
-    private ContextManager contextManager;
-
     /** The source resolver */
     protected SourceResolver resolver;
 
+    /** The portal service. */
+    protected PortalService service;
+
 	/**
 	 * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
 	 */
@@ -192,7 +190,7 @@
     public void service(ServiceManager manager) throws ServiceException {
         this.manager = manager;
         this.resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
-        this.contextManager = (ContextManager)this.manager.lookup(ContextManager.ROLE);
+        this.service = (PortalService)this.manager.lookup(PortalService.ROLE);
     }
 
     /**
@@ -237,22 +235,11 @@
      * @param key Path (e.g. /foo/bar)
      */
     public String sGet(String key) {
-        SessionContext ctx;
-        try {
-		    ctx = this.contextManager.getContext("authentication");
-		} catch (Exception e) {
-		    return null;
-		}
-
-        if(!key.startsWith("/"))
+        if (!key.startsWith("/")) {
     		key = "/" + key;
-    	DocumentFragment node = null;
-        try {
-            node = ctx.getXML("/portalTools" + key);
-        } catch (Exception e) {
-            // TODO
         }
-        return org.apache.cocoon.xml.dom.DOMUtil.getValueOfNode(node);
+        key = this.getClass().getName() + key;
+        return (String)this.service.getAttribute(key);
     }
 
     /**
@@ -261,26 +248,10 @@
      * @param value Value
      */
     public void sSet(String key, String value) {
-        SessionContext ctx;
-        try {
-            ctx = this.contextManager.getContext("authentication");
-        } catch (Exception e) {
-            return;
-        }
-
-        if(!key.startsWith("/"))
-    		key = "/" + key;
-        DocumentFragment frag;
-        try {
-            frag = ctx.getXML("/");
-            org.w3c.dom.Document doc = frag.getOwnerDocument();
-            DocumentFragment newFrag = doc.createDocumentFragment();
-            Text txt = doc.createTextNode(value);
-            newFrag.appendChild(txt);
-            ctx.setXML("/portalTools" + key, newFrag);
-        } catch (ProcessingException e) {
-            // TODO
+        if (!key.startsWith("/")) {
+            key = "/" + key;
         }
+        this.service.setAttribute(key, value);
     }
 
     /**
@@ -289,9 +260,9 @@
     public void dispose() {
         if ( this.manager != null ) {
             this.manager.release(this.resolver);
-            this.manager.release(this.contextManager);
+            this.manager.release(this.service);
             this.resolver = null;
-            this.contextManager = null;
+            this.service = null;
             this.manager = null;
         }
     }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/userManagement/ContextGrabber.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/userManagement/ContextGrabber.java?rev=321120&r1=321119&r2=321120&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/userManagement/ContextGrabber.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/tools/userManagement/ContextGrabber.java
Fri Oct 14 06:57:11 2005
@@ -15,9 +15,10 @@
  */
 package org.apache.cocoon.portal.tools.userManagement;
 
-import org.apache.cocoon.webapps.authentication.context.AuthenticationContext;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Node;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.cocoon.portal.PortalService;
 
 /**
  * Grabbing the context of an user, which is set in the file sunrise-user.xml
@@ -30,34 +31,17 @@
 	/**
 	 * Grabbing the context of the current user
 	 *
-	 * @param context the instantiated class AuthenticationContext
 	 * @return Object of context information
 	 */
-	public UserBean grab (AuthenticationContext context) {
+	public UserBean grab(PortalService service) {
 		UserBean ub = new UserBean ();
-		DocumentFragment df = null;
-		try {
-			df = context.getXML ("/authentication/");
-		} catch (Exception e) {
-            // we ignore it for now
+        final Map infos = service.getComponentManager().getProfileManager().getUser().getUserInfos();
+        final Iterator i = infos.entrySet().iterator();
+        while ( i.hasNext() ) {
+            final Map.Entry current = (Map.Entry)i.next();
+            ub.addContext(current.getKey().toString(), current.getValue().toString());
         }
 
-		grabAuthContext (df.getFirstChild(),ub);
-
 		return ub;
-	}
-
-	private void grabAuthContext (Node node, UserBean ub) {
-		while (node != null) {
-			if (!node.getNodeName().equals("#text")) {
-				if (node.getFirstChild() != null) {
-					grabAuthContext  (node.getFirstChild () ,ub);
-					ub.addContext(node.getNodeName(),node.getFirstChild().getNodeValue());
-				} else {
-					ub.addContext(node.getNodeName(),"");
-                }
-			}
-			node = node.getNextSibling();
-		}
 	}
 }



Mime
View raw message