svn commit: r894961 [2/4] - in /ofbiz/branches/executioncontext20091231: ./ applications/accounting/ applications/accounting/data/ applications/content/ applications/content/data/ applications/humanres/data/ applications/manufacturing/ applications/man...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r894961 [2/4] - in /ofbiz/branches/executioncontext20091231: ./ applications/accounting/ applications/accounting/data/ applications/content/ applications/content/data/ applications/humanres/data/ applications/manufacturing/ applications/man...

adrianc
Added: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContext.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContext.java?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContext.java (added)
+++ ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContext.java Fri Jan  1 00:38:52 2010
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.api.context;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.ofbiz.api.authorization.AccessController;
+import org.ofbiz.api.authorization.AuthorizationManager;
+
+
+/** ExecutionContext interface. The <code>ExecutionContext</code> is a container
+ * for frequently used objects, plus it keeps track of the program's
+ * execution path. <p>As an object container, the <code>ExecutionContext</code>
+ * simplifies framework code - since only one oject needs to be
+ * passed around instead of five or six.</p><p>The <code>ExecutionContext</code>
+ * depends on the artifacts in the program's execution path to implement
+ * the <code>ExecutionArtifact</code> interface, or if that is not possible,
+ * to use a <code>GenericExecutionArtifact</code> instance. At the start of
+ * each method, the artifact calls <code>pushExecutionArtifact</code>, and
+ * as each method exits the artifact calls <code>popExecutionArtifact</code>.
+ * Implementations of this interface will pass the current execution path
+ * to the Authorization Manager so the proper user permissions can be
+ * retrieved for the current artifact.</p>
+ *
+ * @see org.ofbiz.api.context.ExecutionArtifact
+ * @see org.ofbiz.api.context.GenericExecutionArtifact
+ */
+public interface ExecutionContext {
+
+    /** Returns an <code>AccessController</code> instance for this
+     * user login and execution path combination.
+     *
+     * @return An <code>AccessController</code> instance
+     */
+    public AccessController getAccessController();
+
+    /** Returns the currency unit of measure.
+     *
+     * @return The ISO currency code
+     */
+    public String getCurrencyUom();
+
+    /** Returns the current execution path. Artifacts in the path are separated
+     * with a forward slash.
+     *
+     * @return The current execution path
+     */
+    public String getExecutionPath();
+
+    /** Returns the current <code>Locale</code>.
+     *
+     * @return The current <code>Locale</code>
+     */
+    public Locale getLocale();
+
+    /**
+ * Returns the parameters associated with this context.
+ *
+ * @return The parameters associated with this context
+ */
+ public Map<String, ? extends Object> getParameters();
+
+    /** Returns the specified property.
+     *
+     * @param key property whose associated value is to be returned
+     * @return the specified property, or null if the property doesn't exist
+     */
+    public Object getProperty(String key);
+
+    /** Returns the current <code>AuthorizationManager</code> instance.
+     *
+     * @return The current <code>AuthorizationManager</code> instance
+     */
+    public AuthorizationManager getSecurity();
+
+    /** Returns the current <code>TimeZone</code>.
+     *
+     * @return The current <code>TimeZone</code>
+     */
+    public TimeZone getTimeZone();
+
+    /** Initializes this ExecutionContext with artifacts found in
+     * <code>params</code>.
+     *
+     * @param params
+     */
+    public void initializeContext(Map<String, ? extends Object> params);
+
+    /** Pop an <code>ExecutionArtifact</code> off the stack. */
+    public void popExecutionArtifact();
+
+    /** Push an <code>ExecutionArtifact</code> on the stack.
+     *
+     * @param artifact
+     */
+    public void pushExecutionArtifact(ExecutionArtifact artifact);
+
+    /**
+     * Resets this <code>ExecutionContext</code> to its default
+     * state. This method is called when an <code>ExecutionContext</code>
+     * instance is about to be reused.
+     */
+    public void reset();
+
+    /** Sets the currency unit of measure.
+     *
+     * @param currencyUom The ISO currency code
+     */
+    public void setCurrencyUom(String currencyUom);
+
+    /** Sets the current <code>Locale</code>.
+     *
+     * @param locale The current <code>Locale</code>
+     */
+    public void setLocale(Locale locale);
+
+    /** Associates the specified value with the specified key.
+     * If the context contained a previous property for this key,
+     * then the old value is replaced by the specified value.
+     *
+     * @param key the key with which the specified value is to be associated
+     * @param value the value to be associated with the specified key
+     * @return the previous value associated with specified key, or null  if there was no mapping for key
+     */
+    public Object setProperty(String key, Object value);
+
+    /** Sets the current <code>AuthorizationManager</code> instance.
+     *
+     * @param security The new <code>AuthorizationManager</code> instance
+     */
+    public void setSecurity(AuthorizationManager security);
+
+    /** Sets the current <code>TimeZone</code>.
+     *
+     * @param timeZone The current <code>TimeZone</code>
+     */
+    public void setTimeZone(TimeZone timeZone);
+}

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContext.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContextImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContextImpl.java?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContextImpl.java (added)
+++ ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContextImpl.java Fri Jan  1 00:38:52 2010
@@ -0,0 +1,175 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.api.context;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
+
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilProperties;
+
+/** Implementation of the ExecutionContext interface. */
+public abstract class ExecutionContextImpl implements ExecutionContext {
+
+    public static final String module = ExecutionContextImpl.class.getName();
+
+    protected final FastList<ExecutionArtifact> artifactStack = FastList.newInstance();
+ protected String currencyUom = null;
+ protected Locale locale = Locale.getDefault();
+ protected TimeZone timeZone = TimeZone.getDefault();
+ protected final Map<String, Object> properties;
+ // Temporary - will be removed later
+ protected boolean verbose = false;
+
+ protected ExecutionContextImpl() {
+    this.properties = FastMap.newInstance();
+    this.verbose = "true".equals(UtilProperties.getPropertyValue("api.properties", "executionContext.verbose"));
+ }
+
+    protected ExecutionContextImpl(Map<String, Object> properties) {
+        this.properties = properties;
+        this.verbose = "true".equals(UtilProperties.getPropertyValue("api.properties", "executionContext.verbose"));
+    }
+
+    @Override
+    protected void finalize() throws Throwable {
+        if (this.artifactStack.size() > 0) {
+            // This check is temporary - it will be removed when implementation is complete
+            Debug.logError(new Exception("finalize() called with a stack that is not empty"), module);
+            return;
+        }
+        super.finalize();
+    }
+
+    public String getCurrencyUom() {
+        return this.currencyUom;
+    }
+
+ public String getExecutionPath() {
+ StringBuilder sb = new StringBuilder("ofbiz");
+ for (ExecutionArtifact artifact : this.artifactStack) {
+ sb.append("/");
+ sb.append(artifact.getName() == null ? "null" : artifact.getName());
+ }
+ return sb.toString();
+ }
+
+ public Locale getLocale() {
+        return this.locale;
+    }
+
+    public Map<String, ? extends Object> getParameters() {
+     for (int i = this.artifactStack.size() - 1; i >= 0; i--) {
+     try {
+     ParametersArtifact artifact = (ParametersArtifact) this.artifactStack.get(i);
+     return artifact.getParameters();
+     } catch (Exception e) {}
+     }
+ return null;
+ }
+
+ public Object getProperty(String key) {
+        return this.properties.get(key);
+    }
+
+    public TimeZone getTimeZone() {
+        return this.timeZone;
+    }
+
+    public void popExecutionArtifact() {
+     if (this.artifactStack.size() == 0) {
+     // This check is temporary - it will be removed when implementation is complete
+     Debug.logError(new Exception("Attempt to pop an empty stack"), module);
+     return;
+     }
+    ExecutionArtifact artifact = this.artifactStack.removeLast();
+    if (this.verbose) {
+     Debug.logInfo("Popping artifact [" + artifact.getClass().getName() +
+     "] location = " + artifact.getLocation() +
+     ", name = " + artifact.getName(), module);
+    }
+ }
+
+    public void pushExecutionArtifact(ExecutionArtifact artifact) {
+ this.artifactStack.addLast(artifact);
+ if (this.verbose) {
+ Debug.logInfo("Pushing artifact [" + artifact.getClass().getName() +
+ "] location = " + artifact.getLocation() +
+ ", name = " + artifact.getName(), module);
+ }
+ }
+
+    public void reset() {
+        if (this.verbose) {
+            Debug.logInfo("Resetting ExecutionContext", module);
+        }
+        this.artifactStack.clear();
+        this.currencyUom = "";
+        this.locale = Locale.getDefault();
+        this.properties.clear();
+        this.timeZone = TimeZone.getDefault();
+    }
+
+    public void setCurrencyUom(String currencyUom) {
+        if (currencyUom != null) {
+            this.currencyUom = currencyUom;
+        }
+    }
+
+    public void setLocale(Locale locale) {
+        if (locale != null) {
+            this.locale = locale;
+        }
+    }
+
+    protected void setLocale(String locale) {
+        if (locale != null) {
+            this.locale = new Locale(locale);
+        } else {
+            this.locale = Locale.getDefault();
+        }
+    }
+
+    public Object setProperty(String key, Object value) {
+        return this.properties.put(key, value);
+    }
+
+    public void setTimeZone(TimeZone timeZone) {
+        if (timeZone != null) {
+            this.timeZone = timeZone;
+        }
+    }
+
+    protected void setTimeZone(String timeZone) {
+        if (timeZone != null) {
+            this.timeZone = TimeZone.getTimeZone(timeZone);
+        } else {
+            this.timeZone = TimeZone.getDefault();
+        }
+    }
+
+    @Override
+ public String toString() {
+ return this.getExecutionPath();
+ }
+}

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContextImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContextImpl.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ExecutionContextImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericExecutionArtifact.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericExecutionArtifact.java?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericExecutionArtifact.java (added)
+++ ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericExecutionArtifact.java Fri Jan  1 00:38:52 2010
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.api.context;
+
+/** A basic implementation of the <code>ExecutionArtifact</code> interface. */
+public class GenericExecutionArtifact implements ExecutionArtifact {
+
+ protected final String location;
+ protected final String name;
+
+ public GenericExecutionArtifact(String location, String name) {
+ this.location = location;
+ this.name = name;
+ }
+
+ public String getLocation() {
+ return this.location;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public String toString() {
+ return "GenericExecutionArtifact: location = " + this.location + ", name = " + this.name;
+ }
+}

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericExecutionArtifact.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericExecutionArtifact.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericExecutionArtifact.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericParametersArtifact.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericParametersArtifact.java?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericParametersArtifact.java (added)
+++ ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericParametersArtifact.java Fri Jan  1 00:38:52 2010
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.api.context;
+
+import java.util.Map;
+
+/** A basic implementation of the ParametersArtifact interface. */
+public class GenericParametersArtifact extends GenericExecutionArtifact implements ParametersArtifact {
+
+ protected final Map<String, ? extends Object> parameters;
+
+ public GenericParametersArtifact(String location, String name, Map<String, ? extends Object> parameters) {
+ super(location, name);
+ this.parameters = parameters;
+ }
+
+ public GenericParametersArtifact(ExecutionArtifact artifact, Map<String, ? extends Object> parameters) {
+ super(artifact.getLocation(), artifact.getName());
+ this.parameters = parameters;
+ }
+
+ public Map<String, ? extends Object> getParameters() {
+ return this.parameters;
+ }
+
+ @Override
+ public String toString() {
+ return "GenericParametersArtifact: location = " + this.location + ", name = " + this.name;
+ }
+}

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericParametersArtifact.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericParametersArtifact.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/GenericParametersArtifact.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ParametersArtifact.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ParametersArtifact.java?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ParametersArtifact.java (added)
+++ ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ParametersArtifact.java Fri Jan  1 00:38:52 2010
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.api.context;
+
+import java.util.Map;
+
+/** ParametersArtifact interface. This interface extends
+ * <code>ExecutionArtifact</code> and adds the ability to
+ * contain a parameter <code>Map</code>.<p>The purpose of this
+ * class is to provide a way for the <code>ExecutionContext</code>
+ * to keep track of what parameters are the most recent. For
+ * example: Service A calls Service B. Service A has one set of
+ * parameters, and Service B has another set of parameters. During
+ * program execution, Service A creates a <code>ParametersArtifact</code>
+ * instance that contains the service's parameters, then pushes that
+ * instance on the <code>ExecutionContext</code> stack. When Service B
+ * is called, it does the same thing. When framework code needs to
+ * access the current parameters, it calls
+ * <code>ExecutionContext.getParameters()</code>. The <code>ExecutionContext</code>
+ * will search its stack for the first <code>ParametersArtifact</code> instance -
+ * starting at the top of the stack, and return that instance.</p>
+ */
+public interface ParametersArtifact extends ExecutionArtifact {
+
+ /**
+ * Returns the parameters associated with this artifact.
+ *
+ * @return The parameters associated with this artifact
+ */
+ public Map<String, ? extends Object> getParameters();
+
+}

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ParametersArtifact.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ParametersArtifact.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ParametersArtifact.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ThreadContext.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ThreadContext.java?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ThreadContext.java (added)
+++ ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ThreadContext.java Fri Jan  1 00:38:52 2010
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.api.context;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.ofbiz.api.authorization.AccessController;
+import org.ofbiz.api.authorization.AuthorizationManager;
+import org.ofbiz.api.authorization.NullAuthorizationManager;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilProperties;
+
+/** A convenience class for accessing the current thread's <code>ExecutionContext</code>.
+ * @see {@link org.ofbiz.service.ExecutionContext}
+ */
+public class ThreadContext {
+
+    protected static final String module = ThreadContext.class.getName();
+    protected static final AuthorizationManager nullAuthorizationManager = new NullAuthorizationManager();
+
+    protected static final ThreadLocal<ExecutionContext> executionContext = new ThreadLocal<ExecutionContext>() {
+        protected synchronized ExecutionContext initialValue() {
+            ExecutionContext result = null;
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            String className = UtilProperties.getPropertyValue("api.properties", "executionContext.class");
+            try {
+                result = (ExecutionContext) loader.loadClass(className).newInstance();
+            } catch (Exception e) {
+                Debug.logError(e, module);
+            }
+            return result;
+        }
+    };
+
+    /** Used by <code>runUnprotected</code> and <code>endRunUnprotected</code>
+     * to save/restore the original <code>AuthorizationManager</code> instance.
+     */
+    protected static final ThreadLocal<AuthorizationManager> authManager = new ThreadLocal<AuthorizationManager>() {
+        protected synchronized AuthorizationManager initialValue() {return null;};
+    };
+
+    public static void endRunUnprotected() {
+        AuthorizationManager savedAuthorizationManager = authManager.get();
+        if (savedAuthorizationManager != null) {
+            setSecurity(savedAuthorizationManager);
+            authManager.set(null);
+        }
+    }
+
+    public static AccessController getAccessController() {
+        return executionContext.get().getAccessController();
+    }
+
+    public static String getCurrencyUom() {
+        return executionContext.get().getCurrencyUom();
+    }
+
+    public static String getExecutionPath() {
+        return executionContext.get().getExecutionPath();
+    }
+
+    public static Locale getLocale() {
+        return executionContext.get().getLocale();
+    }
+
+    public static Map<String, ? extends Object> getParameters() {
+        return executionContext.get().getParameters();
+    }
+
+    public static Object getProperty(String key) {
+        return executionContext.get().getProperty(key);
+    }
+
+    public static AuthorizationManager getSecurity() {
+        return executionContext.get().getSecurity();
+    }
+
+    public static TimeZone getTimeZone() {
+        return executionContext.get().getTimeZone();
+    }
+
+    public static void initializeContext(Map<String, ? extends Object> params) {
+        executionContext.get().initializeContext(params);
+    }
+
+    public static void popExecutionArtifact() {
+        executionContext.get().popExecutionArtifact();
+    }
+
+    public static void pushExecutionArtifact(ExecutionArtifact artifact) {
+        executionContext.get().pushExecutionArtifact(artifact);
+    }
+
+    public static void pushExecutionArtifact(ExecutionArtifact artifact, Map<String, ? extends Object> parameters) {
+        pushExecutionArtifact(new GenericParametersArtifact(artifact, parameters));
+    }
+
+    public static void pushExecutionArtifact(String location, String name) {
+        pushExecutionArtifact(new GenericExecutionArtifact(location, name));
+    }
+
+    public static void pushExecutionArtifact(String location, String name, Map<String, ? extends Object> parameters) {
+        pushExecutionArtifact(new GenericParametersArtifact(location, name, parameters));
+    }
+
+    public static void reset() {
+        executionContext.get().reset();
+    }
+
+    public static void runUnprotected() {
+        authManager.set(getSecurity());
+        setSecurity(nullAuthorizationManager);
+    }
+
+    public static void setCurrencyUom(String currencyUom) {
+        executionContext.get().setCurrencyUom(currencyUom);
+    }
+
+    public static void setLocale(Locale locale) {
+        executionContext.get().setLocale(locale);
+    }
+
+    public static Object setProperty(String key, Object value) {
+        return executionContext.get().setProperty(key, value);
+    }
+
+    public static void setSecurity(AuthorizationManager security) {
+        executionContext.get().setSecurity(security);
+    }
+
+    public static void setTimeZone(TimeZone timeZone) {
+        executionContext.get().setTimeZone(timeZone);
+    }
+
+}

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ThreadContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ThreadContext.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20091231/framework/api/src/org/ofbiz/api/context/ThreadContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/branches/executioncontext20091231/framework/bi/build.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/bi/build.xml?rev=894961&r1=894960&r2=894961&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/bi/build.xml (original)
+++ ofbiz/branches/executioncontext20091231/framework/bi/build.xml Fri Jan  1 00:38:52 2010
@@ -29,6 +29,7 @@
     <property name="name" value="ofbiz-bi"/>
 
     <path id="local.class.path">
+        <fileset dir="../../framework/api/build/lib" includes="*.jar"/>
         <fileset dir="../../framework/base/lib" includes="*.jar"/>
         <fileset dir="../../framework/base/lib/commons" includes="*.jar"/>
         <fileset dir="../../framework/base/lib/j2eespecs" includes="*.jar"/>

Modified: ofbiz/branches/executioncontext20091231/framework/build.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/build.xml?rev=894961&r1=894960&r2=894961&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/build.xml (original)
+++ ofbiz/branches/executioncontext20091231/framework/build.xml Fri Jan  1 00:38:52 2010
@@ -22,10 +22,10 @@
     <import file="../macros.xml"/>
 
     <filelist id="framework-builds" dir="."
-        files="start/build.xml,base/build.xml,sql/build.xml,
+        files="start/build.xml,base/build.xml,api/build.xml,sql/build.xml,
                entity/build.xml,geronimo/build.xml,
                catalina/build.xml,jetty/build.xml,
-               security/build.xml,service/build.xml,entityext/build.xml,
+               security/build.xml,service/build.xml,context/build.xml,entityext/build.xml,
                webslinger/build.xml,
                bi/build.xml,minilang/build.xml,
                webapp/build.xml,guiapp/build.xml,widget/build.xml,

Modified: ofbiz/branches/executioncontext20091231/framework/common/build.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/common/build.xml?rev=894961&r1=894960&r2=894961&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/common/build.xml (original)
+++ ofbiz/branches/executioncontext20091231/framework/common/build.xml Fri Jan  1 00:38:52 2010
@@ -30,6 +30,7 @@
     <property name="ofbiz.home.dir" value="../.."/>
 
     <path id="local.class.path">
+        <fileset dir="../api/build/lib" includes="*.jar"/>
         <fileset dir="../base/lib" includes="*.jar"/>
         <fileset dir="../base/lib/commons" includes="*.jar"/>
         <fileset dir="../base/lib/j2eespecs" includes="*.jar"/>

Modified: ofbiz/branches/executioncontext20091231/framework/common/src/org/ofbiz/common/login/LoginServices.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/common/src/org/ofbiz/common/login/LoginServices.java?rev=894961&r1=894960&r2=894961&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/common/src/org/ofbiz/common/login/LoginServices.java (original)
+++ ofbiz/branches/executioncontext20091231/framework/common/src/org/ofbiz/common/login/LoginServices.java Fri Jan  1 00:38:52 2010
@@ -53,6 +53,7 @@
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ModelService;
 import org.ofbiz.service.ServiceUtil;
+import org.ofbiz.service.ThreadContext;
 import org.ofbiz.webapp.control.LoginWorker;
 
 /**
@@ -233,6 +234,7 @@
                             }
 
                             successfulLogin = "Y";
+                            ThreadContext.setUserLogin(userLogin);
 
                             if (!isServiceAuth) {
                                 // get the UserLoginSession if this is not a service auth
@@ -410,6 +412,7 @@
                         userLogin.set("userLoginId", username);
                         userLogin.set("enabled", "Y");
                         userLogin.set("hasLoggedOut", "N");
+                        ThreadContext.setUserLogin(userLogin);
                         result.put("userLogin", userLogin);
                         result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS);
                         //TODO: more than this is needed to support 100% external authentication

Modified: ofbiz/branches/executioncontext20091231/framework/component-load.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/component-load.xml?rev=894961&r1=894960&r2=894961&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/component-load.xml (original)
+++ ofbiz/branches/executioncontext20091231/framework/component-load.xml Fri Jan  1 00:38:52 2010
@@ -20,6 +20,8 @@
 
 <component-loader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/component-loader.xsd">
+    <load-component component-location="api"/>
+    <load-component component-location="context"/>
     <load-component component-location="geronimo"/>
     <load-component component-location="sql"/>
     <load-component component-location="entity"/>

Added: ofbiz/branches/executioncontext20091231/framework/context/build.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/context/build.xml?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/context/build.xml (added)
+++ ofbiz/branches/executioncontext20091231/framework/context/build.xml Fri Jan  1 00:38:52 2010
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project name="OFBiz - Execution Context" default="jar" basedir=".">
+    <import file="../../common.xml"/>
+
+    <!-- ================================================================== -->
+    <!-- Initialization of all property settings                            -->
+    <!-- ================================================================== -->
+
+    <property name="name" value="ofbiz-context"/>
+    <property name="ofbiz.home.dir" value="../.."/>
+
+    <path id="local.class.path">
+        <fileset dir="../api/build/lib" includes="*.jar"/>
+        <fileset dir="${lib.dir}" includes="*.jar"/>
+        <fileset dir="../base/lib" includes="*.jar"/>
+        <fileset dir="../base/lib/commons" includes="*.jar"/>
+        <fileset dir="../base/lib/j2eespecs" includes="*.jar"/>
+        <fileset dir="../base/lib/scripting" includes="*.jar"/>
+        <fileset dir="../base/build/lib" includes="*.jar"/>
+        <fileset dir="../entity/build/lib" includes="*.jar"/>
+        <fileset dir="../security/build/lib" includes="*.jar"/>
+        <fileset dir="../service/build/lib" includes="*.jar"/>
+    </path>
+
+    <!-- ================================================================== -->
+    <!-- Compilation of the source files                                    -->
+    <!-- ================================================================== -->
+
+    <target name="jar" depends="classes">
+        <jar jarfile="${build.dir}/lib/${name}.jar">
+            <fileset dir="${build.dir}/classes"/>
+            <fileset dir="${src.dir}">
+                <include name="**/*.properties,**/*.xml,**/*.bsh,**/*.logic,**/*.js,**/*.jacl,**/*.py"/>
+                <include name="META-INF/**"/>
+            </fileset>
+            <!-- now add the NOTICE and LICENSE files to allow the jar file to be distributed alone -->
+            <zipfileset dir="${ofbiz.home.dir}" prefix="META-INF" includes="NOTICE,LICENSE"/>
+        </jar>
+    </target>
+
+    <!-- ================================================================== -->
+    <!-- Build JavaDoc                                                      -->
+    <!-- ================================================================== -->
+
+    <target name="docs" depends="prepare-docs">
+        <javadoc packagenames="org.ofbiz.base.*"
+                 classpathref="local.class.path"
+                 destdir="${build.dir}/javadocs"
+                 Windowtitle="Open for Business - Execution Context">
+            <sourcepath path="${src.dir}"/>
+        </javadoc>
+    </target>
+</project>

Added: ofbiz/branches/executioncontext20091231/framework/context/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/context/ofbiz-component.xml?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/context/ofbiz-component.xml (added)
+++ ofbiz/branches/executioncontext20091231/framework/context/ofbiz-component.xml Fri Jan  1 00:38:52 2010
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<ofbiz-component name="context"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
+    <resource-loader name="main" type="component"/>
+    <classpath type="jar" location="build/lib/*"/>
+    <classpath type="dir" location="config"/>
+    <classpath type="jar" location="lib/*"/>
+</ofbiz-component>

Added: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java (added)
+++ ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java Fri Jan  1 00:38:52 2010
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.context;
+
+import java.security.AccessControlException;
+import java.security.Permission;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+import javolution.util.FastMap;
+
+import org.ofbiz.api.authorization.AccessController;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.entity.util.EntityListIterator;
+import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.ThreadContext;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ModelService;
+
+/** An implementation of the <code>AccessController</code> interface. */
+public class AccessControllerImpl implements AccessController {
+
+    public static final String module = AccessControllerImpl.class.getName();
+
+    protected final OFBizPermission permission;
+    protected final PathNode node;
+    // Temporary - will be removed later
+    protected boolean verbose = false;
+    protected boolean disabled = false;
+
+    protected AccessControllerImpl(PathNode node) {
+        this.node = node;
+        this.permission = new OFBizPermission(ThreadContext.getUserLogin().getString("userLoginId"));
+        this.verbose = "true".equals(UtilProperties.getPropertyValue("api.properties", "authorizationManager.verbose"));
+        this.disabled = "true".equals(UtilProperties.getPropertyValue("api.properties", "authorizationManager.disabled"));
+    }
+
+    public void checkPermission(Permission permission) throws AccessControlException {
+        if (this.verbose) {
+            Debug.logInfo("Checking permission: " + ThreadContext.getExecutionPath() + "[" + permission + "]", module);
+        }
+        this.permission.reset();
+        this.node.getPermissions(ThreadContext.getExecutionPath(), this.permission);
+        if (this.verbose) {
+            Debug.logInfo("Found permission(s): " + ThreadContext.getUserLogin().getString("userLoginId") +
+                    "@" + ThreadContext.getExecutionPath() + "[" + this.permission + "]", module);
+        }
+        if (this.disabled) {
+            return;
+        }
+        if (this.permission.implies(permission) && this.hasServicePermission()) {
+            return;
+        }
+        throw new AccessControlException(ThreadContext.getUserLogin().getString("userLoginId") +
+                "@" + ThreadContext.getExecutionPath() + "[" + permission + "]");
+    }
+
+    public <E> List<E> applyFilters(List<E> list) {
+        if (this.permission.getFilterNames().size() > 0) {
+            return new SecurityAwareList<E>(list, this.permission.getFilterNames());
+        }
+        return list;
+    }
+
+    public <E> ListIterator<E> applyFilters(ListIterator<E> listIterator) {
+        if (listIterator instanceof EntityListIterator) {
+            // Decorating the EntityListIterator breaks a lot of code.
+            return listIterator;
+        }
+        if (this.permission.getFilterNames().size() > 0) {
+            return new SecurityAwareListIterator<E>(listIterator, this.permission.getFilterNames());
+        }
+        return listIterator;
+    }
+
+    protected boolean hasServicePermission() {
+        try {
+            if (this.permission.getServiceNames().size() == 0) {
+                return true;
+            }
+            LocalDispatcher dispatcher = ThreadContext.getDispatcher();
+            DispatchContext ctx = dispatcher.getDispatchContext();
+            Map<String, ? extends Object> params = ThreadContext.getParameters();
+            for (String serviceName : this.permission.getServiceNames()) {
+                ModelService modelService = ctx.getModelService(serviceName);
+                Map<String, Object> context = FastMap.newInstance();
+                if (params != null) {
+                    context.putAll(params);
+                }
+                if (!context.containsKey("userLogin")) {
+                    context.put("userLogin", ThreadContext.getUserLogin());
+                }
+                if (!context.containsKey("locale")) {
+                    context.put("locale", ThreadContext.getLocale());
+                }
+                if (!context.containsKey("timeZone")) {
+                    context.put("timeZone", ThreadContext.getTimeZone());
+                }
+                context = modelService.makeValid(context, ModelService.IN_PARAM);
+                Map<String, Object> result = dispatcher.runSync(serviceName, context);
+                Boolean hasPermission = (Boolean) result.get("hasPermission");
+                if (hasPermission != null && !hasPermission.booleanValue()) {
+                    return false;
+                }
+            }
+        } catch (Exception e) {
+            Debug.logError(e, module);
+        }
+        return true;
+    }
+}

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java (added)
+++ ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java Fri Jan  1 00:38:52 2010
@@ -0,0 +1,221 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.context;
+
+import java.security.AccessControlException;
+import java.security.Permission;
+import java.util.List;
+import java.util.Map;
+
+import javolution.util.FastMap;
+
+import org.ofbiz.api.authorization.AccessController;
+import org.ofbiz.api.authorization.BasicPermissions;
+import org.ofbiz.api.authorization.AuthorizationManager;
+import org.ofbiz.api.authorization.NullAuthorizationManager;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.condition.EntityCondition;
+//import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.cache.UtilCache;
+import org.ofbiz.security.OFBizSecurity;
+import org.ofbiz.service.ThreadContext;
+
+/**
+ * An implementation of the AuthorizationManager interface that uses the OFBiz database
+ * for authorization data storage.
+ */
+public class AuthorizationManagerImpl extends OFBizSecurity implements AuthorizationManager {
+
+    // Right now this class implements permission checking only.
+
+    public static final String module = AuthorizationManagerImpl.class.getName();
+//    protected static final UtilCache<String, PathNode> userPermCache = UtilCache.createUtilCache("authorization.UserPermissions");
+    protected static final Map<String, PathNode> userPermCache = FastMap.newInstance();
+    protected static final AuthorizationManager nullAuthorizationManager = new NullAuthorizationManager();
+    protected static boolean underConstruction = false;
+
+    public AuthorizationManagerImpl() {
+    }
+
+ public void assignGroupPermission(String userGroupId, String artifactId, Permission permission) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void assignGroupToGroup(String childGroupId, String parentGroupId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void assignUserPermission(String userLoginId, String artifactId, Permission permission) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void assignUserToGroup(String userLoginId, String userGroupId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void createUser(String userLoginId, String password) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public String createUserGroup(String description) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void deleteGroupFromGroup(String childGroupId, String parentGroupId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deleteGroupPermission(String userGroupId, String artifactId, Permission permission) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deleteUser(String userLoginId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deleteUserFromGroup(String userLoginId, String userGroupId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deleteUserGroup(String userGroupId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deleteUserPermission(String userLoginId, String artifactId, Permission permission) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateUser(String userLoginId, String password) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void updateUserGroup(String userGroupId, String description) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+    public void clearUserData(GenericValue userLogin) {
+        super.clearUserData(userLogin);
+        userPermCache.remove(userLogin.getString("userLogin"));
+    }
+
+    public AccessController getAccessController() throws AccessControlException {
+        String userLoginId = ThreadContext.getUserLogin().getString("userLoginId");
+        PathNode node = getUserPermissionsNode(userLoginId);
+        if (node == null) {
+            // During object construction, artifacts will be used that will ultimately
+            // call this method. In order for object construction to succeed, we need
+            // to allow unrestricted access to all artifacts.
+            return nullAuthorizationManager.getAccessController();
+        }
+        return new AccessControllerImpl(getUserPermissionsNode(userLoginId));
+ }
+
+    protected static PathNode getUserPermissionsNode(String userLoginId) throws AccessControlException {
+        if (underConstruction) {
+            return null;
+        }
+        PathNode node = userPermCache.get(userLoginId);
+        if (node != null) {
+            return node;
+        }
+        synchronized (userPermCache) {
+            underConstruction = true;
+            node = new PathNode();
+            // Set up the ExecutionContext for unrestricted access to security-aware artifacts
+            ThreadContext.runUnprotected();
+            Delegator delegator = ThreadContext.getDelegator();
+            try {
+                // Process group membership permissions first
+                List<GenericValue> groupMemberships = delegator.findList("UserToUserGroupRel", EntityCondition.makeCondition(UtilMisc.toMap("userLoginId", userLoginId)), null, null, null, false);
+                for (GenericValue userGroup : groupMemberships) {
+                    processGroupPermissions(userGroup.getString("groupId"), node, delegator);
+                }
+                // Process user permissions last
+                List<GenericValue> permissionValues = delegator.findList("UserToArtifactPermRel", EntityCondition.makeCondition(UtilMisc.toMap("userLoginId", userLoginId)), null, null, null, false);
+                setPermissions(userLoginId, node, permissionValues);
+                userPermCache.put(userLoginId, node);
+            } catch (GenericEntityException e) {
+                throw new AccessControlException(e.getMessage());
+            } finally {
+                ThreadContext.endRunUnprotected();
+                underConstruction = false;
+            }
+        }
+    return node;
+ }
+
+    protected static void processGroupPermissions(String groupId, PathNode node, Delegator delegator) throws AccessControlException {
+        try {
+            // Process this group's memberships first
+            List<GenericValue> parentGroups = delegator.findList("UserGroupRelationship", EntityCondition.makeCondition(UtilMisc.toMap("toGroupId", groupId)), null, null, null, false);
+            for (GenericValue parentGroup : parentGroups) {
+                processGroupPermissions(parentGroup.getString("fromGroupId"), node, delegator);
+            }
+            // Process this group's permissions
+            List<GenericValue> permissionValues = delegator.findList("UserGrpToArtifactPermRel", EntityCondition.makeCondition(UtilMisc.toMap("groupId", groupId)), null, null, null, false);
+            setPermissions(groupId, node, permissionValues);
+        } catch (GenericEntityException e) {
+            throw new AccessControlException(e.getMessage());
+        }
+    }
+
+    protected static void setPermissions(String id, PathNode node, List<GenericValue> permissionValues) {
+        for (GenericValue value : permissionValues) {
+            String artifactPath = value.getString("artifactPath");
+            OFBizPermission target = new OFBizPermission(id + "@" + artifactPath);
+            String[] pair = value.getString("permissionValue").split("=");
+            if ("filter".equalsIgnoreCase(pair[0])) {
+                target.filters.add(pair[1]);
+            } else if ("service".equalsIgnoreCase(pair[0])) {
+                target.services.add(pair[1]);
+            } else {
+                Permission permission = BasicPermissions.ConversionMap.get(pair[0].toUpperCase());
+                if (permission != null) {
+                    if ("true".equalsIgnoreCase(pair[1])) {
+                        target.includePermissions.getPermissionsSet().add(permission);
+                    } else {
+                        target.excludePermissions.getPermissionsSet().add(permission);
+                    }
+                } else {
+                    throw new AccessControlException("Invalid permission: " + pair[0]);
+                }
+            }
+            node.setPermissions(artifactPath, target);
+        }
+    }
+
+}

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java (added)
+++ ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java Fri Jan  1 00:38:52 2010
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.context;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.ofbiz.api.authorization.AccessController;
+import org.ofbiz.api.authorization.AuthorizationManager;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.entity.DelegatorFactory;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.service.ExecutionContext;
+import org.ofbiz.service.GenericDispatcher;
+import org.ofbiz.service.LocalDispatcher;
+
+/** An implementation of the <code>ExecutionContext</code> interface. */
+public class ExecutionContextImpl extends org.ofbiz.api.context.ExecutionContextImpl implements ExecutionContext {
+
+    public static final String module = ExecutionContextImpl.class.getName();
+    protected Delegator delegator = null;
+    protected LocalDispatcher dispatcher = null;
+    protected AuthorizationManager security = null;
+    protected GenericValue userLogin = null;
+
+ public AccessController getAccessController() {
+        return (AccessController) this.getSecurity().getAccessController();
+ }
+
+ public Delegator getDelegator() {
+ if (this.delegator == null) {
+ this.delegator = DelegatorFactory.getDelegator("default");
+ }
+ return this.delegator;
+ }
+
+ public LocalDispatcher getDispatcher() {
+ if (this.dispatcher == null) {
+        this.dispatcher = GenericDispatcher.getLocalDispatcher("ExecutionContext", this.getDelegator());
+ }
+ return this.dispatcher;
+ }
+
+ public AuthorizationManager getSecurity() {
+    if (this.security == null) {
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            String className = UtilProperties.getPropertyValue("api.properties", "authorizationManager.class");
+            try {
+                this.security = (AuthorizationManager) loader.loadClass(className).newInstance();
+            } catch (Exception e) {
+                Debug.logError(e, module);
+            }
+    }
+    return this.security;
+ }
+
+ public GenericValue getUserLogin() {
+    if (this.userLogin == null) {
+        Delegator localDelegator = this.getDelegator();
+            try {
+                this.userLogin = localDelegator.findOne("UserLogin", false, "userLoginId", "NOT_LOGGED_IN");
+            } catch (GenericEntityException e) {
+                Debug.logError(e, "Error while getting NOT_LOGGED_IN user: ", module);
+            }
+            if (this.userLogin == null) {
+                this.userLogin = localDelegator.makeValue("UserLogin");
+                this.userLogin.set("userLoginId", "NOT_LOGGED_IN");
+            }
+    }
+ return this.userLogin;
+ }
+
+ public void initializeContext(Map<String, ? extends Object> params) {
+ this.setDelegator((Delegator) params.get("delegator"));
+ this.setDispatcher((LocalDispatcher) params.get("dispatcher"));
+ this.setSecurity((AuthorizationManager) params.get("security"));
+ this.setUserLogin((GenericValue) params.get("userLogin"));
+        this.setLocale((Locale) params.get("locale"));
+        this.setTimeZone((TimeZone) params.get("timeZone"));
+ }
+
+    @Override
+    public void reset() {
+        super.reset();
+        this.delegator = null;
+        this.dispatcher = null;
+        this.security = null;
+        this.userLogin = null;
+    }
+
+    protected void resetUserPreferences() {
+        if (this.userLogin != null) {
+            this.setLocale(userLogin.getString("lastLocale"));
+            this.setLocale(userLogin.getString("lastTimeZone"));
+        } else {
+            this.locale = Locale.getDefault();
+            this.timeZone = TimeZone.getDefault();
+        }
+    }
+
+    public void setDelegator(Delegator delegator) {
+ if (delegator != null) {
+ this.delegator = delegator;
+ }
+ }
+
+ public void setDispatcher(LocalDispatcher dispatcher) {
+ if (dispatcher != null) {
+ this.dispatcher = dispatcher;
+ }
+ }
+
+ public void setSecurity(AuthorizationManager security) {
+ if (security != null) {
+ this.security = security;
+ }
+ }
+
+ public void setUserLogin(GenericValue userLogin) {
+    if (userLogin != null) {
+        this.userLogin = userLogin;
+        this.resetUserPreferences();
+    }
+ }
+
+    public void clearUserData() {
+        this.userLogin = null;
+        this.resetUserPreferences();
+    }
+}

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java (added)
+++ ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java Fri Jan  1 00:38:52 2010
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.context;
+
+import static org.ofbiz.api.authorization.BasicPermissions.*;
+
+import java.security.Permission;
+import java.util.Set;
+
+import javolution.util.FastSet;
+
+import org.ofbiz.api.authorization.PermissionsUnion;
+
+/** OFBizPermission class.
+ * <p>This class enforces the security-aware artifact permission
+ * checking rules:<br>
+ * <ul>
+ * <li>If the permissions list contains the specified permission,
+ * then access is granted</li>
+ * <li>If services are specified, and all services return
+ * <code>hasPermission=true</code>, then access is granted</li>
+ * <li>The class contains a list of filters that can be used
+ * by filter implementations</li>
+ * </ul></p>
+ *
+ */
+@SuppressWarnings("serial")
+public class OFBizPermission extends Permission {
+
+    protected Permission adminPermission = null;
+    protected final PermissionsUnion includePermissions;
+    protected final PermissionsUnion excludePermissions;
+    protected final Set<String> filters = FastSet.newInstance();
+    protected final Set<String> services = FastSet.newInstance();
+
+    public OFBizPermission(String name) {
+        super(name);
+        this.includePermissions = new PermissionsUnion(name);
+        this.excludePermissions = new PermissionsUnion(name);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        }
+        try {
+            OFBizPermission that = (OFBizPermission) obj;
+            return this.getName().equals(that.getName());
+        } catch (Exception e) {}
+        return false;
+    }
+
+    @Override
+    public String getActions() {
+        return null;
+    }
+
+    @Override
+    public int hashCode() {
+        return this.getName().hashCode();
+    }
+
+    @Override
+    public boolean implies(Permission permission) {
+        if (this.adminPermission != null) {
+            return this.adminPermission.implies(permission);
+        }
+        return this.includePermissions.implies(permission) && !this.excludePermissions.implies(permission);
+    }
+
+    public Set<String> getFilterNames() {
+        return this.filters;
+    }
+
+    public Set<String> getServiceNames() {
+        return this.services;
+    }
+
+    public void accumulatePermissions(OFBizPermission permission) {
+        if (permission == null || this.adminPermission != null) {
+            return;
+        }
+        if (permission.includePermissions.getPermissionsSet().contains(Admin)) {
+            this.adminPermission = Admin;
+            return;
+        }
+        this.includePermissions.getPermissionsSet().removeAll(permission.excludePermissions.getPermissionsSet());
+        this.excludePermissions.getPermissionsSet().removeAll(permission.includePermissions.getPermissionsSet());
+        this.includePermissions.getPermissionsSet().addAll(permission.includePermissions.getPermissionsSet());
+        this.excludePermissions.getPermissionsSet().addAll(permission.excludePermissions.getPermissionsSet());
+        this.filters.addAll(permission.filters);
+        this.services.addAll(permission.services);
+    }
+
+    public void reset() {
+        this.adminPermission = null;
+        this.includePermissions.getPermissionsSet().clear();
+        this.excludePermissions.getPermissionsSet().clear();
+        this.filters.clear();
+        this.services.clear();
+    }
+
+    @Override
+    public String toString() {
+        if (this.adminPermission != null) {
+            return this.adminPermission.toString();
+        }
+        StringBuilder sb = new StringBuilder();
+        sb.append(this.includePermissions);
+        sb.append(" ");
+        sb.append(this.excludePermissions);
+        for (String filter : this.filters) {
+            sb.append(" filter=");
+            sb.append(filter);
+        }
+        for (String service : this.services) {
+            sb.append(" service=");
+            sb.append(service);
+        }
+        return sb.toString().trim();
+    }
+
+}

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/OFBizPermission.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/PathNode.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/PathNode.java?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/PathNode.java (added)
+++ ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/PathNode.java Fri Jan  1 00:38:52 2010
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.context;
+
+import java.util.Collection;
+import java.util.Map;
+
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
+/** Implements a node in a permissions tree.
+ */
+public class PathNode {
+
+    protected String nodeName = null;
+    protected OFBizPermission permission = null;
+    protected Map<String, PathNode> childNodes = null;
+
+    public PathNode() {}
+
+    protected PathNode(String nodeName) {
+        this.nodeName = nodeName;
+    }
+
+    public void setPermissions(String artifactPath, OFBizPermission permission) {
+        int pos = artifactPath.indexOf("/");
+        if (pos == -1) {
+            if (this.permission == null) {
+                this.permission = permission;
+            } else {
+                this.permission.accumulatePermissions(permission);
+            }
+            if (this.nodeName == null) {
+                this.nodeName = artifactPath;
+            }
+            return;
+        }
+        String thisNodeName = artifactPath.substring(0, pos);
+        if (this.nodeName == null) {
+            this.nodeName = thisNodeName;
+        }
+        artifactPath = artifactPath.substring(pos + 1);
+        String nextNodeName = artifactPath;
+        pos = artifactPath.indexOf("/");
+        if (pos != -1) {
+            nextNodeName = artifactPath.substring(0, pos);
+        }
+        String key = nextNodeName.toUpperCase();
+        if (this.childNodes == null) {
+            this.childNodes = FastMap.newInstance();
+        }
+        PathNode node = this.childNodes.get(key);
+        if (node == null) {
+            node = new PathNode(nextNodeName);
+            this.childNodes.put(key, node);
+        }
+        node.setPermissions(artifactPath, permission);
+    }
+
+    public void getPermissions(String artifactPath, OFBizPermission permission) {
+        permission.accumulatePermissions(this.permission);
+        int pos = artifactPath.indexOf("/");
+        if (pos != -1 && this.childNodes != null) {
+            artifactPath = artifactPath.substring(pos + 1);
+            String nextNodeName = artifactPath;
+            pos = artifactPath.indexOf("/");
+            if (pos != -1) {
+                nextNodeName = artifactPath.substring(0, pos);
+            }
+            PathNode node = this.childNodes.get(nextNodeName.toUpperCase());
+            if (node != null) {
+                node.getPermissions(artifactPath, permission);
+            }
+        }
+    }
+
+    @Override
+    public String toString() {
+        FastList<PathNode> currentPath = FastList.newInstance();
+        StringBuilder result = new StringBuilder();
+        buildNodeString(currentPath, result);
+        return result.toString();
+    }
+
+    protected void buildNodeString(FastList<PathNode> currentPath, StringBuilder result) {
+        currentPath.add(this);
+        if (this.permission != null) {
+            for (PathNode pathNode: currentPath) {
+                result.append("/");
+                result.append(pathNode.nodeName);
+            }
+            result.append("[");
+            result.append(this.permission);
+            result.append("]");
+            result.append("\n");
+        }
+        if (this.childNodes != null) {
+            Collection<PathNode> childNodes = this.childNodes.values();
+            for (PathNode childNode : childNodes) {
+                childNode.buildNodeString(currentPath, result);
+            }
+        }
+        currentPath.removeLast();
+    }
+}

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/PathNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/PathNode.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/PathNode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/SecurityAwareEli.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/SecurityAwareEli.java?rev=894961&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/SecurityAwareEli.java (added)
+++ ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/SecurityAwareEli.java Fri Jan  1 00:38:52 2010
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.context;
+
+import java.util.List;
+import java.util.Set;
+
+import javolution.util.FastList;
+
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityListIterator;
+
+/**
+ * SecurityAwareEli class.  This class decorates an <code>
+ * EntityListIterator</code> instance and filters a list of
+ * <code>GenericValue</code>s based on a set of permission services.
+ * <p>The permission service must implement <code>permissionInterface</code>
+ * and accept an optional <code>candidateObject</code> parameter (parameter
+ * type is <code>java.lang.Object</code>). The service should
+ * return <code>hasPermission = true</code> if the user is granted access
+ * to the <code>candidateObject</code>.</p>
+ */
+public class SecurityAwareEli extends SecurityAwareListIterator<GenericValue> {
+
+    public static final String module = SecurityAwareEli.class.getName();
+    protected final EntityListIterator listIterator;
+    protected GenericValue previousValue = null;
+
+    public SecurityAwareEli(EntityListIterator iterator, Set<String> serviceNameList) {
+        super(iterator, serviceNameList);
+        this.listIterator = iterator;
+    }
+
+    public boolean absolute(int rowNum) throws GenericEntityException {
+        return this.listIterator.absolute(rowNum);
+    }
+
+    public void afterLast() throws GenericEntityException {
+        this.listIterator.afterLast();
+    }
+
+    public void beforeFirst() throws GenericEntityException {
+        this.listIterator.beforeFirst();
+    }
+
+    public void close() throws GenericEntityException {
+        this.listIterator.close();
+    }
+
+    public GenericValue currentGenericValue() throws GenericEntityException {
+        GenericValue value = this.listIterator.currentGenericValue();
+        while (value != null && !this.hasPermission(value)) {
+            value = this.next();
+        }
+        return value;
+    }
+
+    public int currentIndex() throws GenericEntityException {
+        return this.listIterator.currentIndex();
+    }
+
+    public boolean first() throws GenericEntityException {
+        return this.listIterator.first();
+    }
+
+    public List<GenericValue> getCompleteList() throws GenericEntityException {
+        List<GenericValue> list = FastList.newInstance();
+        GenericValue nextValue = this.next();
+        while (nextValue != null) {
+            list.add(nextValue);
+            nextValue = this.next();
+        }
+        return list;
+    }
+
+    public List<GenericValue> getPartialList(int start, int number) throws GenericEntityException {
+        List<GenericValue> list = FastList.newInstance();
+        if (number == 0) {
+            return list;
+        }
+        if (start == 0) {
+            start = 1;
+        }
+        GenericValue nextValue = null;
+        if (start == 1) {
+            nextValue = this.next();
+            if (nextValue == null) {
+                return list;
+            }
+        } else {
+            nextValue = this.getAbsolute(start);
+        }
+        int numRetreived = 1;
+        while (number > numRetreived && nextValue != null) {
+            list.add(nextValue);
+            numRetreived++;
+            nextValue = this.next();
+        }
+        return list;
+    }
+
+    protected GenericValue getAbsolute(int start) throws GenericEntityException {
+        if (!this.absolute(start)) {
+            return null;
+        }
+        return this.currentGenericValue();
+    }
+
+    public int getResultsSizeAfterPartialList() throws GenericEntityException {
+        return this.listIterator.getResultsSizeAfterPartialList();
+    }
+
+    public boolean last() throws GenericEntityException {
+        return this.listIterator.last();
+    }
+
+    public boolean relative(int rows) throws GenericEntityException {
+        return this.listIterator.relative(rows);
+    }
+
+    public void setDelegator(GenericDelegator delegator) {
+        this.listIterator.setDelegator(delegator);
+    }
+
+    public void setFetchSize(int rows) throws GenericEntityException {
+        this.listIterator.setFetchSize(rows);
+    }
+
+}

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/SecurityAwareEli.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/SecurityAwareEli.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20091231/framework/context/src/org/ofbiz/context/SecurityAwareEli.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain