You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Scott Gray <sc...@hotwaxmedia.com> on 2009/11/08 21:32:17 UTC
Re: svn commit: r833727 - in /ofbiz/trunk/framework/webslinger/src/org/ofbiz: commons/vfs/ commons/vfs/ofbiz/ webslinger/
Hi Jacques,
This is that same problem with the patch again, please keep an eye out
for these as the commits are impossible to review.
Thanks
Scott
HotWax Media
http://www.hotwaxmedia.com
On 8/11/2009, at 7:18 AM, jleroux@apache.org wrote:
> Author: jleroux
> Date: Sat Nov 7 18:18:33 2009
> New Revision: 833727
>
> URL: http://svn.apache.org/viewvc?rev=833727&view=rev
> Log:
> A patch from Marc Morin "Resolve java warnings exposed in Eclipse :
> framework - webslinger" (https://issues.apache.org/jira/browse/OFBIZ-3121
> ) - OFBIZ-3121
>
> Modified:
> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
> CommonsVfsContainer.java
> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/
> OfbizComponentProvider.java
> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/
> OfbizHomeProvider.java
> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> EntityHttpUtil.java
> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> StatsUpdater.java
> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> WebslingerContextMapper.java
> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> WebslingerServerEngine.java
>
> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
> CommonsVfsContainer.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java?rev=833727&r1=833726&r2=833727&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
> CommonsVfsContainer.java (original)
> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
> CommonsVfsContainer.java Sat Nov 7 18:18:33 2009
> @@ -1,68 +1,66 @@
> -/
> *******************************************************************************
> - * 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.commons.vfs;
> -
> -import java.io.File;
> -import java.io.IOException;
> -import java.net.MalformedURLException;
> -
> -import org.apache.commons.vfs.CacheStrategy;
> -import org.apache.commons.vfs.FileObject;
> -import org.apache.commons.vfs.FileSystemException;
> -import org.apache.commons.vfs.FileSystemManager;
> -import org.apache.commons.vfs.impl.StandardFileSystemManager;
> -
> -import org.ofbiz.base.container.Container;
> -import org.ofbiz.base.container.ContainerException;
> -import org.ofbiz.base.util.UtilMisc;
> -import org.webslinger.commons.vfs.VFSUtil;
> -
> -public class CommonsVfsContainer implements Container {
> - private static StandardFileSystemManager sfsm;
> -
> - public void init(String[] args, String configFile) throws
> ContainerException {
> - }
> -
> - public boolean start() throws ContainerException {
> - try {
> - StandardFileSystemManager sfsm =
> VFSUtil.createStandardFileSystemManager();
> - FileObject currentDir = sfsm.resolveFile(new
> File(".").toURI().toURL().toString());
> - sfsm.setBaseFile(currentDir);
> - CommonsVfsContainer.sfsm = sfsm;
> - } catch (FileSystemException e) {
> - throw UtilMisc.initCause(new
> ContainerException("Initializing StandardFileSystemManager"), e);
> - } catch (MalformedURLException e) {
> - throw UtilMisc.initCause(new
> ContainerException("Initializing StandardFileSystemManager"), e);
> - }
> - return true;
> - }
> -
> - public void stop() throws ContainerException {
> - sfsm.close();
> - sfsm = null;
> - }
> -
> - public static FileObject resolveFile(String uri) throws
> IOException {
> - return sfsm.resolveFile(uri);
> - }
> -
> - public static FileSystemManager getFileSystemManager() {
> - return sfsm;
> - }
> -}
> +/
> *******************************************************************************
> + * 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.commons.vfs;
> +
> +import java.io.File;
> +import java.io.IOException;
> +import java.net.MalformedURLException;
> +
> +import org.apache.commons.vfs.FileObject;
> +import org.apache.commons.vfs.FileSystemException;
> +import org.apache.commons.vfs.FileSystemManager;
> +import org.apache.commons.vfs.impl.StandardFileSystemManager;
> +import org.ofbiz.base.container.Container;
> +import org.ofbiz.base.container.ContainerException;
> +import org.ofbiz.base.util.UtilMisc;
> +import org.webslinger.commons.vfs.VFSUtil;
> +
> +public class CommonsVfsContainer implements Container {
> + private static StandardFileSystemManager sfsm;
> +
> + public void init(String[] args, String configFile) throws
> ContainerException {
> + }
> +
> + public boolean start() throws ContainerException {
> + try {
> + StandardFileSystemManager sfsm =
> VFSUtil.createStandardFileSystemManager();
> + FileObject currentDir = sfsm.resolveFile(new
> File(".").toURI().toURL().toString());
> + sfsm.setBaseFile(currentDir);
> + CommonsVfsContainer.sfsm = sfsm;
> + } catch (FileSystemException e) {
> + throw UtilMisc.initCause(new
> ContainerException("Initializing StandardFileSystemManager"), e);
> + } catch (MalformedURLException e) {
> + throw UtilMisc.initCause(new
> ContainerException("Initializing StandardFileSystemManager"), e);
> + }
> + return true;
> + }
> +
> + public void stop() throws ContainerException {
> + sfsm.close();
> + sfsm = null;
> + }
> +
> + public static FileObject resolveFile(String uri) throws
> IOException {
> + return sfsm.resolveFile(uri);
> + }
> +
> + public static FileSystemManager getFileSystemManager() {
> + return sfsm;
> + }
> +}
>
> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
> ofbiz/OfbizComponentProvider.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java?rev=833727&r1=833726&r2=833727&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/
> OfbizComponentProvider.java (original)
> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/
> OfbizComponentProvider.java Sat Nov 7 18:18:33 2009
> @@ -1,58 +1,58 @@
> -/
> *******************************************************************************
> - * 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.commons.vfs.ofbiz;
> -
> -import java.net.URL;
> -import java.util.Collection;
> -import org.apache.commons.vfs.FileObject;
> -import org.apache.commons.vfs.FileSystemException;
> -import org.apache.commons.vfs.FileSystemOptions;
> -import org.apache.commons.vfs.provider.AbstractFileProvider;
> -import
> org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
> -import org.ofbiz.base.location.FlexibleLocation;
> -import org.ofbiz.base.util.UtilMisc;
> -import org.webslinger.commons.vfs.VFSUtil;
> -
> -public class OfbizComponentProvider extends AbstractFileProvider {
> - public Collection getCapabilities() {
> - return DefaultLocalFileProvider.capabilities;
> - }
> -
> - public FileObject findFile(FileObject base, String name,
> FileSystemOptions properties) throws FileSystemException {
> - try {
> - //name = name.replaceAll("^ofbiz-component://", "");
> - int nameLength = name.length();
> - int componentNameStart = 16;
> - while (componentNameStart < nameLength &&
> name.charAt(componentNameStart) == '/') componentNameStart++;
> - if (componentNameStart == nameLength) throw new
> IllegalArgumentException("Invalid name(" + name + ")");
> - int componentNameEnd = componentNameStart;
> - while (componentNameEnd < nameLength &&
> name.charAt(componentNameEnd) != '/') componentNameEnd++;
> - if (componentNameEnd == nameLength) throw new
> IllegalArgumentException("Invalid name(" + name + ")");
> - int restStart = componentNameEnd;
> - while (restStart < nameLength && name.charAt(restStart)
> == '/') restStart++;
> - if (restStart == nameLength) throw new
> IllegalArgumentException("Invalid name(" + name + ")");
> - String componentName =
> name.substring(componentNameStart, componentNameEnd);
> - URL location =
> FlexibleLocation.resolveLocation("component://" + componentName +
> "/.");
> - FileObject ofbizBase =
> getContext().resolveFile(location.toString(), properties);
> - return
> VFSUtil
> .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
> ofbizBase
> .resolveFile(name.substring(restStart)).getURL().toString(),
> properties);
> - } catch (Exception e) {
> - throw UtilMisc.initCause(new
> FileSystemException(e.getMessage(), null, e), e);
> - }
> - }
> -}
> +/
> *******************************************************************************
> + * 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.commons.vfs.ofbiz;
> +
> +import java.net.URL;
> +import java.util.Collection;
> +import org.apache.commons.vfs.FileObject;
> +import org.apache.commons.vfs.FileSystemException;
> +import org.apache.commons.vfs.FileSystemOptions;
> +import org.apache.commons.vfs.provider.AbstractFileProvider;
> +import
> org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
> +import org.ofbiz.base.location.FlexibleLocation;
> +import org.ofbiz.base.util.UtilMisc;
> +import org.webslinger.commons.vfs.VFSUtil;
> +
> +public class OfbizComponentProvider extends AbstractFileProvider {
> + public Collection<?> getCapabilities() {
> + return DefaultLocalFileProvider.capabilities;
> + }
> +
> + public FileObject findFile(FileObject base, String name,
> FileSystemOptions properties) throws FileSystemException {
> + try {
> + //name = name.replaceAll("^ofbiz-component://", "");
> + int nameLength = name.length();
> + int componentNameStart = 16;
> + while (componentNameStart < nameLength &&
> name.charAt(componentNameStart) == '/') componentNameStart++;
> + if (componentNameStart == nameLength) throw new
> IllegalArgumentException("Invalid name(" + name + ")");
> + int componentNameEnd = componentNameStart;
> + while (componentNameEnd < nameLength &&
> name.charAt(componentNameEnd) != '/') componentNameEnd++;
> + if (componentNameEnd == nameLength) throw new
> IllegalArgumentException("Invalid name(" + name + ")");
> + int restStart = componentNameEnd;
> + while (restStart < nameLength && name.charAt(restStart)
> == '/') restStart++;
> + if (restStart == nameLength) throw new
> IllegalArgumentException("Invalid name(" + name + ")");
> + String componentName =
> name.substring(componentNameStart, componentNameEnd);
> + URL location =
> FlexibleLocation.resolveLocation("component://" + componentName +
> "/.");
> + FileObject ofbizBase =
> getContext().resolveFile(location.toString(), properties);
> + return
> VFSUtil
> .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
> ofbizBase
> .resolveFile(name.substring(restStart)).getURL().toString(),
> properties);
> + } catch (Exception e) {
> + throw UtilMisc.initCause(new
> FileSystemException(e.getMessage(), null, e), e);
> + }
> + }
> +}
>
> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
> ofbiz/OfbizHomeProvider.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java?rev=833727&r1=833726&r2=833727&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/
> OfbizHomeProvider.java (original)
> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/
> OfbizHomeProvider.java Sat Nov 7 18:18:33 2009
> @@ -1,50 +1,50 @@
> -/
> *******************************************************************************
> - * 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.commons.vfs.ofbiz;
> -
> -import java.net.URL;
> -import java.util.Collection;
> -
> -import org.apache.commons.vfs.FileObject;
> -import org.apache.commons.vfs.FileSystemException;
> -import org.apache.commons.vfs.FileSystemOptions;
> -import org.apache.commons.vfs.provider.AbstractFileProvider;
> -import
> org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
> -
> -import org.ofbiz.base.location.FlexibleLocation;
> -import org.ofbiz.base.util.UtilMisc;
> -
> -import org.webslinger.commons.vfs.VFSUtil;
> -
> -public class OfbizHomeProvider extends AbstractFileProvider {
> - public Collection getCapabilities() {
> - return DefaultLocalFileProvider.capabilities;
> - }
> -
> - public FileObject findFile(FileObject base, String name,
> FileSystemOptions properties) throws FileSystemException {
> - //new Exception("findFile(" + base + ", " + name +
> ")").printStackTrace();
> - try {
> - URL location =
> FlexibleLocation.resolveLocation("ofbizhome://.");
> - FileObject ofbizBase =
> getContext().resolveFile(location.toString(), properties);
> - return
> VFSUtil
> .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
> ofbizBase.resolveFile(name.substring(13)).getURL().toString(),
> properties);
> - } catch (Exception e) {
> - throw UtilMisc.initCause(new
> FileSystemException(e.getMessage(), null, e), e);
> - }
> - }
> -}
> +/
> *******************************************************************************
> + * 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.commons.vfs.ofbiz;
> +
> +import java.net.URL;
> +import java.util.Collection;
> +
> +import org.apache.commons.vfs.FileObject;
> +import org.apache.commons.vfs.FileSystemException;
> +import org.apache.commons.vfs.FileSystemOptions;
> +import org.apache.commons.vfs.provider.AbstractFileProvider;
> +import
> org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
> +
> +import org.ofbiz.base.location.FlexibleLocation;
> +import org.ofbiz.base.util.UtilMisc;
> +
> +import org.webslinger.commons.vfs.VFSUtil;
> +
> +public class OfbizHomeProvider extends AbstractFileProvider {
> + public Collection<?> getCapabilities() {
> + return DefaultLocalFileProvider.capabilities;
> + }
> +
> + public FileObject findFile(FileObject base, String name,
> FileSystemOptions properties) throws FileSystemException {
> + //new Exception("findFile(" + base + ", " + name +
> ")").printStackTrace();
> + try {
> + URL location =
> FlexibleLocation.resolveLocation("ofbizhome://.");
> + FileObject ofbizBase =
> getContext().resolveFile(location.toString(), properties);
> + return
> VFSUtil
> .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
> ofbizBase.resolveFile(name.substring(13)).getURL().toString(),
> properties);
> + } catch (Exception e) {
> + throw UtilMisc.initCause(new
> FileSystemException(e.getMessage(), null, e), e);
> + }
> + }
> +}
>
> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> EntityHttpUtil.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/EntityHttpUtil.java?rev=833727&r1=833726&r2=833727&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> EntityHttpUtil.java (original)
> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> EntityHttpUtil.java Sat Nov 7 18:18:33 2009
> @@ -1,78 +1,73 @@
> -/
> *******************************************************************************
> - * 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.webslinger;
> -
> -import java.util.HashMap;
> -import java.util.Iterator;
> -import java.util.Locale;
> -import java.util.Map;
> -
> -import javax.servlet.ServletRequest;
> -import javax.servlet.http.HttpServletRequest;
> -
> -import org.ofbiz.base.util.GeneralException;
> -import org.ofbiz.base.util.ObjectType;
> -import org.ofbiz.base.util.UtilHttp;
> -import org.ofbiz.base.util.UtilMisc;
> -import org.ofbiz.base.util.UtilValidate;
> -import org.ofbiz.entity.Delegator;
> -import org.ofbiz.entity.GenericValue;
> -import org.ofbiz.entity.jdbc.SqlJdbcUtil;
> -import org.ofbiz.entity.model.ModelEntity;
> -import org.ofbiz.entity.model.ModelField;
> -import org.ofbiz.entity.model.ModelFieldType;
> -
> -public class EntityHttpUtil {
> - public static GenericValue makeValidValue(String entityName,
> ServletRequest request) throws GeneralException {
> - return makeValidValue(entityName, false, request);
> - }
> -
> - public static GenericValue makeValidValue(String entityName,
> boolean includePks, ServletRequest request) throws GeneralException {
> - if (request instanceof HttpServletRequest) return
> makeValidValue(entityName, includePks, (HttpServletRequest) request);
> - throw new IllegalArgumentException("Not an
> HttpServletRequest");
> - }
> -
> - public static GenericValue makeValidValue(String entityName,
> HttpServletRequest request) throws GeneralException {
> - return makeValidValue(entityName, false, request);
> - }
> -
> - public static GenericValue makeValidValue(String entityName,
> boolean includePks, HttpServletRequest request) throws
> GeneralException {
> - Delegator delegator = (Delegator)
> request.getAttribute("delegator");
> - GenericValue value = delegator.makeValue(entityName);
> - ModelEntity model = value.getModelEntity();
> - Iterator<ModelField> it = includePks ?
> model.getFieldsIterator() : model.getNopksIterator();
> - Locale locale = UtilHttp.getLocale(request);
> - while (it.hasNext()) {
> - ModelField field = it.next();
> - String fieldName = field.getName();
> - String parameterValue = request.getParameter(fieldName);
> - Object fieldValue;
> - if (parameterValue == null) {
> - fieldValue = null;
> - } else {
> - ModelFieldType fieldType =
> delegator.getEntityFieldType(model, field.getType());
> - String wantedType = fieldType.getJavaType();
> - fieldValue =
> ObjectType.simpleTypeConvert(parameterValue, wantedType, null,
> locale, true);
> - }
> - value.put(fieldName, fieldValue);
> - }
> - return value;
> - }
> -}
> -
> +/
> *******************************************************************************
> + * 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.webslinger;
> +
> +import java.util.Iterator;
> +import java.util.Locale;
> +
> +import javax.servlet.ServletRequest;
> +import javax.servlet.http.HttpServletRequest;
> +
> +import org.ofbiz.base.util.GeneralException;
> +import org.ofbiz.base.util.ObjectType;
> +import org.ofbiz.base.util.UtilHttp;
> +import org.ofbiz.entity.Delegator;
> +import org.ofbiz.entity.GenericValue;
> +import org.ofbiz.entity.model.ModelEntity;
> +import org.ofbiz.entity.model.ModelField;
> +import org.ofbiz.entity.model.ModelFieldType;
> +
> +public class EntityHttpUtil {
> + public static GenericValue makeValidValue(String entityName,
> ServletRequest request) throws GeneralException {
> + return makeValidValue(entityName, false, request);
> + }
> +
> + public static GenericValue makeValidValue(String entityName,
> boolean includePks, ServletRequest request) throws GeneralException {
> + if (request instanceof HttpServletRequest) return
> makeValidValue(entityName, includePks, (HttpServletRequest) request);
> + throw new IllegalArgumentException("Not an
> HttpServletRequest");
> + }
> +
> + public static GenericValue makeValidValue(String entityName,
> HttpServletRequest request) throws GeneralException {
> + return makeValidValue(entityName, false, request);
> + }
> +
> + public static GenericValue makeValidValue(String entityName,
> boolean includePks, HttpServletRequest request) throws
> GeneralException {
> + Delegator delegator = (Delegator)
> request.getAttribute("delegator");
> + GenericValue value = delegator.makeValue(entityName);
> + ModelEntity model = value.getModelEntity();
> + Iterator<ModelField> it = includePks ?
> model.getFieldsIterator() : model.getNopksIterator();
> + Locale locale = UtilHttp.getLocale(request);
> + while (it.hasNext()) {
> + ModelField field = it.next();
> + String fieldName = field.getName();
> + String parameterValue = request.getParameter(fieldName);
> + Object fieldValue;
> + if (parameterValue == null) {
> + fieldValue = null;
> + } else {
> + ModelFieldType fieldType =
> delegator.getEntityFieldType(model, field.getType());
> + String wantedType = fieldType.getJavaType();
> + fieldValue =
> ObjectType.simpleTypeConvert(parameterValue, wantedType, null,
> locale, true);
> + }
> + value.put(fieldName, fieldValue);
> + }
> + return value;
> + }
> +}
> +
>
> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> StatsUpdater.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java?rev=833727&r1=833726&r2=833727&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> StatsUpdater.java (original)
> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> StatsUpdater.java Sat Nov 7 18:18:33 2009
> @@ -1,121 +1,118 @@
> -/
> *******************************************************************************
> - * 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.webslinger;
> -
> -import java.util.HashMap;
> -import java.util.Iterator;
> -import java.util.Map;
> -import java.util.concurrent.Callable;
> -import java.util.concurrent.ConcurrentHashMap;
> -import java.util.concurrent.ScheduledFuture;
> -import java.util.concurrent.TimeUnit;
> -import java.util.concurrent.atomic.AtomicReference;
> -
> -import org.ofbiz.base.util.UtilMisc;
> -import org.ofbiz.entity.Delegator;
> -import org.ofbiz.entity.GenericEntityException;
> -import org.ofbiz.entity.GenericPK;
> -import org.ofbiz.entity.GenericValue;
> -
> -import org.webslinger.cache.ConcurrentCache;
> -import org.webslinger.concurrent.ExecutionPool;
> -
> -public class StatsUpdater {
> - private static final Updater UPDATER = new Updater();
> -
> - public static void updateStats(Delegator delegator, String
> entityName, Map<String, ? extends Object> keyFields, Map<String, ?
> extends Long> updateCountFields) throws GenericEntityException {
> - GenericPK pk = delegator.makePK(entityName, keyFields);
> - Map<String, Long> value = UPDATER.getValue(pk);
> - synchronized (value) {
> - for (Map.Entry<String, ? extends Long> entry:
> updateCountFields.entrySet()) {
> - Long oldValue = value.get(entry.getKey());
> - if (oldValue != null) {
> - value.put(entry.getKey(),
> Long.valueOf(oldValue.longValue() + entry.getValue()));
> - } else {
> - value.put(entry.getKey(), entry.getValue());
> - }
> - }
> - }
> - }
> -
> - private static final class Updater implements Callable<Void> {
> - protected AtomicReference<EntityHolder> entities = new
> AtomicReference<EntityHolder>(new EntityHolder(Updater.class,
> "entities", null));
> - protected ScheduledFuture<Void> future;
> -
> - protected Map<String, Long> getValue(GenericPK pk) throws
> GenericEntityException {
> - synchronized (this) {
> - if (future == null || future.isDone()) {
> - future = ExecutionPool.schedule(this, 1,
> TimeUnit.SECONDS);
> - }
> - }
> - try {
> - return entities.get().get(pk);
> - } catch (RuntimeException e) {
> - throw e;
> - } catch (GenericEntityException e) {
> - throw e;
> - } catch (Exception e) {
> - throw UtilMisc.initCause(new
> GenericEntityException(e.getMessage()), e);
> - }
> - }
> -
> - public Void call() {
> - EntityHolder oldEntities;
> - EntityHolder newEntities = new
> EntityHolder(Updater.class, "entities", null);
> - do {
> - oldEntities = entities.get();
> - } while (!entities.compareAndSet(oldEntities,
> newEntities));
> - synchronized (Updater.class) {
> - for (GenericPK pk: oldEntities.keys()) {
> - try {
> - Map<String, Long> add = oldEntities.get(pk);
> - GenericValue existing =
> pk.getDelegator().findOne(pk.getEntityName(), pk, false);
> - if (existing == null) {
> - existing =
> pk.getDelegator().create(pk.getEntityName(), pk);
> - }
> - for (Map.Entry<String, Long> entry:
> add.entrySet()) {
> - Long value = entry.getValue();
> - Long oldValue =
> existing.getLong(entry.getKey());
> - if (oldValue != null) {
> - existing.put(entry.getKey(),
> Long.valueOf(value.longValue() + oldValue.longValue()));
> - } else {
> - existing.put(entry.getKey(), value);
> - }
> - }
> - existing.store();
> - } catch (Exception e) {
> - e.printStackTrace();
> - }
> - }
> - }
> - return null;
> - }
> - }
> -
> - private static final class EntityHolder extends
> ConcurrentCache<GenericPK, Map<String, Long>> {
> - protected EntityHolder(Class<?> owner, String field, String
> label) {
> - super(owner, field, label, HARD);
> - }
> -
> - @Override
> - protected Map<String, Long> createValue(GenericPK pk)
> throws Exception {
> - return new HashMap<String, Long>();
> - }
> - }
> -}
> +/
> *******************************************************************************
> + * 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.webslinger;
> +
> +import java.util.HashMap;
> +import java.util.Map;
> +import java.util.concurrent.Callable;
> +import java.util.concurrent.ScheduledFuture;
> +import java.util.concurrent.TimeUnit;
> +import java.util.concurrent.atomic.AtomicReference;
> +
> +import org.ofbiz.base.util.UtilMisc;
> +import org.ofbiz.entity.Delegator;
> +import org.ofbiz.entity.GenericEntityException;
> +import org.ofbiz.entity.GenericPK;
> +import org.ofbiz.entity.GenericValue;
> +import org.webslinger.cache.ConcurrentCache;
> +import org.webslinger.concurrent.ExecutionPool;
> +
> +public class StatsUpdater {
> + private static final Updater UPDATER = new Updater();
> +
> + public static void updateStats(Delegator delegator, String
> entityName, Map<String, ? extends Object> keyFields, Map<String, ?
> extends Long> updateCountFields) throws GenericEntityException {
> + GenericPK pk = delegator.makePK(entityName, keyFields);
> + Map<String, Long> value = UPDATER.getValue(pk);
> + synchronized (value) {
> + for (Map.Entry<String, ? extends Long> entry:
> updateCountFields.entrySet()) {
> + Long oldValue = value.get(entry.getKey());
> + if (oldValue != null) {
> + value.put(entry.getKey(),
> Long.valueOf(oldValue.longValue() + entry.getValue()));
> + } else {
> + value.put(entry.getKey(), entry.getValue());
> + }
> + }
> + }
> + }
> +
> + private static final class Updater implements Callable<Void> {
> + protected AtomicReference<EntityHolder> entities = new
> AtomicReference<EntityHolder>(new EntityHolder(Updater.class,
> "entities", null));
> + protected ScheduledFuture<Void> future;
> +
> + protected Map<String, Long> getValue(GenericPK pk) throws
> GenericEntityException {
> + synchronized (this) {
> + if (future == null || future.isDone()) {
> + future = ExecutionPool.schedule(this, 1,
> TimeUnit.SECONDS);
> + }
> + }
> + try {
> + return entities.get().get(pk);
> + } catch (RuntimeException e) {
> + throw e;
> + } catch (GenericEntityException e) {
> + throw e;
> + } catch (Exception e) {
> + throw UtilMisc.initCause(new
> GenericEntityException(e.getMessage()), e);
> + }
> + }
> +
> + public Void call() {
> + EntityHolder oldEntities;
> + EntityHolder newEntities = new
> EntityHolder(Updater.class, "entities", null);
> + do {
> + oldEntities = entities.get();
> + } while (!entities.compareAndSet(oldEntities,
> newEntities));
> + synchronized (Updater.class) {
> + for (GenericPK pk: oldEntities.keys()) {
> + try {
> + Map<String, Long> add = oldEntities.get(pk);
> + GenericValue existing =
> pk.getDelegator().findOne(pk.getEntityName(), pk, false);
> + if (existing == null) {
> + existing =
> pk.getDelegator().create(pk.getEntityName(), pk);
> + }
> + for (Map.Entry<String, Long> entry:
> add.entrySet()) {
> + Long value = entry.getValue();
> + Long oldValue =
> existing.getLong(entry.getKey());
> + if (oldValue != null) {
> + existing.put(entry.getKey(),
> Long.valueOf(value.longValue() + oldValue.longValue()));
> + } else {
> + existing.put(entry.getKey(), value);
> + }
> + }
> + existing.store();
> + } catch (Exception e) {
> + e.printStackTrace();
> + }
> + }
> + }
> + return null;
> + }
> + }
> +
> + private static final class EntityHolder extends
> ConcurrentCache<GenericPK, Map<String, Long>> {
> + protected EntityHolder(Class<?> owner, String field, String
> label) {
> + super(owner, field, label, HARD);
> + }
> +
> + @Override
> + protected Map<String, Long> createValue(GenericPK pk)
> throws Exception {
> + return new HashMap<String, Long>();
> + }
> + }
> +}
>
> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> WebslingerContextMapper.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java?rev=833727&r1=833726&r2=833727&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> WebslingerContextMapper.java (original)
> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> WebslingerContextMapper.java Sat Nov 7 18:18:33 2009
> @@ -1,218 +1,216 @@
> -/
> *******************************************************************************
> - * 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.webslinger;
> -
> -import java.io.IOException;
> -import java.net.URL;
> -import java.util.ArrayList;
> -import java.util.Arrays;
> -import java.util.HashSet;
> -import java.util.List;
> -import java.util.Set;
> -
> -import javax.servlet.ServletConfig;
> -import javax.servlet.ServletContext;
> -import javax.servlet.ServletException;
> -import javax.servlet.http.HttpServletRequest;
> -
> -import org.ofbiz.base.util.UtilMisc;
> -import org.ofbiz.base.util.UtilProperties;
> -import org.ofbiz.entity.Delegator;
> -import org.ofbiz.entity.DelegatorFactory;
> -import org.ofbiz.entity.GenericEntityException;
> -import org.ofbiz.entity.GenericValue;
> -import org.ofbiz.entity.cache.Cache;
> -import org.ofbiz.entity.util.EntityUtil;
> -import org.ofbiz.security.SecurityFactory;
> -import org.ofbiz.security.authz.AuthorizationFactory;
> -import org.ofbiz.service.GenericDispatcher;
> -import org.ofbiz.service.LocalDispatcher;
> -import org.ofbiz.service.ServiceDispatcher;
> -import org.ofbiz.service.DispatchContext;
> -
> -import org.webslinger.AbstractMappingWebslingerServletContextFactory;
> -import org.webslinger.WebslingerServletContext;
> -import org.webslinger.collections.CollectionUtil;
> -import org.webslinger.lang.ObjectUtil;
> -
> -public class WebslingerContextMapper extends
> AbstractMappingWebslingerServletContextFactory {
> - protected ServletContext servletContext;
> - protected Delegator delegator;
> - protected final ArrayList<URL> globalReaderURLs = new
> ArrayList<URL>();
> -
> - public void init(ServletConfig config) throws ServletException,
> IOException {
> -
> System
> .err.println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
> - servletContext = config.getServletContext();
> - String delegatorName =
> servletContext.getInitParameter("entityDelegatorName");
> - delegator = DelegatorFactory.getDelegator(delegatorName);
> - String readerFiles =
> servletContext.getInitParameter("serviceReaderUrls");
> - if (readerFiles != null) {
> - for (String reader: CollectionUtil.split(readerFiles,
> ";")) {
> - URL url =
> config.getServletContext().getResource(reader);
> - if (url != null) globalReaderURLs.add(url);
> - }
> - }
> - super.init(config,
> UtilProperties.getPropertyValue("webslinger.properties",
> "moduleBase"));
> - }
> -
> - @Override
> - protected Layout[] getStartLayouts() throws Exception {
> - ArrayList<Layout> layouts = new ArrayList<Layout>();
> - try {
> - for (GenericValue value:
> delegator.findByAnd("WebslingerServer",
> UtilMisc.toMap("loadAtStart", "Y"))) {
> - layouts.add(new OfbizLayout(value));
> - }
> - } catch (GenericEntityException e) {
> - }
> - return layouts.toArray(new Layout[layouts.size()]);
> - }
> -
> - @Override
> - public void initializeRequest(WebslingerServletContext context,
> HttpServletRequest request) {
> - request.setAttribute("servletContext", context);
> - Object delegator = context.getAttribute("delegator");
> - Object dispatcher = context.getAttribute("dispatcher");
> - Object authz = context.getAttribute("authz");
> - Object security = context.getAttribute("security");
> - request.setAttribute("delegator", delegator);
> - request.setAttribute("dispatcher", dispatcher);
> - request.setAttribute("authz", authz);
> - request.setAttribute("security", security);
> - // FIXME!!! These next two are a hack until proper fake/
> wrapped session support is done in webslinger
> - servletContext.setAttribute("delegator", delegator);
> - servletContext.setAttribute("dispatcher", dispatcher);
> - servletContext.setAttribute("authz", authz);
> - servletContext.setAttribute("security", security);
> - }
> -
> - @Override
> - protected void initializeContext(WebslingerServletContext
> context, Layout layout) throws Exception {
> - OfbizLayout ofbizLayout = (OfbizLayout) layout;
> - Delegator delegator = null;
> - delegator =
> DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
> - context.setAttribute("delegator", delegator);
> - context.setAttribute("dispatcher", new
> WebslingerGenericDispatcher(context, layout.getTarget(), delegator,
> globalReaderURLs));
> - context.setAttribute("authz",
> AuthorizationFactory.getInstance(delegator));
> - context.setAttribute("security",
> SecurityFactory.getInstance(delegator));
> - }
> -
> - protected static final class WebslingerGenericDispatcher
> extends GenericDispatcher {
> - protected
> WebslingerGenericDispatcher(WebslingerServletContext context, String
> name, Delegator delegator, List<URL> globalReaderURLs) throws
> IOException {
> - ArrayList<URL> readerURLs = new
> ArrayList<URL>(globalReaderURLs);
> - String readerFiles =
> context.getInitParameter("serviceReaderUrls");
> - if (readerFiles != null) {
> - for (String reader:
> CollectionUtil.split(readerFiles, ";")) {
> - URL url = context.getResource(reader);
> - if (url != null) readerURLs.add(url);
> - }
> - }
> - System.err.println(readerURLs);
> - this.dispatcher = new ServiceDispatcher(delegator,
> true, true, true) {
> - };
> - ClassLoader loader = null;
> - try {
> - loader =
> Thread.currentThread().getContextClassLoader();
> - } catch (SecurityException e) {
> - loader =
> WebslingerContextMapper.class.getClassLoader();
> - }
> - DispatchContext dc = new DispatchContext(name,
> readerURLs, loader, null);
> - init(name, delegator, dc);
> - }
> - }
> -
> - @Override
> - protected Set<String> getSuffixes() throws Exception {
> - Cache cache = delegator.getCache();
> - Set<String> suffixes;
> - synchronized (WebslingerContextMapper.class) {
> - suffixes = cache.get("WebslingerHostSuffix", null,
> "WebslingerContextMapper.Suffixes");
> - if (suffixes == null) {
> - suffixes = new HashSet<String>();
> - for (GenericValue value:
> delegator.findList("WebslingerHostSuffix", null, null, null, null,
> false)) {
> - suffixes.add(value.getString("hostSuffix"));
> - }
> - cache.put("WebslingerHostSuffix", null,
> "WebslingerContextMapper.Suffixes", suffixes);
> - }
> - }
> - return suffixes;
> - }
> -
> - @Override
> - protected Layout lookupLayout(String hostName, String
> contextPath) throws Exception {
> - GenericValue layout =
> EntityUtil.getOnly(delegator.findByAndCache("WebslingerLayout",
> UtilMisc.toMap("hostName", hostName, "contextPath", contextPath)));
> - if (layout == null) return null;
> - return new OfbizLayout(layout);
> - }
> -
> - protected class OfbizLayout implements Layout {
> - private final String contextPath;
> - private final String id;
> - private final String target;
> - private final String[] bases;
> - private final int hashCode;
> - protected final String delegatorName;
> - protected final String dispatcherName;
> -
> - protected OfbizLayout(GenericValue server) throws
> GenericEntityException {
> - contextPath = server.getString("contextPath");
> - id = server.getString("webslingerServerId");
> - target = server.getString("target");
> - List<GenericValue> baseValues =
> server.getRelatedCache("WebslingerServerBase",
> UtilMisc.toList("seqNum"));
> - bases = new String[baseValues.size()];
> - for (int i = 0; i < bases.length; i++) {
> - GenericValue baseValue = baseValues.get(i);
> - bases[i] = baseValue.getString("baseName");
> - }
> - delegatorName = server.getString("delegatorName");
> - dispatcherName = server.getString("dispatcherName");
> - hashCode = target.hashCode() ^
> ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
> - }
> -
> - public String getContextPath() {
> - return contextPath;
> - }
> -
> - public String getId() {
> - return id;
> - }
> -
> - public String getTarget() {
> - return target;
> - }
> -
> - public String[] getBases() {
> - return bases;
> - }
> -
> - @Override
> - public int hashCode() {
> - return hashCode;
> - }
> -
> - @Override
> - public boolean equals(Object o) {
> - if (!(o instanceof OfbizLayout)) return false;
> - OfbizLayout other = (OfbizLayout) o;
> - if (!contextPath.equals(other.contextPath)) return false;
> - if (!target.equals(other.target)) return false;
> - if (!ObjectUtil.equalsHelper(delegatorName,
> other.delegatorName)) return false;
> - return Arrays.equals(bases, other.bases);
> - }
> - }
> -}
> +/
> *******************************************************************************
> + * 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.webslinger;
> +
> +import java.io.IOException;
> +import java.net.URL;
> +import java.util.ArrayList;
> +import java.util.Arrays;
> +import java.util.HashSet;
> +import java.util.List;
> +import java.util.Set;
> +
> +import javax.servlet.ServletConfig;
> +import javax.servlet.ServletContext;
> +import javax.servlet.ServletException;
> +import javax.servlet.http.HttpServletRequest;
> +
> +import org.ofbiz.base.util.UtilMisc;
> +import org.ofbiz.base.util.UtilProperties;
> +import org.ofbiz.entity.Delegator;
> +import org.ofbiz.entity.DelegatorFactory;
> +import org.ofbiz.entity.GenericEntityException;
> +import org.ofbiz.entity.GenericValue;
> +import org.ofbiz.entity.cache.Cache;
> +import org.ofbiz.entity.util.EntityUtil;
> +import org.ofbiz.security.SecurityFactory;
> +import org.ofbiz.security.authz.AuthorizationFactory;
> +import org.ofbiz.service.DispatchContext;
> +import org.ofbiz.service.GenericDispatcher;
> +import org.ofbiz.service.ServiceDispatcher;
> +import org.webslinger.AbstractMappingWebslingerServletContextFactory;
> +import org.webslinger.WebslingerServletContext;
> +import org.webslinger.collections.CollectionUtil;
> +import org.webslinger.lang.ObjectUtil;
> +
> +public class WebslingerContextMapper extends
> AbstractMappingWebslingerServletContextFactory {
> + protected ServletContext servletContext;
> + protected Delegator delegator;
> + protected final ArrayList<URL> globalReaderURLs = new
> ArrayList<URL>();
> +
> + public void init(ServletConfig config) throws ServletException,
> IOException {
> +
> System
> .err.println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
> + servletContext = config.getServletContext();
> + String delegatorName =
> servletContext.getInitParameter("entityDelegatorName");
> + delegator = DelegatorFactory.getDelegator(delegatorName);
> + String readerFiles =
> servletContext.getInitParameter("serviceReaderUrls");
> + if (readerFiles != null) {
> + for (String reader: CollectionUtil.split(readerFiles,
> ";")) {
> + URL url =
> config.getServletContext().getResource(reader);
> + if (url != null) globalReaderURLs.add(url);
> + }
> + }
> + super.init(config,
> UtilProperties.getPropertyValue("webslinger.properties",
> "moduleBase"));
> + }
> +
> + @Override
> + protected Layout[] getStartLayouts() throws Exception {
> + ArrayList<Layout> layouts = new ArrayList<Layout>();
> + try {
> + for (GenericValue value:
> delegator.findByAnd("WebslingerServer",
> UtilMisc.toMap("loadAtStart", "Y"))) {
> + layouts.add(new OfbizLayout(value));
> + }
> + } catch (GenericEntityException e) {
> + }
> + return layouts.toArray(new Layout[layouts.size()]);
> + }
> +
> + @Override
> + public void initializeRequest(WebslingerServletContext context,
> HttpServletRequest request) {
> + request.setAttribute("servletContext", context);
> + Object delegator = context.getAttribute("delegator");
> + Object dispatcher = context.getAttribute("dispatcher");
> + Object authz = context.getAttribute("authz");
> + Object security = context.getAttribute("security");
> + request.setAttribute("delegator", delegator);
> + request.setAttribute("dispatcher", dispatcher);
> + request.setAttribute("authz", authz);
> + request.setAttribute("security", security);
> + // FIXME!!! These next two are a hack until proper fake/
> wrapped session support is done in webslinger
> + servletContext.setAttribute("delegator", delegator);
> + servletContext.setAttribute("dispatcher", dispatcher);
> + servletContext.setAttribute("authz", authz);
> + servletContext.setAttribute("security", security);
> + }
> +
> + @Override
> + protected void initializeContext(WebslingerServletContext
> context, Layout layout) throws Exception {
> + OfbizLayout ofbizLayout = (OfbizLayout) layout;
> + Delegator delegator = null;
> + delegator =
> DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
> + context.setAttribute("delegator", delegator);
> + context.setAttribute("dispatcher", new
> WebslingerGenericDispatcher(context, layout.getTarget(), delegator,
> globalReaderURLs));
> + context.setAttribute("authz",
> AuthorizationFactory.getInstance(delegator));
> + context.setAttribute("security",
> SecurityFactory.getInstance(delegator));
> + }
> +
> + protected static final class WebslingerGenericDispatcher
> extends GenericDispatcher {
> + protected
> WebslingerGenericDispatcher(WebslingerServletContext context, String
> name, Delegator delegator, List<URL> globalReaderURLs) throws
> IOException {
> + ArrayList<URL> readerURLs = new
> ArrayList<URL>(globalReaderURLs);
> + String readerFiles =
> context.getInitParameter("serviceReaderUrls");
> + if (readerFiles != null) {
> + for (String reader:
> CollectionUtil.split(readerFiles, ";")) {
> + URL url = context.getResource(reader);
> + if (url != null) readerURLs.add(url);
> + }
> + }
> + System.err.println(readerURLs);
> + this.dispatcher = new ServiceDispatcher(delegator,
> true, true, true) {
> + };
> + ClassLoader loader = null;
> + try {
> + loader =
> Thread.currentThread().getContextClassLoader();
> + } catch (SecurityException e) {
> + loader =
> WebslingerContextMapper.class.getClassLoader();
> + }
> + DispatchContext dc = new DispatchContext(name,
> readerURLs, loader, null);
> + init(name, delegator, dc);
> + }
> + }
> +
> + @Override
> + protected Set<String> getSuffixes() throws Exception {
> + Cache cache = delegator.getCache();
> + Set<String> suffixes;
> + synchronized (WebslingerContextMapper.class) {
> + suffixes = cache.get("WebslingerHostSuffix", null,
> "WebslingerContextMapper.Suffixes");
> + if (suffixes == null) {
> + suffixes = new HashSet<String>();
> + for (GenericValue value:
> delegator.findList("WebslingerHostSuffix", null, null, null, null,
> false)) {
> + suffixes.add(value.getString("hostSuffix"));
> + }
> + cache.put("WebslingerHostSuffix", null,
> "WebslingerContextMapper.Suffixes", suffixes);
> + }
> + }
> + return suffixes;
> + }
> +
> + @Override
> + protected Layout lookupLayout(String hostName, String
> contextPath) throws Exception {
> + GenericValue layout =
> EntityUtil.getOnly(delegator.findByAndCache("WebslingerLayout",
> UtilMisc.toMap("hostName", hostName, "contextPath", contextPath)));
> + if (layout == null) return null;
> + return new OfbizLayout(layout);
> + }
> +
> + protected class OfbizLayout implements Layout {
> + private final String contextPath;
> + private final String id;
> + private final String target;
> + private final String[] bases;
> + private final int hashCode;
> + protected final String delegatorName;
> + protected final String dispatcherName;
> +
> + protected OfbizLayout(GenericValue server) throws
> GenericEntityException {
> + contextPath = server.getString("contextPath");
> + id = server.getString("webslingerServerId");
> + target = server.getString("target");
> + List<GenericValue> baseValues =
> server.getRelatedCache("WebslingerServerBase",
> UtilMisc.toList("seqNum"));
> + bases = new String[baseValues.size()];
> + for (int i = 0; i < bases.length; i++) {
> + GenericValue baseValue = baseValues.get(i);
> + bases[i] = baseValue.getString("baseName");
> + }
> + delegatorName = server.getString("delegatorName");
> + dispatcherName = server.getString("dispatcherName");
> + hashCode = target.hashCode() ^
> ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
> + }
> +
> + public String getContextPath() {
> + return contextPath;
> + }
> +
> + public String getId() {
> + return id;
> + }
> +
> + public String getTarget() {
> + return target;
> + }
> +
> + public String[] getBases() {
> + return bases;
> + }
> +
> + @Override
> + public int hashCode() {
> + return hashCode;
> + }
> +
> + @Override
> + public boolean equals(Object o) {
> + if (!(o instanceof OfbizLayout)) return false;
> + OfbizLayout other = (OfbizLayout) o;
> + if (!contextPath.equals(other.contextPath)) return false;
> + if (!target.equals(other.target)) return false;
> + if (!ObjectUtil.equalsHelper(delegatorName,
> other.delegatorName)) return false;
> + return Arrays.equals(bases, other.bases);
> + }
> + }
> +}
>
> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> WebslingerServerEngine.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java?rev=833727&r1=833726&r2=833727&view=diff
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> WebslingerServerEngine.java (original)
> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
> WebslingerServerEngine.java Sat Nov 7 18:18:33 2009
> @@ -1,64 +1,59 @@
> -/
> *******************************************************************************
> - * 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.webslinger;
> -
> -import java.io.IOException;
> -import java.io.StringReader;
> -import java.io.StringWriter;
> -import java.util.Collections;
> -import java.util.Map;
> -
> -import org.ofbiz.base.util.UtilGenerics;
> -import org.ofbiz.base.util.UtilMisc;
> -import org.ofbiz.entity.Delegator;
> -import org.ofbiz.entity.GenericValue;
> -import org.ofbiz.entity.util.EntityUtil;
> -import org.ofbiz.service.GenericServiceException;
> -import org.ofbiz.service.ModelService;
> -import org.ofbiz.service.ServiceDispatcher;
> -import org.ofbiz.service.engine.GenericAsyncEngine;
> -
> -import org.webslinger.WebslingerServletContext;
> -
> -public class WebslingerServerEngine extends GenericAsyncEngine {
> - public WebslingerServerEngine(ServiceDispatcher dispatcher) {
> - super(dispatcher);
> - }
> -
> - @Override
> - public void runSyncIgnore(String localName, ModelService
> modelService, Map<String, Object> context) throws
> GenericServiceException {
> - runSync(localName, modelService, context);
> - }
> -
> - @Override
> - public Map<String, Object> runSync(String localName,
> ModelService modelService, Map<String, Object> context) throws
> GenericServiceException {
> - Delegator delegator = dispatcher.getDelegator();
> - try {
> - GenericValue found =
> EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout",
> UtilMisc.toMap("webslingerServerId", modelService.location)));
> - if (found == null) throw new
> GenericServiceException("Couldn't find server mapping for(" +
> modelService.location + ")");
> - return
> UtilGenerics
> .checkMap
> (WebslingerServletContext.invokeInVM(found.getString("hostName"),
> 8080, modelService.invoke, context));
> - } catch (RuntimeException e) {
> - throw e;
> - } catch (GenericServiceException e) {
> - throw e;
> - } catch (Exception e) {
> - throw UtilMisc.initCause(new
> GenericServiceException(e.getMessage()), e);
> - }
> - }
> -}
> +/
> *******************************************************************************
> + * 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.webslinger;
> +
> +import java.util.Map;
> +
> +import org.ofbiz.base.util.UtilGenerics;
> +import org.ofbiz.base.util.UtilMisc;
> +import org.ofbiz.entity.Delegator;
> +import org.ofbiz.entity.GenericValue;
> +import org.ofbiz.entity.util.EntityUtil;
> +import org.ofbiz.service.GenericServiceException;
> +import org.ofbiz.service.ModelService;
> +import org.ofbiz.service.ServiceDispatcher;
> +import org.ofbiz.service.engine.GenericAsyncEngine;
> +import org.webslinger.WebslingerServletContext;
> +
> +public class WebslingerServerEngine extends GenericAsyncEngine {
> + public WebslingerServerEngine(ServiceDispatcher dispatcher) {
> + super(dispatcher);
> + }
> +
> + @Override
> + public void runSyncIgnore(String localName, ModelService
> modelService, Map<String, Object> context) throws
> GenericServiceException {
> + runSync(localName, modelService, context);
> + }
> +
> + @Override
> + public Map<String, Object> runSync(String localName,
> ModelService modelService, Map<String, Object> context) throws
> GenericServiceException {
> + Delegator delegator = dispatcher.getDelegator();
> + try {
> + GenericValue found =
> EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout",
> UtilMisc.toMap("webslingerServerId", modelService.location)));
> + if (found == null) throw new
> GenericServiceException("Couldn't find server mapping for(" +
> modelService.location + ")");
> + return
> UtilGenerics
> .checkMap
> (WebslingerServletContext.invokeInVM(found.getString("hostName"),
> 8080, modelService.invoke, context));
> + } catch (RuntimeException e) {
> + throw e;
> + } catch (GenericServiceException e) {
> + throw e;
> + } catch (Exception e) {
> + throw UtilMisc.initCause(new
> GenericServiceException(e.getMessage()), e);
> + }
> + }
> +}
>
>
Re: svn commit: r833727 - in /ofbiz/trunk/framework/webslinger/src/org/ofbiz: commons/vfs/ commons/vfs/ofbiz/ webslinger/
Posted by Jacques Le Roux <ja...@les7arts.com>.
Hi Scott,
Yes, this is certainly because the person who commited them in 1st place has not his svn config file properly set.
It was not me, but with the setting I had (and was not aware since I did not think it could be changed without mentionning) it could
have been me.
So please commiters, like me, check your svn config file and compare with http://ofbiz.apache.org/svn/config
Thanks
Jacques
From: "Scott Gray" <sc...@hotwaxmedia.com>
> Hi Jacques
>
> I was referring to the svn properties on the files being committed rather than the svn config.
>
> Regards
> Scott
>
> On 10/11/2009, at 1:07 AM, Jacques Le Roux wrote:
>
>> I replaced my .subversion/config by ours. Not sure why it has been replaced, by an install maybe or as I'm on Windows, Tortoise
>> while changing the setting...
>>
>> Jacques
>>
>> From: "Scott Gray" <sc...@hotwaxmedia.com>
>>> Hi Jacques,
>>>
>>> I think the problem is related to files in svn that do not have any svn properties set (specifically eol-style), I just came
>>> across this myself in r833931 and r833933. When I initially applied the patch the entire file changed but after setting the
>>> svn properties the issue went away.
>>>
>>> Regards
>>> Scott
>>>
>>> On 9/11/2009, at 11:32 AM, Jacques Le Roux wrote:
>>>
>>>> Sorry Scott,
>>>>
>>>> I have still not got the reflex... As I have not touched the patch (ok you have to trust me) you may review the patch
>>>> itself...
>>>>
>>>> Jacques
>>>>
>>>> From: "Scott Gray" <sc...@hotwaxmedia.com>
>>>>> Hi Jacques,
>>>>>
>>>>> This is that same problem with the patch again, please keep an eye out for these as the commits are impossible to review.
>>>>>
>>>>> Thanks
>>>>> Scott
>>>>>
>>>>> HotWax Media
>>>>> http://www.hotwaxmedia.com
>>>>>
>>>>> On 8/11/2009, at 7:18 AM, jleroux@apache.org wrote:
>>>>>
>>>>>> Author: jleroux
>>>>>> Date: Sat Nov 7 18:18:33 2009
>>>>>> New Revision: 833727
>>>>>>
>>>>>> URL: http://svn.apache.org/viewvc?rev=833727&view=rev
>>>>>> Log:
>>>>>> A patch from Marc Morin "Resolve java warnings exposed in Eclipse : framework - webslinger"
>>>>>> (https://issues.apache.org/jira/browse/OFBIZ-3121 ) - OFBIZ-3121
>>>>>>
>>>>>> Modified:
>>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ CommonsVfsContainer.java
>>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/ OfbizComponentProvider.java
>>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/ OfbizHomeProvider.java
>>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ EntityHttpUtil.java
>>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ StatsUpdater.java
>>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerContextMapper.java
>>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerServerEngine.java
>>>>>>
>>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/ commons/ vfs/ CommonsVfsContainer.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>>> = = = = = = = = = = = = ==================================================================
>>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ CommonsVfsContainer.java (original)
>>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ CommonsVfsContainer.java Sat Nov 7 18:18:33 2009
>>>>>> @@ -1,68 +1,66 @@
>>>>>> -/ *******************************************************************************
>>>>>> - * 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.commons.vfs;
>>>>>> -
>>>>>> -import java.io.File;
>>>>>> -import java.io.IOException;
>>>>>> -import java.net.MalformedURLException;
>>>>>> -
>>>>>> -import org.apache.commons.vfs.CacheStrategy;
>>>>>> -import org.apache.commons.vfs.FileObject;
>>>>>> -import org.apache.commons.vfs.FileSystemException;
>>>>>> -import org.apache.commons.vfs.FileSystemManager;
>>>>>> -import org.apache.commons.vfs.impl.StandardFileSystemManager;
>>>>>> -
>>>>>> -import org.ofbiz.base.container.Container;
>>>>>> -import org.ofbiz.base.container.ContainerException;
>>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>>> -import org.webslinger.commons.vfs.VFSUtil;
>>>>>> -
>>>>>> -public class CommonsVfsContainer implements Container {
>>>>>> - private static StandardFileSystemManager sfsm;
>>>>>> -
>>>>>> - public void init(String[] args, String configFile) throws ContainerException {
>>>>>> - }
>>>>>> -
>>>>>> - public boolean start() throws ContainerException {
>>>>>> - try {
>>>>>> - StandardFileSystemManager sfsm = VFSUtil.createStandardFileSystemManager();
>>>>>> - FileObject currentDir = sfsm.resolveFile(new File(".").toURI().toURL().toString());
>>>>>> - sfsm.setBaseFile(currentDir);
>>>>>> - CommonsVfsContainer.sfsm = sfsm;
>>>>>> - } catch (FileSystemException e) {
>>>>>> - throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
>>>>>> - } catch (MalformedURLException e) {
>>>>>> - throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
>>>>>> - }
>>>>>> - return true;
>>>>>> - }
>>>>>> -
>>>>>> - public void stop() throws ContainerException {
>>>>>> - sfsm.close();
>>>>>> - sfsm = null;
>>>>>> - }
>>>>>> -
>>>>>> - public static FileObject resolveFile(String uri) throws IOException {
>>>>>> - return sfsm.resolveFile(uri);
>>>>>> - }
>>>>>> -
>>>>>> - public static FileSystemManager getFileSystemManager() {
>>>>>> - return sfsm;
>>>>>> - }
>>>>>> -}
>>>>>> +/ *******************************************************************************
>>>>>> + * 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.commons.vfs;
>>>>>> +
>>>>>> +import java.io.File;
>>>>>> +import java.io.IOException;
>>>>>> +import java.net.MalformedURLException;
>>>>>> +
>>>>>> +import org.apache.commons.vfs.FileObject;
>>>>>> +import org.apache.commons.vfs.FileSystemException;
>>>>>> +import org.apache.commons.vfs.FileSystemManager;
>>>>>> +import org.apache.commons.vfs.impl.StandardFileSystemManager;
>>>>>> +import org.ofbiz.base.container.Container;
>>>>>> +import org.ofbiz.base.container.ContainerException;
>>>>>> +import org.ofbiz.base.util.UtilMisc;
>>>>>> +import org.webslinger.commons.vfs.VFSUtil;
>>>>>> +
>>>>>> +public class CommonsVfsContainer implements Container {
>>>>>> + private static StandardFileSystemManager sfsm;
>>>>>> +
>>>>>> + public void init(String[] args, String configFile) throws ContainerException {
>>>>>> + }
>>>>>> +
>>>>>> + public boolean start() throws ContainerException {
>>>>>> + try {
>>>>>> + StandardFileSystemManager sfsm = VFSUtil.createStandardFileSystemManager();
>>>>>> + FileObject currentDir = sfsm.resolveFile(new File(".").toURI().toURL().toString());
>>>>>> + sfsm.setBaseFile(currentDir);
>>>>>> + CommonsVfsContainer.sfsm = sfsm;
>>>>>> + } catch (FileSystemException e) {
>>>>>> + throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
>>>>>> + } catch (MalformedURLException e) {
>>>>>> + throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
>>>>>> + }
>>>>>> + return true;
>>>>>> + }
>>>>>> +
>>>>>> + public void stop() throws ContainerException {
>>>>>> + sfsm.close();
>>>>>> + sfsm = null;
>>>>>> + }
>>>>>> +
>>>>>> + public static FileObject resolveFile(String uri) throws IOException {
>>>>>> + return sfsm.resolveFile(uri);
>>>>>> + }
>>>>>> +
>>>>>> + public static FileSystemManager getFileSystemManager() {
>>>>>> + return sfsm;
>>>>>> + }
>>>>>> +}
>>>>>>
>>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/ commons/ vfs/ ofbiz/OfbizComponentProvider.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>>> = = = = = = = = = = = = ==================================================================
>>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/ OfbizComponentProvider.java (original)
>>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/ OfbizComponentProvider.java Sat Nov 7 18:18:33 2009
>>>>>> @@ -1,58 +1,58 @@
>>>>>> -/ *******************************************************************************
>>>>>> - * 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.commons.vfs.ofbiz;
>>>>>> -
>>>>>> -import java.net.URL;
>>>>>> -import java.util.Collection;
>>>>>> -import org.apache.commons.vfs.FileObject;
>>>>>> -import org.apache.commons.vfs.FileSystemException;
>>>>>> -import org.apache.commons.vfs.FileSystemOptions;
>>>>>> -import org.apache.commons.vfs.provider.AbstractFileProvider;
>>>>>> -import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>>>>> -import org.ofbiz.base.location.FlexibleLocation;
>>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>>> -import org.webslinger.commons.vfs.VFSUtil;
>>>>>> -
>>>>>> -public class OfbizComponentProvider extends AbstractFileProvider {
>>>>>> - public Collection getCapabilities() {
>>>>>> - return DefaultLocalFileProvider.capabilities;
>>>>>> - }
>>>>>> -
>>>>>> - public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
>>>>>> - try {
>>>>>> - //name = name.replaceAll("^ofbiz-component://", "");
>>>>>> - int nameLength = name.length();
>>>>>> - int componentNameStart = 16;
>>>>>> - while (componentNameStart < nameLength && name.charAt(componentNameStart) == '/') componentNameStart++;
>>>>>> - if (componentNameStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>>>>>> - int componentNameEnd = componentNameStart;
>>>>>> - while (componentNameEnd < nameLength && name.charAt(componentNameEnd) != '/') componentNameEnd++;
>>>>>> - if (componentNameEnd == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>>>>>> - int restStart = componentNameEnd;
>>>>>> - while (restStart < nameLength && name.charAt(restStart) == '/') restStart++;
>>>>>> - if (restStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>>>>>> - String componentName = name.substring(componentNameStart, componentNameEnd);
>>>>>> - URL location = FlexibleLocation.resolveLocation("component://" + componentName + "/.");
>>>>>> - FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
>>>>>> - return VFSUtil .toFileObject (ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase
>>>>>> .resolveFile(name.substring(restStart)).getURL().toString(), properties);
>>>>>> - } catch (Exception e) {
>>>>>> - throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
>>>>>> - }
>>>>>> - }
>>>>>> -}
>>>>>> +/ *******************************************************************************
>>>>>> + * 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.commons.vfs.ofbiz;
>>>>>> +
>>>>>> +import java.net.URL;
>>>>>> +import java.util.Collection;
>>>>>> +import org.apache.commons.vfs.FileObject;
>>>>>> +import org.apache.commons.vfs.FileSystemException;
>>>>>> +import org.apache.commons.vfs.FileSystemOptions;
>>>>>> +import org.apache.commons.vfs.provider.AbstractFileProvider;
>>>>>> +import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>>>>> +import org.ofbiz.base.location.FlexibleLocation;
>>>>>> +import org.ofbiz.base.util.UtilMisc;
>>>>>> +import org.webslinger.commons.vfs.VFSUtil;
>>>>>> +
>>>>>> +public class OfbizComponentProvider extends AbstractFileProvider {
>>>>>> + public Collection<?> getCapabilities() {
>>>>>> + return DefaultLocalFileProvider.capabilities;
>>>>>> + }
>>>>>> +
>>>>>> + public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
>>>>>> + try {
>>>>>> + //name = name.replaceAll("^ofbiz-component://", "");
>>>>>> + int nameLength = name.length();
>>>>>> + int componentNameStart = 16;
>>>>>> + while (componentNameStart < nameLength && name.charAt(componentNameStart) == '/') componentNameStart++;
>>>>>> + if (componentNameStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>>>>>> + int componentNameEnd = componentNameStart;
>>>>>> + while (componentNameEnd < nameLength && name.charAt(componentNameEnd) != '/') componentNameEnd++;
>>>>>> + if (componentNameEnd == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>>>>>> + int restStart = componentNameEnd;
>>>>>> + while (restStart < nameLength && name.charAt(restStart) == '/') restStart++;
>>>>>> + if (restStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>>>>>> + String componentName = name.substring(componentNameStart, componentNameEnd);
>>>>>> + URL location = FlexibleLocation.resolveLocation("component://" + componentName + "/.");
>>>>>> + FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
>>>>>> + return VFSUtil .toFileObject (ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase
>>>>>> .resolveFile(name.substring(restStart)).getURL().toString(), properties);
>>>>>> + } catch (Exception e) {
>>>>>> + throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
>>>>>> + }
>>>>>> + }
>>>>>> +}
>>>>>>
>>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/ commons/ vfs/ ofbiz/OfbizHomeProvider.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>>> = = = = = = = = = = = = ==================================================================
>>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/ OfbizHomeProvider.java (original)
>>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/ OfbizHomeProvider.java Sat Nov 7 18:18:33 2009
>>>>>> @@ -1,50 +1,50 @@
>>>>>> -/ *******************************************************************************
>>>>>> - * 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.commons.vfs.ofbiz;
>>>>>> -
>>>>>> -import java.net.URL;
>>>>>> -import java.util.Collection;
>>>>>> -
>>>>>> -import org.apache.commons.vfs.FileObject;
>>>>>> -import org.apache.commons.vfs.FileSystemException;
>>>>>> -import org.apache.commons.vfs.FileSystemOptions;
>>>>>> -import org.apache.commons.vfs.provider.AbstractFileProvider;
>>>>>> -import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>>>>> -
>>>>>> -import org.ofbiz.base.location.FlexibleLocation;
>>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>>> -
>>>>>> -import org.webslinger.commons.vfs.VFSUtil;
>>>>>> -
>>>>>> -public class OfbizHomeProvider extends AbstractFileProvider {
>>>>>> - public Collection getCapabilities() {
>>>>>> - return DefaultLocalFileProvider.capabilities;
>>>>>> - }
>>>>>> -
>>>>>> - public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
>>>>>> - //new Exception("findFile(" + base + ", " + name + ")").printStackTrace();
>>>>>> - try {
>>>>>> - URL location = FlexibleLocation.resolveLocation("ofbizhome://.");
>>>>>> - FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
>>>>>> - return VFSUtil .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
>>>>>> ofbizBase.resolveFile(name.substring(13)).getURL().toString(), properties);
>>>>>> - } catch (Exception e) {
>>>>>> - throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
>>>>>> - }
>>>>>> - }
>>>>>> -}
>>>>>> +/ *******************************************************************************
>>>>>> + * 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.commons.vfs.ofbiz;
>>>>>> +
>>>>>> +import java.net.URL;
>>>>>> +import java.util.Collection;
>>>>>> +
>>>>>> +import org.apache.commons.vfs.FileObject;
>>>>>> +import org.apache.commons.vfs.FileSystemException;
>>>>>> +import org.apache.commons.vfs.FileSystemOptions;
>>>>>> +import org.apache.commons.vfs.provider.AbstractFileProvider;
>>>>>> +import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>>>>> +
>>>>>> +import org.ofbiz.base.location.FlexibleLocation;
>>>>>> +import org.ofbiz.base.util.UtilMisc;
>>>>>> +
>>>>>> +import org.webslinger.commons.vfs.VFSUtil;
>>>>>> +
>>>>>> +public class OfbizHomeProvider extends AbstractFileProvider {
>>>>>> + public Collection<?> getCapabilities() {
>>>>>> + return DefaultLocalFileProvider.capabilities;
>>>>>> + }
>>>>>> +
>>>>>> + public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
>>>>>> + //new Exception("findFile(" + base + ", " + name + ")").printStackTrace();
>>>>>> + try {
>>>>>> + URL location = FlexibleLocation.resolveLocation("ofbizhome://.");
>>>>>> + FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
>>>>>> + return VFSUtil .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
>>>>>> ofbizBase.resolveFile(name.substring(13)).getURL().toString(), properties);
>>>>>> + } catch (Exception e) {
>>>>>> + throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
>>>>>> + }
>>>>>> + }
>>>>>> +}
>>>>>>
>>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/ webslinger/ EntityHttpUtil.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/EntityHttpUtil.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>>> = = = = = = = = = = = = ==================================================================
>>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ EntityHttpUtil.java (original)
>>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ EntityHttpUtil.java Sat Nov 7 18:18:33 2009
>>>>>> @@ -1,78 +1,73 @@
>>>>>> -/ *******************************************************************************
>>>>>> - * 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.webslinger;
>>>>>> -
>>>>>> -import java.util.HashMap;
>>>>>> -import java.util.Iterator;
>>>>>> -import java.util.Locale;
>>>>>> -import java.util.Map;
>>>>>> -
>>>>>> -import javax.servlet.ServletRequest;
>>>>>> -import javax.servlet.http.HttpServletRequest;
>>>>>> -
>>>>>> -import org.ofbiz.base.util.GeneralException;
>>>>>> -import org.ofbiz.base.util.ObjectType;
>>>>>> -import org.ofbiz.base.util.UtilHttp;
>>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>>> -import org.ofbiz.base.util.UtilValidate;
>>>>>> -import org.ofbiz.entity.Delegator;
>>>>>> -import org.ofbiz.entity.GenericValue;
>>>>>> -import org.ofbiz.entity.jdbc.SqlJdbcUtil;
>>>>>> -import org.ofbiz.entity.model.ModelEntity;
>>>>>> -import org.ofbiz.entity.model.ModelField;
>>>>>> -import org.ofbiz.entity.model.ModelFieldType;
>>>>>> -
>>>>>> -public class EntityHttpUtil {
>>>>>> - public static GenericValue makeValidValue(String entityName, ServletRequest request) throws GeneralException {
>>>>>> - return makeValidValue(entityName, false, request);
>>>>>> - }
>>>>>> -
>>>>>> - public static GenericValue makeValidValue(String entityName, boolean includePks, ServletRequest request) throws
>>>>>> GeneralException {
>>>>>> - if (request instanceof HttpServletRequest) return makeValidValue(entityName, includePks, (HttpServletRequest)
>>>>>> request);
>>>>>> - throw new IllegalArgumentException("Not an HttpServletRequest");
>>>>>> - }
>>>>>> -
>>>>>> - public static GenericValue makeValidValue(String entityName, HttpServletRequest request) throws GeneralException {
>>>>>> - return makeValidValue(entityName, false, request);
>>>>>> - }
>>>>>> -
>>>>>> - public static GenericValue makeValidValue(String entityName, boolean includePks, HttpServletRequest request) throws
>>>>>> GeneralException {
>>>>>> - Delegator delegator = (Delegator) request.getAttribute("delegator");
>>>>>> - GenericValue value = delegator.makeValue(entityName);
>>>>>> - ModelEntity model = value.getModelEntity();
>>>>>> - Iterator<ModelField> it = includePks ? model.getFieldsIterator() : model.getNopksIterator();
>>>>>> - Locale locale = UtilHttp.getLocale(request);
>>>>>> - while (it.hasNext()) {
>>>>>> - ModelField field = it.next();
>>>>>> - String fieldName = field.getName();
>>>>>> - String parameterValue = request.getParameter(fieldName);
>>>>>> - Object fieldValue;
>>>>>> - if (parameterValue == null) {
>>>>>> - fieldValue = null;
>>>>>> - } else {
>>>>>> - ModelFieldType fieldType = delegator.getEntityFieldType(model, field.getType());
>>>>>> - String wantedType = fieldType.getJavaType();
>>>>>> - fieldValue = ObjectType.simpleTypeConvert(parameterValue, wantedType, null, locale, true);
>>>>>> - }
>>>>>> - value.put(fieldName, fieldValue);
>>>>>> - }
>>>>>> - return value;
>>>>>> - }
>>>>>> -}
>>>>>> -
>>>>>> +/ *******************************************************************************
>>>>>> + * 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.webslinger;
>>>>>> +
>>>>>> +import java.util.Iterator;
>>>>>> +import java.util.Locale;
>>>>>> +
>>>>>> +import javax.servlet.ServletRequest;
>>>>>> +import javax.servlet.http.HttpServletRequest;
>>>>>> +
>>>>>> +import org.ofbiz.base.util.GeneralException;
>>>>>> +import org.ofbiz.base.util.ObjectType;
>>>>>> +import org.ofbiz.base.util.UtilHttp;
>>>>>> +import org.ofbiz.entity.Delegator;
>>>>>> +import org.ofbiz.entity.GenericValue;
>>>>>> +import org.ofbiz.entity.model.ModelEntity;
>>>>>> +import org.ofbiz.entity.model.ModelField;
>>>>>> +import org.ofbiz.entity.model.ModelFieldType;
>>>>>> +
>>>>>> +public class EntityHttpUtil {
>>>>>> + public static GenericValue makeValidValue(String entityName, ServletRequest request) throws GeneralException {
>>>>>> + return makeValidValue(entityName, false, request);
>>>>>> + }
>>>>>> +
>>>>>> + public static GenericValue makeValidValue(String entityName, boolean includePks, ServletRequest request) throws
>>>>>> GeneralException {
>>>>>> + if (request instanceof HttpServletRequest) return makeValidValue(entityName, includePks, (HttpServletRequest)
>>>>>> request);
>>>>>> + throw new IllegalArgumentException("Not an HttpServletRequest");
>>>>>> + }
>>>>>> +
>>>>>> + public static GenericValue makeValidValue(String entityName, HttpServletRequest request) throws GeneralException {
>>>>>> + return makeValidValue(entityName, false, request);
>>>>>> + }
>>>>>> +
>>>>>> + public static GenericValue makeValidValue(String entityName, boolean includePks, HttpServletRequest request) throws
>>>>>> GeneralException {
>>>>>> + Delegator delegator = (Delegator) request.getAttribute("delegator");
>>>>>> + GenericValue value = delegator.makeValue(entityName);
>>>>>> + ModelEntity model = value.getModelEntity();
>>>>>> + Iterator<ModelField> it = includePks ? model.getFieldsIterator() : model.getNopksIterator();
>>>>>> + Locale locale = UtilHttp.getLocale(request);
>>>>>> + while (it.hasNext()) {
>>>>>> + ModelField field = it.next();
>>>>>> + String fieldName = field.getName();
>>>>>> + String parameterValue = request.getParameter(fieldName);
>>>>>> + Object fieldValue;
>>>>>> + if (parameterValue == null) {
>>>>>> + fieldValue = null;
>>>>>> + } else {
>>>>>> + ModelFieldType fieldType = delegator.getEntityFieldType(model, field.getType());
>>>>>> + String wantedType = fieldType.getJavaType();
>>>>>> + fieldValue = ObjectType.simpleTypeConvert(parameterValue, wantedType, null, locale, true);
>>>>>> + }
>>>>>> + value.put(fieldName, fieldValue);
>>>>>> + }
>>>>>> + return value;
>>>>>> + }
>>>>>> +}
>>>>>> +
>>>>>>
>>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/ webslinger/ StatsUpdater.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>>> = = = = = = = = = = = = ==================================================================
>>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ StatsUpdater.java (original)
>>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ StatsUpdater.java Sat Nov 7 18:18:33 2009
>>>>>> @@ -1,121 +1,118 @@
>>>>>> -/ *******************************************************************************
>>>>>> - * 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.webslinger;
>>>>>> -
>>>>>> -import java.util.HashMap;
>>>>>> -import java.util.Iterator;
>>>>>> -import java.util.Map;
>>>>>> -import java.util.concurrent.Callable;
>>>>>> -import java.util.concurrent.ConcurrentHashMap;
>>>>>> -import java.util.concurrent.ScheduledFuture;
>>>>>> -import java.util.concurrent.TimeUnit;
>>>>>> -import java.util.concurrent.atomic.AtomicReference;
>>>>>> -
>>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>>> -import org.ofbiz.entity.Delegator;
>>>>>> -import org.ofbiz.entity.GenericEntityException;
>>>>>> -import org.ofbiz.entity.GenericPK;
>>>>>> -import org.ofbiz.entity.GenericValue;
>>>>>> -
>>>>>> -import org.webslinger.cache.ConcurrentCache;
>>>>>> -import org.webslinger.concurrent.ExecutionPool;
>>>>>> -
>>>>>> -public class StatsUpdater {
>>>>>> - private static final Updater UPDATER = new Updater();
>>>>>> -
>>>>>> - public static void updateStats(Delegator delegator, String entityName, Map<String, ? extends Object> keyFields,
>>>>>> Map<String, ? extends Long> updateCountFields) throws GenericEntityException {
>>>>>> - GenericPK pk = delegator.makePK(entityName, keyFields);
>>>>>> - Map<String, Long> value = UPDATER.getValue(pk);
>>>>>> - synchronized (value) {
>>>>>> - for (Map.Entry<String, ? extends Long> entry: updateCountFields.entrySet()) {
>>>>>> - Long oldValue = value.get(entry.getKey());
>>>>>> - if (oldValue != null) {
>>>>>> - value.put(entry.getKey(), Long.valueOf(oldValue.longValue() + entry.getValue()));
>>>>>> - } else {
>>>>>> - value.put(entry.getKey(), entry.getValue());
>>>>>> - }
>>>>>> - }
>>>>>> - }
>>>>>> - }
>>>>>> -
>>>>>> - private static final class Updater implements Callable<Void> {
>>>>>> - protected AtomicReference<EntityHolder> entities = new AtomicReference<EntityHolder>(new
>>>>>> EntityHolder(Updater.class, "entities", null));
>>>>>> - protected ScheduledFuture<Void> future;
>>>>>> -
>>>>>> - protected Map<String, Long> getValue(GenericPK pk) throws GenericEntityException {
>>>>>> - synchronized (this) {
>>>>>> - if (future == null || future.isDone()) {
>>>>>> - future = ExecutionPool.schedule(this, 1, TimeUnit.SECONDS);
>>>>>> - }
>>>>>> - }
>>>>>> - try {
>>>>>> - return entities.get().get(pk);
>>>>>> - } catch (RuntimeException e) {
>>>>>> - throw e;
>>>>>> - } catch (GenericEntityException e) {
>>>>>> - throw e;
>>>>>> - } catch (Exception e) {
>>>>>> - throw UtilMisc.initCause(new GenericEntityException(e.getMessage()), e);
>>>>>> - }
>>>>>> - }
>>>>>> -
>>>>>> - public Void call() {
>>>>>> - EntityHolder oldEntities;
>>>>>> - EntityHolder newEntities = new EntityHolder(Updater.class, "entities", null);
>>>>>> - do {
>>>>>> - oldEntities = entities.get();
>>>>>> - } while (!entities.compareAndSet(oldEntities, newEntities));
>>>>>> - synchronized (Updater.class) {
>>>>>> - for (GenericPK pk: oldEntities.keys()) {
>>>>>> - try {
>>>>>> - Map<String, Long> add = oldEntities.get(pk);
>>>>>> - GenericValue existing = pk.getDelegator().findOne(pk.getEntityName(), pk, false);
>>>>>> - if (existing == null) {
>>>>>> - existing = pk.getDelegator().create(pk.getEntityName(), pk);
>>>>>> - }
>>>>>> - for (Map.Entry<String, Long> entry: add.entrySet()) {
>>>>>> - Long value = entry.getValue();
>>>>>> - Long oldValue = existing.getLong(entry.getKey());
>>>>>> - if (oldValue != null) {
>>>>>> - existing.put(entry.getKey(), Long.valueOf(value.longValue() + oldValue.longValue()));
>>>>>> - } else {
>>>>>> - existing.put(entry.getKey(), value);
>>>>>> - }
>>>>>> - }
>>>>>> - existing.store();
>>>>>> - } catch (Exception e) {
>>>>>> - e.printStackTrace();
>>>>>> - }
>>>>>> - }
>>>>>> - }
>>>>>> - return null;
>>>>>> - }
>>>>>> - }
>>>>>> -
>>>>>> - private static final class EntityHolder extends ConcurrentCache<GenericPK, Map<String, Long>> {
>>>>>> - protected EntityHolder(Class<?> owner, String field, String label) {
>>>>>> - super(owner, field, label, HARD);
>>>>>> - }
>>>>>> -
>>>>>> - @Override
>>>>>> - protected Map<String, Long> createValue(GenericPK pk) throws Exception {
>>>>>> - return new HashMap<String, Long>();
>>>>>> - }
>>>>>> - }
>>>>>> -}
>>>>>> +/ *******************************************************************************
>>>>>> + * 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.webslinger;
>>>>>> +
>>>>>> +import java.util.HashMap;
>>>>>> +import java.util.Map;
>>>>>> +import java.util.concurrent.Callable;
>>>>>> +import java.util.concurrent.ScheduledFuture;
>>>>>> +import java.util.concurrent.TimeUnit;
>>>>>> +import java.util.concurrent.atomic.AtomicReference;
>>>>>> +
>>>>>> +import org.ofbiz.base.util.UtilMisc;
>>>>>> +import org.ofbiz.entity.Delegator;
>>>>>> +import org.ofbiz.entity.GenericEntityException;
>>>>>> +import org.ofbiz.entity.GenericPK;
>>>>>> +import org.ofbiz.entity.GenericValue;
>>>>>> +import org.webslinger.cache.ConcurrentCache;
>>>>>> +import org.webslinger.concurrent.ExecutionPool;
>>>>>> +
>>>>>> +public class StatsUpdater {
>>>>>> + private static final Updater UPDATER = new Updater();
>>>>>> +
>>>>>> + public static void updateStats(Delegator delegator, String entityName, Map<String, ? extends Object> keyFields,
>>>>>> Map<String, ? extends Long> updateCountFields) throws GenericEntityException {
>>>>>> + GenericPK pk = delegator.makePK(entityName, keyFields);
>>>>>> + Map<String, Long> value = UPDATER.getValue(pk);
>>>>>> + synchronized (value) {
>>>>>> + for (Map.Entry<String, ? extends Long> entry: updateCountFields.entrySet()) {
>>>>>> + Long oldValue = value.get(entry.getKey());
>>>>>> + if (oldValue != null) {
>>>>>> + value.put(entry.getKey(), Long.valueOf(oldValue.longValue() + entry.getValue()));
>>>>>> + } else {
>>>>>> + value.put(entry.getKey(), entry.getValue());
>>>>>> + }
>>>>>> + }
>>>>>> + }
>>>>>> + }
>>>>>> +
>>>>>> + private static final class Updater implements Callable<Void> {
>>>>>> + protected AtomicReference<EntityHolder> entities = new AtomicReference<EntityHolder>(new
>>>>>> EntityHolder(Updater.class, "entities", null));
>>>>>> + protected ScheduledFuture<Void> future;
>>>>>> +
>>>>>> + protected Map<String, Long> getValue(GenericPK pk) throws GenericEntityException {
>>>>>> + synchronized (this) {
>>>>>> + if (future == null || future.isDone()) {
>>>>>> + future = ExecutionPool.schedule(this, 1, TimeUnit.SECONDS);
>>>>>> + }
>>>>>> + }
>>>>>> + try {
>>>>>> + return entities.get().get(pk);
>>>>>> + } catch (RuntimeException e) {
>>>>>> + throw e;
>>>>>> + } catch (GenericEntityException e) {
>>>>>> + throw e;
>>>>>> + } catch (Exception e) {
>>>>>> + throw UtilMisc.initCause(new GenericEntityException(e.getMessage()), e);
>>>>>> + }
>>>>>> + }
>>>>>> +
>>>>>> + public Void call() {
>>>>>> + EntityHolder oldEntities;
>>>>>> + EntityHolder newEntities = new EntityHolder(Updater.class, "entities", null);
>>>>>> + do {
>>>>>> + oldEntities = entities.get();
>>>>>> + } while (!entities.compareAndSet(oldEntities, newEntities));
>>>>>> + synchronized (Updater.class) {
>>>>>> + for (GenericPK pk: oldEntities.keys()) {
>>>>>> + try {
>>>>>> + Map<String, Long> add = oldEntities.get(pk);
>>>>>> + GenericValue existing = pk.getDelegator().findOne(pk.getEntityName(), pk, false);
>>>>>> + if (existing == null) {
>>>>>> + existing = pk.getDelegator().create(pk.getEntityName(), pk);
>>>>>> + }
>>>>>> + for (Map.Entry<String, Long> entry: add.entrySet()) {
>>>>>> + Long value = entry.getValue();
>>>>>> + Long oldValue = existing.getLong(entry.getKey());
>>>>>> + if (oldValue != null) {
>>>>>> + existing.put(entry.getKey(), Long.valueOf(value.longValue() + oldValue.longValue()));
>>>>>> + } else {
>>>>>> + existing.put(entry.getKey(), value);
>>>>>> + }
>>>>>> + }
>>>>>> + existing.store();
>>>>>> + } catch (Exception e) {
>>>>>> + e.printStackTrace();
>>>>>> + }
>>>>>> + }
>>>>>> + }
>>>>>> + return null;
>>>>>> + }
>>>>>> + }
>>>>>> +
>>>>>> + private static final class EntityHolder extends ConcurrentCache<GenericPK, Map<String, Long>> {
>>>>>> + protected EntityHolder(Class<?> owner, String field, String label) {
>>>>>> + super(owner, field, label, HARD);
>>>>>> + }
>>>>>> +
>>>>>> + @Override
>>>>>> + protected Map<String, Long> createValue(GenericPK pk) throws Exception {
>>>>>> + return new HashMap<String, Long>();
>>>>>> + }
>>>>>> + }
>>>>>> +}
>>>>>>
>>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/ webslinger/ WebslingerContextMapper.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>>> = = = = = = = = = = = = ==================================================================
>>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerContextMapper.java (original)
>>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerContextMapper.java Sat Nov 7 18:18:33 2009
>>>>>> @@ -1,218 +1,216 @@
>>>>>> -/ *******************************************************************************
>>>>>> - * 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.webslinger;
>>>>>> -
>>>>>> -import java.io.IOException;
>>>>>> -import java.net.URL;
>>>>>> -import java.util.ArrayList;
>>>>>> -import java.util.Arrays;
>>>>>> -import java.util.HashSet;
>>>>>> -import java.util.List;
>>>>>> -import java.util.Set;
>>>>>> -
>>>>>> -import javax.servlet.ServletConfig;
>>>>>> -import javax.servlet.ServletContext;
>>>>>> -import javax.servlet.ServletException;
>>>>>> -import javax.servlet.http.HttpServletRequest;
>>>>>> -
>>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>>> -import org.ofbiz.base.util.UtilProperties;
>>>>>> -import org.ofbiz.entity.Delegator;
>>>>>> -import org.ofbiz.entity.DelegatorFactory;
>>>>>> -import org.ofbiz.entity.GenericEntityException;
>>>>>> -import org.ofbiz.entity.GenericValue;
>>>>>> -import org.ofbiz.entity.cache.Cache;
>>>>>> -import org.ofbiz.entity.util.EntityUtil;
>>>>>> -import org.ofbiz.security.SecurityFactory;
>>>>>> -import org.ofbiz.security.authz.AuthorizationFactory;
>>>>>> -import org.ofbiz.service.GenericDispatcher;
>>>>>> -import org.ofbiz.service.LocalDispatcher;
>>>>>> -import org.ofbiz.service.ServiceDispatcher;
>>>>>> -import org.ofbiz.service.DispatchContext;
>>>>>> -
>>>>>> -import org.webslinger.AbstractMappingWebslingerServletContextFactory;
>>>>>> -import org.webslinger.WebslingerServletContext;
>>>>>> -import org.webslinger.collections.CollectionUtil;
>>>>>> -import org.webslinger.lang.ObjectUtil;
>>>>>> -
>>>>>> -public class WebslingerContextMapper extends AbstractMappingWebslingerServletContextFactory {
>>>>>> - protected ServletContext servletContext;
>>>>>> - protected Delegator delegator;
>>>>>> - protected final ArrayList<URL> globalReaderURLs = new ArrayList<URL>();
>>>>>> -
>>>>>> - public void init(ServletConfig config) throws ServletException, IOException {
>>>>>> - System .err .println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
>>>>>> - servletContext = config.getServletContext();
>>>>>> - String delegatorName = servletContext.getInitParameter("entityDelegatorName");
>>>>>> - delegator = DelegatorFactory.getDelegator(delegatorName);
>>>>>> - String readerFiles = servletContext.getInitParameter("serviceReaderUrls");
>>>>>> - if (readerFiles != null) {
>>>>>> - for (String reader: CollectionUtil.split(readerFiles, ";")) {
>>>>>> - URL url = config.getServletContext().getResource(reader);
>>>>>> - if (url != null) globalReaderURLs.add(url);
>>>>>> - }
>>>>>> - }
>>>>>> - super.init(config, UtilProperties.getPropertyValue("webslinger.properties", "moduleBase"));
>>>>>> - }
>>>>>> -
>>>>>> - @Override
>>>>>> - protected Layout[] getStartLayouts() throws Exception {
>>>>>> - ArrayList<Layout> layouts = new ArrayList<Layout>();
>>>>>> - try {
>>>>>> - for (GenericValue value: delegator.findByAnd("WebslingerServer", UtilMisc.toMap("loadAtStart", "Y"))) {
>>>>>> - layouts.add(new OfbizLayout(value));
>>>>>> - }
>>>>>> - } catch (GenericEntityException e) {
>>>>>> - }
>>>>>> - return layouts.toArray(new Layout[layouts.size()]);
>>>>>> - }
>>>>>> -
>>>>>> - @Override
>>>>>> - public void initializeRequest(WebslingerServletContext context, HttpServletRequest request) {
>>>>>> - request.setAttribute("servletContext", context);
>>>>>> - Object delegator = context.getAttribute("delegator");
>>>>>> - Object dispatcher = context.getAttribute("dispatcher");
>>>>>> - Object authz = context.getAttribute("authz");
>>>>>> - Object security = context.getAttribute("security");
>>>>>> - request.setAttribute("delegator", delegator);
>>>>>> - request.setAttribute("dispatcher", dispatcher);
>>>>>> - request.setAttribute("authz", authz);
>>>>>> - request.setAttribute("security", security);
>>>>>> - // FIXME!!! These next two are a hack until proper fake/ wrapped session support is done in webslinger
>>>>>> - servletContext.setAttribute("delegator", delegator);
>>>>>> - servletContext.setAttribute("dispatcher", dispatcher);
>>>>>> - servletContext.setAttribute("authz", authz);
>>>>>> - servletContext.setAttribute("security", security);
>>>>>> - }
>>>>>> -
>>>>>> - @Override
>>>>>> - protected void initializeContext(WebslingerServletContext context, Layout layout) throws Exception {
>>>>>> - OfbizLayout ofbizLayout = (OfbizLayout) layout;
>>>>>> - Delegator delegator = null;
>>>>>> - delegator = DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
>>>>>> - context.setAttribute("delegator", delegator);
>>>>>> - context.setAttribute("dispatcher", new WebslingerGenericDispatcher(context, layout.getTarget(), delegator,
>>>>>> globalReaderURLs));
>>>>>> - context.setAttribute("authz", AuthorizationFactory.getInstance(delegator));
>>>>>> - context.setAttribute("security", SecurityFactory.getInstance(delegator));
>>>>>> - }
>>>>>> -
>>>>>> - protected static final class WebslingerGenericDispatcher extends GenericDispatcher {
>>>>>> - protected WebslingerGenericDispatcher(WebslingerServletContext context, String name, Delegator delegator,
>>>>>> List<URL> globalReaderURLs) throws IOException {
>>>>>> - ArrayList<URL> readerURLs = new ArrayList<URL>(globalReaderURLs);
>>>>>> - String readerFiles = context.getInitParameter("serviceReaderUrls");
>>>>>> - if (readerFiles != null) {
>>>>>> - for (String reader: CollectionUtil.split(readerFiles, ";")) {
>>>>>> - URL url = context.getResource(reader);
>>>>>> - if (url != null) readerURLs.add(url);
>>>>>> - }
>>>>>> - }
>>>>>> - System.err.println(readerURLs);
>>>>>> - this.dispatcher = new ServiceDispatcher(delegator, true, true, true) {
>>>>>> - };
>>>>>> - ClassLoader loader = null;
>>>>>> - try {
>>>>>> - loader = Thread.currentThread().getContextClassLoader();
>>>>>> - } catch (SecurityException e) {
>>>>>> - loader = WebslingerContextMapper.class.getClassLoader();
>>>>>> - }
>>>>>> - DispatchContext dc = new DispatchContext(name, readerURLs, loader, null);
>>>>>> - init(name, delegator, dc);
>>>>>> - }
>>>>>> - }
>>>>>> -
>>>>>> - @Override
>>>>>> - protected Set<String> getSuffixes() throws Exception {
>>>>>> - Cache cache = delegator.getCache();
>>>>>> - Set<String> suffixes;
>>>>>> - synchronized (WebslingerContextMapper.class) {
>>>>>> - suffixes = cache.get("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes");
>>>>>> - if (suffixes == null) {
>>>>>> - suffixes = new HashSet<String>();
>>>>>> - for (GenericValue value: delegator.findList("WebslingerHostSuffix", null, null, null, null, false)) {
>>>>>> - suffixes.add(value.getString("hostSuffix"));
>>>>>> - }
>>>>>> - cache.put("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes", suffixes);
>>>>>> - }
>>>>>> - }
>>>>>> - return suffixes;
>>>>>> - }
>>>>>> -
>>>>>> - @Override
>>>>>> - protected Layout lookupLayout(String hostName, String contextPath) throws Exception {
>>>>>> - GenericValue layout = EntityUtil .getOnly(delegator.findByAndCache("WebslingerLayout",
>>>>>> UtilMisc.toMap("hostName", hostName, "contextPath", contextPath)));
>>>>>> - if (layout == null) return null;
>>>>>> - return new OfbizLayout(layout);
>>>>>> - }
>>>>>> -
>>>>>> - protected class OfbizLayout implements Layout {
>>>>>> - private final String contextPath;
>>>>>> - private final String id;
>>>>>> - private final String target;
>>>>>> - private final String[] bases;
>>>>>> - private final int hashCode;
>>>>>> - protected final String delegatorName;
>>>>>> - protected final String dispatcherName;
>>>>>> -
>>>>>> - protected OfbizLayout(GenericValue server) throws GenericEntityException {
>>>>>> - contextPath = server.getString("contextPath");
>>>>>> - id = server.getString("webslingerServerId");
>>>>>> - target = server.getString("target");
>>>>>> - List<GenericValue> baseValues = server.getRelatedCache("WebslingerServerBase", UtilMisc.toList("seqNum"));
>>>>>> - bases = new String[baseValues.size()];
>>>>>> - for (int i = 0; i < bases.length; i++) {
>>>>>> - GenericValue baseValue = baseValues.get(i);
>>>>>> - bases[i] = baseValue.getString("baseName");
>>>>>> - }
>>>>>> - delegatorName = server.getString("delegatorName");
>>>>>> - dispatcherName = server.getString("dispatcherName");
>>>>>> - hashCode = target.hashCode() ^ ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
>>>>>> - }
>>>>>> -
>>>>>> - public String getContextPath() {
>>>>>> - return contextPath;
>>>>>> - }
>>>>>> -
>>>>>> - public String getId() {
>>>>>> - return id;
>>>>>> - }
>>>>>> -
>>>>>> - public String getTarget() {
>>>>>> - return target;
>>>>>> - }
>>>>>> -
>>>>>> - public String[] getBases() {
>>>>>> - return bases;
>>>>>> - }
>>>>>> -
>>>>>> - @Override
>>>>>> - public int hashCode() {
>>>>>> - return hashCode;
>>>>>> - }
>>>>>> -
>>>>>> - @Override
>>>>>> - public boolean equals(Object o) {
>>>>>> - if (!(o instanceof OfbizLayout)) return false;
>>>>>> - OfbizLayout other = (OfbizLayout) o;
>>>>>> - if (!contextPath.equals(other.contextPath)) return false;
>>>>>> - if (!target.equals(other.target)) return false;
>>>>>> - if (!ObjectUtil.equalsHelper(delegatorName, other.delegatorName)) return false;
>>>>>> - return Arrays.equals(bases, other.bases);
>>>>>> - }
>>>>>> - }
>>>>>> -}
>>>>>> +/ *******************************************************************************
>>>>>> + * 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.webslinger;
>>>>>> +
>>>>>> +import java.io.IOException;
>>>>>> +import java.net.URL;
>>>>>> +import java.util.ArrayList;
>>>>>> +import java.util.Arrays;
>>>>>> +import java.util.HashSet;
>>>>>> +import java.util.List;
>>>>>> +import java.util.Set;
>>>>>> +
>>>>>> +import javax.servlet.ServletConfig;
>>>>>> +import javax.servlet.ServletContext;
>>>>>> +import javax.servlet.ServletException;
>>>>>> +import javax.servlet.http.HttpServletRequest;
>>>>>> +
>>>>>> +import org.ofbiz.base.util.UtilMisc;
>>>>>> +import org.ofbiz.base.util.UtilProperties;
>>>>>> +import org.ofbiz.entity.Delegator;
>>>>>> +import org.ofbiz.entity.DelegatorFactory;
>>>>>> +import org.ofbiz.entity.GenericEntityException;
>>>>>> +import org.ofbiz.entity.GenericValue;
>>>>>> +import org.ofbiz.entity.cache.Cache;
>>>>>> +import org.ofbiz.entity.util.EntityUtil;
>>>>>> +import org.ofbiz.security.SecurityFactory;
>>>>>> +import org.ofbiz.security.authz.AuthorizationFactory;
>>>>>> +import org.ofbiz.service.DispatchContext;
>>>>>> +import org.ofbiz.service.GenericDispatcher;
>>>>>> +import org.ofbiz.service.ServiceDispatcher;
>>>>>> +import org.webslinger.AbstractMappingWebslingerServletContextFactory;
>>>>>> +import org.webslinger.WebslingerServletContext;
>>>>>> +import org.webslinger.collections.CollectionUtil;
>>>>>> +import org.webslinger.lang.ObjectUtil;
>>>>>> +
>>>>>> +public class WebslingerContextMapper extends AbstractMappingWebslingerServletContextFactory {
>>>>>> + protected ServletContext servletContext;
>>>>>> + protected Delegator delegator;
>>>>>> + protected final ArrayList<URL> globalReaderURLs = new ArrayList<URL>();
>>>>>> +
>>>>>> + public void init(ServletConfig config) throws ServletException, IOException {
>>>>>> + System .err .println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
>>>>>> + servletContext = config.getServletContext();
>>>>>> + String delegatorName = servletContext.getInitParameter("entityDelegatorName");
>>>>>> + delegator = DelegatorFactory.getDelegator(delegatorName);
>>>>>> + String readerFiles = servletContext.getInitParameter("serviceReaderUrls");
>>>>>> + if (readerFiles != null) {
>>>>>> + for (String reader: CollectionUtil.split(readerFiles, ";")) {
>>>>>> + URL url = config.getServletContext().getResource(reader);
>>>>>> + if (url != null) globalReaderURLs.add(url);
>>>>>> + }
>>>>>> + }
>>>>>> + super.init(config, UtilProperties.getPropertyValue("webslinger.properties", "moduleBase"));
>>>>>> + }
>>>>>> +
>>>>>> + @Override
>>>>>> + protected Layout[] getStartLayouts() throws Exception {
>>>>>> + ArrayList<Layout> layouts = new ArrayList<Layout>();
>>>>>> + try {
>>>>>> + for (GenericValue value: delegator.findByAnd("WebslingerServer", UtilMisc.toMap("loadAtStart", "Y"))) {
>>>>>> + layouts.add(new OfbizLayout(value));
>>>>>> + }
>>>>>> + } catch (GenericEntityException e) {
>>>>>> + }
>>>>>> + return layouts.toArray(new Layout[layouts.size()]);
>>>>>> + }
>>>>>> +
>>>>>> + @Override
>>>>>> + public void initializeRequest(WebslingerServletContext context, HttpServletRequest request) {
>>>>>> + request.setAttribute("servletContext", context);
>>>>>> + Object delegator = context.getAttribute("delegator");
>>>>>> + Object dispatcher = context.getAttribute("dispatcher");
>>>>>> + Object authz = context.getAttribute("authz");
>>>>>> + Object security = context.getAttribute("security");
>>>>>> + request.setAttribute("delegator", delegator);
>>>>>> + request.setAttribute("dispatcher", dispatcher);
>>>>>> + request.setAttribute("authz", authz);
>>>>>> + request.setAttribute("security", security);
>>>>>> + // FIXME!!! These next two are a hack until proper fake/ wrapped session support is done in webslinger
>>>>>> + servletContext.setAttribute("delegator", delegator);
>>>>>> + servletContext.setAttribute("dispatcher", dispatcher);
>>>>>> + servletContext.setAttribute("authz", authz);
>>>>>> + servletContext.setAttribute("security", security);
>>>>>> + }
>>>>>> +
>>>>>> + @Override
>>>>>> + protected void initializeContext(WebslingerServletContext context, Layout layout) throws Exception {
>>>>>> + OfbizLayout ofbizLayout = (OfbizLayout) layout;
>>>>>> + Delegator delegator = null;
>>>>>> + delegator = DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
>>>>>> + context.setAttribute("delegator", delegator);
>>>>>> + context.setAttribute("dispatcher", new WebslingerGenericDispatcher(context, layout.getTarget(), delegator,
>>>>>> globalReaderURLs));
>>>>>> + context.setAttribute("authz", AuthorizationFactory.getInstance(delegator));
>>>>>> + context.setAttribute("security", SecurityFactory.getInstance(delegator));
>>>>>> + }
>>>>>> +
>>>>>> + protected static final class WebslingerGenericDispatcher extends GenericDispatcher {
>>>>>> + protected WebslingerGenericDispatcher(WebslingerServletContext context, String name, Delegator delegator,
>>>>>> List<URL> globalReaderURLs) throws IOException {
>>>>>> + ArrayList<URL> readerURLs = new ArrayList<URL>(globalReaderURLs);
>>>>>> + String readerFiles = context.getInitParameter("serviceReaderUrls");
>>>>>> + if (readerFiles != null) {
>>>>>> + for (String reader: CollectionUtil.split(readerFiles, ";")) {
>>>>>> + URL url = context.getResource(reader);
>>>>>> + if (url != null) readerURLs.add(url);
>>>>>> + }
>>>>>> + }
>>>>>> + System.err.println(readerURLs);
>>>>>> + this.dispatcher = new ServiceDispatcher(delegator, true, true, true) {
>>>>>> + };
>>>>>> + ClassLoader loader = null;
>>>>>> + try {
>>>>>> + loader = Thread.currentThread().getContextClassLoader();
>>>>>> + } catch (SecurityException e) {
>>>>>> + loader = WebslingerContextMapper.class.getClassLoader();
>>>>>> + }
>>>>>> + DispatchContext dc = new DispatchContext(name, readerURLs, loader, null);
>>>>>> + init(name, delegator, dc);
>>>>>> + }
>>>>>> + }
>>>>>> +
>>>>>> + @Override
>>>>>> + protected Set<String> getSuffixes() throws Exception {
>>>>>> + Cache cache = delegator.getCache();
>>>>>> + Set<String> suffixes;
>>>>>> + synchronized (WebslingerContextMapper.class) {
>>>>>> + suffixes = cache.get("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes");
>>>>>> + if (suffixes == null) {
>>>>>> + suffixes = new HashSet<String>();
>>>>>> + for (GenericValue value: delegator.findList("WebslingerHostSuffix", null, null, null, null, false)) {
>>>>>> + suffixes.add(value.getString("hostSuffix"));
>>>>>> + }
>>>>>> + cache.put("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes", suffixes);
>>>>>> + }
>>>>>> + }
>>>>>> + return suffixes;
>>>>>> + }
>>>>>> +
>>>>>> + @Override
>>>>>> + protected Layout lookupLayout(String hostName, String contextPath) throws Exception {
>>>>>> + GenericValue layout = EntityUtil .getOnly(delegator.findByAndCache("WebslingerLayout",
>>>>>> UtilMisc.toMap("hostName", hostName, "contextPath", contextPath)));
>>>>>> + if (layout == null) return null;
>>>>>> + return new OfbizLayout(layout);
>>>>>> + }
>>>>>> +
>>>>>> + protected class OfbizLayout implements Layout {
>>>>>> + private final String contextPath;
>>>>>> + private final String id;
>>>>>> + private final String target;
>>>>>> + private final String[] bases;
>>>>>> + private final int hashCode;
>>>>>> + protected final String delegatorName;
>>>>>> + protected final String dispatcherName;
>>>>>> +
>>>>>> + protected OfbizLayout(GenericValue server) throws GenericEntityException {
>>>>>> + contextPath = server.getString("contextPath");
>>>>>> + id = server.getString("webslingerServerId");
>>>>>> + target = server.getString("target");
>>>>>> + List<GenericValue> baseValues = server.getRelatedCache("WebslingerServerBase", UtilMisc.toList("seqNum"));
>>>>>> + bases = new String[baseValues.size()];
>>>>>> + for (int i = 0; i < bases.length; i++) {
>>>>>> + GenericValue baseValue = baseValues.get(i);
>>>>>> + bases[i] = baseValue.getString("baseName");
>>>>>> + }
>>>>>> + delegatorName = server.getString("delegatorName");
>>>>>> + dispatcherName = server.getString("dispatcherName");
>>>>>> + hashCode = target.hashCode() ^ ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
>>>>>> + }
>>>>>> +
>>>>>> + public String getContextPath() {
>>>>>> + return contextPath;
>>>>>> + }
>>>>>> +
>>>>>> + public String getId() {
>>>>>> + return id;
>>>>>> + }
>>>>>> +
>>>>>> + public String getTarget() {
>>>>>> + return target;
>>>>>> + }
>>>>>> +
>>>>>> + public String[] getBases() {
>>>>>> + return bases;
>>>>>> + }
>>>>>> +
>>>>>> + @Override
>>>>>> + public int hashCode() {
>>>>>> + return hashCode;
>>>>>> + }
>>>>>> +
>>>>>> + @Override
>>>>>> + public boolean equals(Object o) {
>>>>>> + if (!(o instanceof OfbizLayout)) return false;
>>>>>> + OfbizLayout other = (OfbizLayout) o;
>>>>>> + if (!contextPath.equals(other.contextPath)) return false;
>>>>>> + if (!target.equals(other.target)) return false;
>>>>>> + if (!ObjectUtil.equalsHelper(delegatorName, other.delegatorName)) return false;
>>>>>> + return Arrays.equals(bases, other.bases);
>>>>>> + }
>>>>>> + }
>>>>>> +}
>>>>>>
>>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/ webslinger/ WebslingerServerEngine.java
>>>>>> URL:
>>>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>>> = = = = = = = = = = = = ==================================================================
>>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerServerEngine.java (original)
>>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerServerEngine.java Sat Nov 7 18:18:33 2009
>>>>>> @@ -1,64 +1,59 @@
>>>>>> -/ *******************************************************************************
>>>>>> - * 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.webslinger;
>>>>>> -
>>>>>> -import java.io.IOException;
>>>>>> -import java.io.StringReader;
>>>>>> -import java.io.StringWriter;
>>>>>> -import java.util.Collections;
>>>>>> -import java.util.Map;
>>>>>> -
>>>>>> -import org.ofbiz.base.util.UtilGenerics;
>>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>>> -import org.ofbiz.entity.Delegator;
>>>>>> -import org.ofbiz.entity.GenericValue;
>>>>>> -import org.ofbiz.entity.util.EntityUtil;
>>>>>> -import org.ofbiz.service.GenericServiceException;
>>>>>> -import org.ofbiz.service.ModelService;
>>>>>> -import org.ofbiz.service.ServiceDispatcher;
>>>>>> -import org.ofbiz.service.engine.GenericAsyncEngine;
>>>>>> -
>>>>>> -import org.webslinger.WebslingerServletContext;
>>>>>> -
>>>>>> -public class WebslingerServerEngine extends GenericAsyncEngine {
>>>>>> - public WebslingerServerEngine(ServiceDispatcher dispatcher) {
>>>>>> - super(dispatcher);
>>>>>> - }
>>>>>> -
>>>>>> - @Override
>>>>>> - public void runSyncIgnore(String localName, ModelService modelService, Map<String, Object> context) throws
>>>>>> GenericServiceException {
>>>>>> - runSync(localName, modelService, context);
>>>>>> - }
>>>>>> -
>>>>>> - @Override
>>>>>> - public Map<String, Object> runSync(String localName, ModelService modelService, Map<String, Object> context) throws
>>>>>> GenericServiceException {
>>>>>> - Delegator delegator = dispatcher.getDelegator();
>>>>>> - try {
>>>>>> - GenericValue found = EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout",
>>>>>> UtilMisc.toMap("webslingerServerId", modelService.location)));
>>>>>> - if (found == null) throw new GenericServiceException("Couldn't find server mapping for(" +
>>>>>> modelService.location + ")");
>>>>>> - return UtilGenerics .checkMap (WebslingerServletContext .invokeInVM(found.getString("hostName"), 8080,
>>>>>> modelService.invoke, context));
>>>>>> - } catch (RuntimeException e) {
>>>>>> - throw e;
>>>>>> - } catch (GenericServiceException e) {
>>>>>> - throw e;
>>>>>> - } catch (Exception e) {
>>>>>> - throw UtilMisc.initCause(new GenericServiceException(e.getMessage()), e);
>>>>>> - }
>>>>>> - }
>>>>>> -}
>>>>>> +/ *******************************************************************************
>>>>>> + * 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.webslinger;
>>>>>> +
>>>>>> +import java.util.Map;
>>>>>> +
>>>>>> +import org.ofbiz.base.util.UtilGenerics;
>>>>>> +import org.ofbiz.base.util.UtilMisc;
>>>>>> +import org.ofbiz.entity.Delegator;
>>>>>> +import org.ofbiz.entity.GenericValue;
>>>>>> +import org.ofbiz.entity.util.EntityUtil;
>>>>>> +import org.ofbiz.service.GenericServiceException;
>>>>>> +import org.ofbiz.service.ModelService;
>>>>>> +import org.ofbiz.service.ServiceDispatcher;
>>>>>> +import org.ofbiz.service.engine.GenericAsyncEngine;
>>>>>> +import org.webslinger.WebslingerServletContext;
>>>>>> +
>>>>>> +public class WebslingerServerEngine extends GenericAsyncEngine {
>>>>>> + public WebslingerServerEngine(ServiceDispatcher dispatcher) {
>>>>>> + super(dispatcher);
>>>>>> + }
>>>>>> +
>>>>>> + @Override
>>>>>> + public void runSyncIgnore(String localName, ModelService modelService, Map<String, Object> context) throws
>>>>>> GenericServiceException {
>>>>>> + runSync(localName, modelService, context);
>>>>>> + }
>>>>>> +
>>>>>> + @Override
>>>>>> + public Map<String, Object> runSync(String localName, ModelService modelService, Map<String, Object> context) throws
>>>>>> GenericServiceException {
>>>>>> + Delegator delegator = dispatcher.getDelegator();
>>>>>> + try {
>>>>>> + GenericValue found = EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout",
>>>>>> UtilMisc.toMap("webslingerServerId", modelService.location)));
>>>>>> + if (found == null) throw new GenericServiceException("Couldn't find server mapping for(" +
>>>>>> modelService.location + ")");
>>>>>> + return UtilGenerics .checkMap (WebslingerServletContext .invokeInVM(found.getString("hostName"), 8080,
>>>>>> modelService.invoke, context));
>>>>>> + } catch (RuntimeException e) {
>>>>>> + throw e;
>>>>>> + } catch (GenericServiceException e) {
>>>>>> + throw e;
>>>>>> + } catch (Exception e) {
>>>>>> + throw UtilMisc.initCause(new GenericServiceException(e.getMessage()), e);
>>>>>> + }
>>>>>> + }
>>>>>> +}
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>
>
Re: svn commit: r833727 - in /ofbiz/trunk/framework/webslinger/src/org/ofbiz: commons/vfs/ commons/vfs/ofbiz/ webslinger/
Posted by Scott Gray <sc...@hotwaxmedia.com>.
Hi Jacques
I was referring to the svn properties on the files being committed
rather than the svn config.
Regards
Scott
On 10/11/2009, at 1:07 AM, Jacques Le Roux wrote:
> I replaced my .subversion/config by ours. Not sure why it has been
> replaced, by an install maybe or as I'm on Windows, Tortoise while
> changing the setting...
>
> Jacques
>
> From: "Scott Gray" <sc...@hotwaxmedia.com>
>> Hi Jacques,
>>
>> I think the problem is related to files in svn that do not have
>> any svn properties set (specifically eol-style), I just came
>> across this myself in r833931 and r833933. When I initially
>> applied the patch the entire file changed but after setting the
>> svn properties the issue went away.
>>
>> Regards
>> Scott
>>
>> On 9/11/2009, at 11:32 AM, Jacques Le Roux wrote:
>>
>>> Sorry Scott,
>>>
>>> I have still not got the reflex... As I have not touched the
>>> patch (ok you have to trust me) you may review the patch itself...
>>>
>>> Jacques
>>>
>>> From: "Scott Gray" <sc...@hotwaxmedia.com>
>>>> Hi Jacques,
>>>>
>>>> This is that same problem with the patch again, please keep an
>>>> eye out for these as the commits are impossible to review.
>>>>
>>>> Thanks
>>>> Scott
>>>>
>>>> HotWax Media
>>>> http://www.hotwaxmedia.com
>>>>
>>>> On 8/11/2009, at 7:18 AM, jleroux@apache.org wrote:
>>>>
>>>>> Author: jleroux
>>>>> Date: Sat Nov 7 18:18:33 2009
>>>>> New Revision: 833727
>>>>>
>>>>> URL: http://svn.apache.org/viewvc?rev=833727&view=rev
>>>>> Log:
>>>>> A patch from Marc Morin "Resolve java warnings exposed in
>>>>> Eclipse : framework - webslinger" (https://issues.apache.org/jira/browse/OFBIZ-3121
>>>>> ) - OFBIZ-3121
>>>>>
>>>>> Modified:
>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>>>> CommonsVfsContainer.java
>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>>>> ofbiz/ OfbizComponentProvider.java
>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>>>> ofbiz/ OfbizHomeProvider.java
>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>>>> EntityHttpUtil.java
>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>>>> StatsUpdater.java
>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>>>> WebslingerContextMapper.java
>>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>>>> WebslingerServerEngine.java
>>>>>
>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/
>>>>> commons/ vfs/ CommonsVfsContainer.java
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>> = = = = = = = = = =
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>>>> CommonsVfsContainer.java (original)
>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>>>> CommonsVfsContainer.java Sat Nov 7 18:18:33 2009
>>>>> @@ -1,68 +1,66 @@
>>>>> -/
>>>>> *******************************************************************************
>>>>> - * 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.commons.vfs;
>>>>> -
>>>>> -import java.io.File;
>>>>> -import java.io.IOException;
>>>>> -import java.net.MalformedURLException;
>>>>> -
>>>>> -import org.apache.commons.vfs.CacheStrategy;
>>>>> -import org.apache.commons.vfs.FileObject;
>>>>> -import org.apache.commons.vfs.FileSystemException;
>>>>> -import org.apache.commons.vfs.FileSystemManager;
>>>>> -import org.apache.commons.vfs.impl.StandardFileSystemManager;
>>>>> -
>>>>> -import org.ofbiz.base.container.Container;
>>>>> -import org.ofbiz.base.container.ContainerException;
>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>> -import org.webslinger.commons.vfs.VFSUtil;
>>>>> -
>>>>> -public class CommonsVfsContainer implements Container {
>>>>> - private static StandardFileSystemManager sfsm;
>>>>> -
>>>>> - public void init(String[] args, String configFile) throws
>>>>> ContainerException {
>>>>> - }
>>>>> -
>>>>> - public boolean start() throws ContainerException {
>>>>> - try {
>>>>> - StandardFileSystemManager sfsm =
>>>>> VFSUtil.createStandardFileSystemManager();
>>>>> - FileObject currentDir = sfsm.resolveFile(new
>>>>> File(".").toURI().toURL().toString());
>>>>> - sfsm.setBaseFile(currentDir);
>>>>> - CommonsVfsContainer.sfsm = sfsm;
>>>>> - } catch (FileSystemException e) {
>>>>> - throw UtilMisc.initCause(new
>>>>> ContainerException("Initializing StandardFileSystemManager"), e);
>>>>> - } catch (MalformedURLException e) {
>>>>> - throw UtilMisc.initCause(new
>>>>> ContainerException("Initializing StandardFileSystemManager"), e);
>>>>> - }
>>>>> - return true;
>>>>> - }
>>>>> -
>>>>> - public void stop() throws ContainerException {
>>>>> - sfsm.close();
>>>>> - sfsm = null;
>>>>> - }
>>>>> -
>>>>> - public static FileObject resolveFile(String uri) throws
>>>>> IOException {
>>>>> - return sfsm.resolveFile(uri);
>>>>> - }
>>>>> -
>>>>> - public static FileSystemManager getFileSystemManager() {
>>>>> - return sfsm;
>>>>> - }
>>>>> -}
>>>>> +/
>>>>> *******************************************************************************
>>>>> + * 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.commons.vfs;
>>>>> +
>>>>> +import java.io.File;
>>>>> +import java.io.IOException;
>>>>> +import java.net.MalformedURLException;
>>>>> +
>>>>> +import org.apache.commons.vfs.FileObject;
>>>>> +import org.apache.commons.vfs.FileSystemException;
>>>>> +import org.apache.commons.vfs.FileSystemManager;
>>>>> +import org.apache.commons.vfs.impl.StandardFileSystemManager;
>>>>> +import org.ofbiz.base.container.Container;
>>>>> +import org.ofbiz.base.container.ContainerException;
>>>>> +import org.ofbiz.base.util.UtilMisc;
>>>>> +import org.webslinger.commons.vfs.VFSUtil;
>>>>> +
>>>>> +public class CommonsVfsContainer implements Container {
>>>>> + private static StandardFileSystemManager sfsm;
>>>>> +
>>>>> + public void init(String[] args, String configFile) throws
>>>>> ContainerException {
>>>>> + }
>>>>> +
>>>>> + public boolean start() throws ContainerException {
>>>>> + try {
>>>>> + StandardFileSystemManager sfsm =
>>>>> VFSUtil.createStandardFileSystemManager();
>>>>> + FileObject currentDir = sfsm.resolveFile(new
>>>>> File(".").toURI().toURL().toString());
>>>>> + sfsm.setBaseFile(currentDir);
>>>>> + CommonsVfsContainer.sfsm = sfsm;
>>>>> + } catch (FileSystemException e) {
>>>>> + throw UtilMisc.initCause(new
>>>>> ContainerException("Initializing StandardFileSystemManager"), e);
>>>>> + } catch (MalformedURLException e) {
>>>>> + throw UtilMisc.initCause(new
>>>>> ContainerException("Initializing StandardFileSystemManager"), e);
>>>>> + }
>>>>> + return true;
>>>>> + }
>>>>> +
>>>>> + public void stop() throws ContainerException {
>>>>> + sfsm.close();
>>>>> + sfsm = null;
>>>>> + }
>>>>> +
>>>>> + public static FileObject resolveFile(String uri) throws
>>>>> IOException {
>>>>> + return sfsm.resolveFile(uri);
>>>>> + }
>>>>> +
>>>>> + public static FileSystemManager getFileSystemManager() {
>>>>> + return sfsm;
>>>>> + }
>>>>> +}
>>>>>
>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/
>>>>> commons/ vfs/ ofbiz/OfbizComponentProvider.java
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>> = = = = = = = = = =
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>>>> ofbiz/ OfbizComponentProvider.java (original)
>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>>>> ofbiz/ OfbizComponentProvider.java Sat Nov 7 18:18:33 2009
>>>>> @@ -1,58 +1,58 @@
>>>>> -/
>>>>> *******************************************************************************
>>>>> - * 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.commons.vfs.ofbiz;
>>>>> -
>>>>> -import java.net.URL;
>>>>> -import java.util.Collection;
>>>>> -import org.apache.commons.vfs.FileObject;
>>>>> -import org.apache.commons.vfs.FileSystemException;
>>>>> -import org.apache.commons.vfs.FileSystemOptions;
>>>>> -import org.apache.commons.vfs.provider.AbstractFileProvider;
>>>>> -import
>>>>> org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>>>> -import org.ofbiz.base.location.FlexibleLocation;
>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>> -import org.webslinger.commons.vfs.VFSUtil;
>>>>> -
>>>>> -public class OfbizComponentProvider extends
>>>>> AbstractFileProvider {
>>>>> - public Collection getCapabilities() {
>>>>> - return DefaultLocalFileProvider.capabilities;
>>>>> - }
>>>>> -
>>>>> - public FileObject findFile(FileObject base, String name,
>>>>> FileSystemOptions properties) throws FileSystemException {
>>>>> - try {
>>>>> - //name = name.replaceAll("^ofbiz-component://", "");
>>>>> - int nameLength = name.length();
>>>>> - int componentNameStart = 16;
>>>>> - while (componentNameStart < nameLength &&
>>>>> name.charAt(componentNameStart) == '/') componentNameStart++;
>>>>> - if (componentNameStart == nameLength) throw new
>>>>> IllegalArgumentException("Invalid name(" + name + ")");
>>>>> - int componentNameEnd = componentNameStart;
>>>>> - while (componentNameEnd < nameLength &&
>>>>> name.charAt(componentNameEnd) != '/') componentNameEnd++;
>>>>> - if (componentNameEnd == nameLength) throw new
>>>>> IllegalArgumentException("Invalid name(" + name + ")");
>>>>> - int restStart = componentNameEnd;
>>>>> - while (restStart < nameLength &&
>>>>> name.charAt(restStart) == '/') restStart++;
>>>>> - if (restStart == nameLength) throw new
>>>>> IllegalArgumentException("Invalid name(" + name + ")");
>>>>> - String componentName =
>>>>> name.substring(componentNameStart, componentNameEnd);
>>>>> - URL location =
>>>>> FlexibleLocation.resolveLocation("component://" + componentName
>>>>> + "/.");
>>>>> - FileObject ofbizBase =
>>>>> getContext().resolveFile(location.toString(), properties);
>>>>> - return
>>>>> VFSUtil
>>>>> .toFileObject
>>>>> (ofbizBase.getFileSystem().getFileSystemManager(),
>>>>> ofbizBase
>>>>> .resolveFile(name.substring(restStart)).getURL().toString(),
>>>>> properties);
>>>>> - } catch (Exception e) {
>>>>> - throw UtilMisc.initCause(new
>>>>> FileSystemException(e.getMessage(), null, e), e);
>>>>> - }
>>>>> - }
>>>>> -}
>>>>> +/
>>>>> *******************************************************************************
>>>>> + * 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.commons.vfs.ofbiz;
>>>>> +
>>>>> +import java.net.URL;
>>>>> +import java.util.Collection;
>>>>> +import org.apache.commons.vfs.FileObject;
>>>>> +import org.apache.commons.vfs.FileSystemException;
>>>>> +import org.apache.commons.vfs.FileSystemOptions;
>>>>> +import org.apache.commons.vfs.provider.AbstractFileProvider;
>>>>> +import
>>>>> org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>>>> +import org.ofbiz.base.location.FlexibleLocation;
>>>>> +import org.ofbiz.base.util.UtilMisc;
>>>>> +import org.webslinger.commons.vfs.VFSUtil;
>>>>> +
>>>>> +public class OfbizComponentProvider extends
>>>>> AbstractFileProvider {
>>>>> + public Collection<?> getCapabilities() {
>>>>> + return DefaultLocalFileProvider.capabilities;
>>>>> + }
>>>>> +
>>>>> + public FileObject findFile(FileObject base, String name,
>>>>> FileSystemOptions properties) throws FileSystemException {
>>>>> + try {
>>>>> + //name = name.replaceAll("^ofbiz-component://", "");
>>>>> + int nameLength = name.length();
>>>>> + int componentNameStart = 16;
>>>>> + while (componentNameStart < nameLength &&
>>>>> name.charAt(componentNameStart) == '/') componentNameStart++;
>>>>> + if (componentNameStart == nameLength) throw new
>>>>> IllegalArgumentException("Invalid name(" + name + ")");
>>>>> + int componentNameEnd = componentNameStart;
>>>>> + while (componentNameEnd < nameLength &&
>>>>> name.charAt(componentNameEnd) != '/') componentNameEnd++;
>>>>> + if (componentNameEnd == nameLength) throw new
>>>>> IllegalArgumentException("Invalid name(" + name + ")");
>>>>> + int restStart = componentNameEnd;
>>>>> + while (restStart < nameLength &&
>>>>> name.charAt(restStart) == '/') restStart++;
>>>>> + if (restStart == nameLength) throw new
>>>>> IllegalArgumentException("Invalid name(" + name + ")");
>>>>> + String componentName =
>>>>> name.substring(componentNameStart, componentNameEnd);
>>>>> + URL location =
>>>>> FlexibleLocation.resolveLocation("component://" + componentName
>>>>> + "/.");
>>>>> + FileObject ofbizBase =
>>>>> getContext().resolveFile(location.toString(), properties);
>>>>> + return
>>>>> VFSUtil
>>>>> .toFileObject
>>>>> (ofbizBase.getFileSystem().getFileSystemManager(),
>>>>> ofbizBase
>>>>> .resolveFile(name.substring(restStart)).getURL().toString(),
>>>>> properties);
>>>>> + } catch (Exception e) {
>>>>> + throw UtilMisc.initCause(new
>>>>> FileSystemException(e.getMessage(), null, e), e);
>>>>> + }
>>>>> + }
>>>>> +}
>>>>>
>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/
>>>>> commons/ vfs/ ofbiz/OfbizHomeProvider.java
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>> = = = = = = = = = =
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>>>> ofbiz/ OfbizHomeProvider.java (original)
>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>>>> ofbiz/ OfbizHomeProvider.java Sat Nov 7 18:18:33 2009
>>>>> @@ -1,50 +1,50 @@
>>>>> -/
>>>>> *******************************************************************************
>>>>> - * 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.commons.vfs.ofbiz;
>>>>> -
>>>>> -import java.net.URL;
>>>>> -import java.util.Collection;
>>>>> -
>>>>> -import org.apache.commons.vfs.FileObject;
>>>>> -import org.apache.commons.vfs.FileSystemException;
>>>>> -import org.apache.commons.vfs.FileSystemOptions;
>>>>> -import org.apache.commons.vfs.provider.AbstractFileProvider;
>>>>> -import
>>>>> org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>>>> -
>>>>> -import org.ofbiz.base.location.FlexibleLocation;
>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>> -
>>>>> -import org.webslinger.commons.vfs.VFSUtil;
>>>>> -
>>>>> -public class OfbizHomeProvider extends AbstractFileProvider {
>>>>> - public Collection getCapabilities() {
>>>>> - return DefaultLocalFileProvider.capabilities;
>>>>> - }
>>>>> -
>>>>> - public FileObject findFile(FileObject base, String name,
>>>>> FileSystemOptions properties) throws FileSystemException {
>>>>> - //new Exception("findFile(" + base + ", " + name +
>>>>> ")").printStackTrace();
>>>>> - try {
>>>>> - URL location =
>>>>> FlexibleLocation.resolveLocation("ofbizhome://.");
>>>>> - FileObject ofbizBase =
>>>>> getContext().resolveFile(location.toString(), properties);
>>>>> - return
>>>>> VFSUtil
>>>>> .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
>>>>> ofbizBase.resolveFile(name.substring(13)).getURL().toString(),
>>>>> properties);
>>>>> - } catch (Exception e) {
>>>>> - throw UtilMisc.initCause(new
>>>>> FileSystemException(e.getMessage(), null, e), e);
>>>>> - }
>>>>> - }
>>>>> -}
>>>>> +/
>>>>> *******************************************************************************
>>>>> + * 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.commons.vfs.ofbiz;
>>>>> +
>>>>> +import java.net.URL;
>>>>> +import java.util.Collection;
>>>>> +
>>>>> +import org.apache.commons.vfs.FileObject;
>>>>> +import org.apache.commons.vfs.FileSystemException;
>>>>> +import org.apache.commons.vfs.FileSystemOptions;
>>>>> +import org.apache.commons.vfs.provider.AbstractFileProvider;
>>>>> +import
>>>>> org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>>>> +
>>>>> +import org.ofbiz.base.location.FlexibleLocation;
>>>>> +import org.ofbiz.base.util.UtilMisc;
>>>>> +
>>>>> +import org.webslinger.commons.vfs.VFSUtil;
>>>>> +
>>>>> +public class OfbizHomeProvider extends AbstractFileProvider {
>>>>> + public Collection<?> getCapabilities() {
>>>>> + return DefaultLocalFileProvider.capabilities;
>>>>> + }
>>>>> +
>>>>> + public FileObject findFile(FileObject base, String name,
>>>>> FileSystemOptions properties) throws FileSystemException {
>>>>> + //new Exception("findFile(" + base + ", " + name +
>>>>> ")").printStackTrace();
>>>>> + try {
>>>>> + URL location =
>>>>> FlexibleLocation.resolveLocation("ofbizhome://.");
>>>>> + FileObject ofbizBase =
>>>>> getContext().resolveFile(location.toString(), properties);
>>>>> + return
>>>>> VFSUtil
>>>>> .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
>>>>> ofbizBase.resolveFile(name.substring(13)).getURL().toString(),
>>>>> properties);
>>>>> + } catch (Exception e) {
>>>>> + throw UtilMisc.initCause(new
>>>>> FileSystemException(e.getMessage(), null, e), e);
>>>>> + }
>>>>> + }
>>>>> +}
>>>>>
>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/
>>>>> webslinger/ EntityHttpUtil.java
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/EntityHttpUtil.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>> = = = = = = = = = =
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>>>> EntityHttpUtil.java (original)
>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>>>> EntityHttpUtil.java Sat Nov 7 18:18:33 2009
>>>>> @@ -1,78 +1,73 @@
>>>>> -/
>>>>> *******************************************************************************
>>>>> - * 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.webslinger;
>>>>> -
>>>>> -import java.util.HashMap;
>>>>> -import java.util.Iterator;
>>>>> -import java.util.Locale;
>>>>> -import java.util.Map;
>>>>> -
>>>>> -import javax.servlet.ServletRequest;
>>>>> -import javax.servlet.http.HttpServletRequest;
>>>>> -
>>>>> -import org.ofbiz.base.util.GeneralException;
>>>>> -import org.ofbiz.base.util.ObjectType;
>>>>> -import org.ofbiz.base.util.UtilHttp;
>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>> -import org.ofbiz.base.util.UtilValidate;
>>>>> -import org.ofbiz.entity.Delegator;
>>>>> -import org.ofbiz.entity.GenericValue;
>>>>> -import org.ofbiz.entity.jdbc.SqlJdbcUtil;
>>>>> -import org.ofbiz.entity.model.ModelEntity;
>>>>> -import org.ofbiz.entity.model.ModelField;
>>>>> -import org.ofbiz.entity.model.ModelFieldType;
>>>>> -
>>>>> -public class EntityHttpUtil {
>>>>> - public static GenericValue makeValidValue(String
>>>>> entityName, ServletRequest request) throws GeneralException {
>>>>> - return makeValidValue(entityName, false, request);
>>>>> - }
>>>>> -
>>>>> - public static GenericValue makeValidValue(String
>>>>> entityName, boolean includePks, ServletRequest request) throws
>>>>> GeneralException {
>>>>> - if (request instanceof HttpServletRequest) return
>>>>> makeValidValue(entityName, includePks, (HttpServletRequest)
>>>>> request);
>>>>> - throw new IllegalArgumentException("Not an
>>>>> HttpServletRequest");
>>>>> - }
>>>>> -
>>>>> - public static GenericValue makeValidValue(String
>>>>> entityName, HttpServletRequest request) throws
>>>>> GeneralException {
>>>>> - return makeValidValue(entityName, false, request);
>>>>> - }
>>>>> -
>>>>> - public static GenericValue makeValidValue(String
>>>>> entityName, boolean includePks, HttpServletRequest request)
>>>>> throws GeneralException {
>>>>> - Delegator delegator = (Delegator)
>>>>> request.getAttribute("delegator");
>>>>> - GenericValue value = delegator.makeValue(entityName);
>>>>> - ModelEntity model = value.getModelEntity();
>>>>> - Iterator<ModelField> it = includePks ?
>>>>> model.getFieldsIterator() : model.getNopksIterator();
>>>>> - Locale locale = UtilHttp.getLocale(request);
>>>>> - while (it.hasNext()) {
>>>>> - ModelField field = it.next();
>>>>> - String fieldName = field.getName();
>>>>> - String parameterValue =
>>>>> request.getParameter(fieldName);
>>>>> - Object fieldValue;
>>>>> - if (parameterValue == null) {
>>>>> - fieldValue = null;
>>>>> - } else {
>>>>> - ModelFieldType fieldType =
>>>>> delegator.getEntityFieldType(model, field.getType());
>>>>> - String wantedType = fieldType.getJavaType();
>>>>> - fieldValue =
>>>>> ObjectType.simpleTypeConvert(parameterValue, wantedType, null,
>>>>> locale, true);
>>>>> - }
>>>>> - value.put(fieldName, fieldValue);
>>>>> - }
>>>>> - return value;
>>>>> - }
>>>>> -}
>>>>> -
>>>>> +/
>>>>> *******************************************************************************
>>>>> + * 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.webslinger;
>>>>> +
>>>>> +import java.util.Iterator;
>>>>> +import java.util.Locale;
>>>>> +
>>>>> +import javax.servlet.ServletRequest;
>>>>> +import javax.servlet.http.HttpServletRequest;
>>>>> +
>>>>> +import org.ofbiz.base.util.GeneralException;
>>>>> +import org.ofbiz.base.util.ObjectType;
>>>>> +import org.ofbiz.base.util.UtilHttp;
>>>>> +import org.ofbiz.entity.Delegator;
>>>>> +import org.ofbiz.entity.GenericValue;
>>>>> +import org.ofbiz.entity.model.ModelEntity;
>>>>> +import org.ofbiz.entity.model.ModelField;
>>>>> +import org.ofbiz.entity.model.ModelFieldType;
>>>>> +
>>>>> +public class EntityHttpUtil {
>>>>> + public static GenericValue makeValidValue(String
>>>>> entityName, ServletRequest request) throws GeneralException {
>>>>> + return makeValidValue(entityName, false, request);
>>>>> + }
>>>>> +
>>>>> + public static GenericValue makeValidValue(String
>>>>> entityName, boolean includePks, ServletRequest request) throws
>>>>> GeneralException {
>>>>> + if (request instanceof HttpServletRequest) return
>>>>> makeValidValue(entityName, includePks, (HttpServletRequest)
>>>>> request);
>>>>> + throw new IllegalArgumentException("Not an
>>>>> HttpServletRequest");
>>>>> + }
>>>>> +
>>>>> + public static GenericValue makeValidValue(String
>>>>> entityName, HttpServletRequest request) throws
>>>>> GeneralException {
>>>>> + return makeValidValue(entityName, false, request);
>>>>> + }
>>>>> +
>>>>> + public static GenericValue makeValidValue(String
>>>>> entityName, boolean includePks, HttpServletRequest request)
>>>>> throws GeneralException {
>>>>> + Delegator delegator = (Delegator)
>>>>> request.getAttribute("delegator");
>>>>> + GenericValue value = delegator.makeValue(entityName);
>>>>> + ModelEntity model = value.getModelEntity();
>>>>> + Iterator<ModelField> it = includePks ?
>>>>> model.getFieldsIterator() : model.getNopksIterator();
>>>>> + Locale locale = UtilHttp.getLocale(request);
>>>>> + while (it.hasNext()) {
>>>>> + ModelField field = it.next();
>>>>> + String fieldName = field.getName();
>>>>> + String parameterValue =
>>>>> request.getParameter(fieldName);
>>>>> + Object fieldValue;
>>>>> + if (parameterValue == null) {
>>>>> + fieldValue = null;
>>>>> + } else {
>>>>> + ModelFieldType fieldType =
>>>>> delegator.getEntityFieldType(model, field.getType());
>>>>> + String wantedType = fieldType.getJavaType();
>>>>> + fieldValue =
>>>>> ObjectType.simpleTypeConvert(parameterValue, wantedType, null,
>>>>> locale, true);
>>>>> + }
>>>>> + value.put(fieldName, fieldValue);
>>>>> + }
>>>>> + return value;
>>>>> + }
>>>>> +}
>>>>> +
>>>>>
>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/
>>>>> webslinger/ StatsUpdater.java
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>> = = = = = = = = = =
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>>>> StatsUpdater.java (original)
>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>>>> StatsUpdater.java Sat Nov 7 18:18:33 2009
>>>>> @@ -1,121 +1,118 @@
>>>>> -/
>>>>> *******************************************************************************
>>>>> - * 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.webslinger;
>>>>> -
>>>>> -import java.util.HashMap;
>>>>> -import java.util.Iterator;
>>>>> -import java.util.Map;
>>>>> -import java.util.concurrent.Callable;
>>>>> -import java.util.concurrent.ConcurrentHashMap;
>>>>> -import java.util.concurrent.ScheduledFuture;
>>>>> -import java.util.concurrent.TimeUnit;
>>>>> -import java.util.concurrent.atomic.AtomicReference;
>>>>> -
>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>> -import org.ofbiz.entity.Delegator;
>>>>> -import org.ofbiz.entity.GenericEntityException;
>>>>> -import org.ofbiz.entity.GenericPK;
>>>>> -import org.ofbiz.entity.GenericValue;
>>>>> -
>>>>> -import org.webslinger.cache.ConcurrentCache;
>>>>> -import org.webslinger.concurrent.ExecutionPool;
>>>>> -
>>>>> -public class StatsUpdater {
>>>>> - private static final Updater UPDATER = new Updater();
>>>>> -
>>>>> - public static void updateStats(Delegator delegator,
>>>>> String entityName, Map<String, ? extends Object> keyFields,
>>>>> Map<String, ? extends Long> updateCountFields) throws
>>>>> GenericEntityException {
>>>>> - GenericPK pk = delegator.makePK(entityName, keyFields);
>>>>> - Map<String, Long> value = UPDATER.getValue(pk);
>>>>> - synchronized (value) {
>>>>> - for (Map.Entry<String, ? extends Long> entry:
>>>>> updateCountFields.entrySet()) {
>>>>> - Long oldValue = value.get(entry.getKey());
>>>>> - if (oldValue != null) {
>>>>> - value.put(entry.getKey(),
>>>>> Long.valueOf(oldValue.longValue() + entry.getValue()));
>>>>> - } else {
>>>>> - value.put(entry.getKey(), entry.getValue());
>>>>> - }
>>>>> - }
>>>>> - }
>>>>> - }
>>>>> -
>>>>> - private static final class Updater implements
>>>>> Callable<Void> {
>>>>> - protected AtomicReference<EntityHolder> entities =
>>>>> new AtomicReference<EntityHolder>(new
>>>>> EntityHolder(Updater.class, "entities", null));
>>>>> - protected ScheduledFuture<Void> future;
>>>>> -
>>>>> - protected Map<String, Long> getValue(GenericPK pk)
>>>>> throws GenericEntityException {
>>>>> - synchronized (this) {
>>>>> - if (future == null || future.isDone()) {
>>>>> - future = ExecutionPool.schedule(this, 1,
>>>>> TimeUnit.SECONDS);
>>>>> - }
>>>>> - }
>>>>> - try {
>>>>> - return entities.get().get(pk);
>>>>> - } catch (RuntimeException e) {
>>>>> - throw e;
>>>>> - } catch (GenericEntityException e) {
>>>>> - throw e;
>>>>> - } catch (Exception e) {
>>>>> - throw UtilMisc.initCause(new
>>>>> GenericEntityException(e.getMessage()), e);
>>>>> - }
>>>>> - }
>>>>> -
>>>>> - public Void call() {
>>>>> - EntityHolder oldEntities;
>>>>> - EntityHolder newEntities = new
>>>>> EntityHolder(Updater.class, "entities", null);
>>>>> - do {
>>>>> - oldEntities = entities.get();
>>>>> - } while (!entities.compareAndSet(oldEntities,
>>>>> newEntities));
>>>>> - synchronized (Updater.class) {
>>>>> - for (GenericPK pk: oldEntities.keys()) {
>>>>> - try {
>>>>> - Map<String, Long> add =
>>>>> oldEntities.get(pk);
>>>>> - GenericValue existing =
>>>>> pk.getDelegator().findOne(pk.getEntityName(), pk, false);
>>>>> - if (existing == null) {
>>>>> - existing =
>>>>> pk.getDelegator().create(pk.getEntityName(), pk);
>>>>> - }
>>>>> - for (Map.Entry<String, Long> entry:
>>>>> add.entrySet()) {
>>>>> - Long value = entry.getValue();
>>>>> - Long oldValue =
>>>>> existing.getLong(entry.getKey());
>>>>> - if (oldValue != null) {
>>>>> - existing.put(entry.getKey(),
>>>>> Long.valueOf(value.longValue() + oldValue.longValue()));
>>>>> - } else {
>>>>> - existing.put(entry.getKey(),
>>>>> value);
>>>>> - }
>>>>> - }
>>>>> - existing.store();
>>>>> - } catch (Exception e) {
>>>>> - e.printStackTrace();
>>>>> - }
>>>>> - }
>>>>> - }
>>>>> - return null;
>>>>> - }
>>>>> - }
>>>>> -
>>>>> - private static final class EntityHolder extends
>>>>> ConcurrentCache<GenericPK, Map<String, Long>> {
>>>>> - protected EntityHolder(Class<?> owner, String field,
>>>>> String label) {
>>>>> - super(owner, field, label, HARD);
>>>>> - }
>>>>> -
>>>>> - @Override
>>>>> - protected Map<String, Long> createValue(GenericPK pk)
>>>>> throws Exception {
>>>>> - return new HashMap<String, Long>();
>>>>> - }
>>>>> - }
>>>>> -}
>>>>> +/
>>>>> *******************************************************************************
>>>>> + * 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.webslinger;
>>>>> +
>>>>> +import java.util.HashMap;
>>>>> +import java.util.Map;
>>>>> +import java.util.concurrent.Callable;
>>>>> +import java.util.concurrent.ScheduledFuture;
>>>>> +import java.util.concurrent.TimeUnit;
>>>>> +import java.util.concurrent.atomic.AtomicReference;
>>>>> +
>>>>> +import org.ofbiz.base.util.UtilMisc;
>>>>> +import org.ofbiz.entity.Delegator;
>>>>> +import org.ofbiz.entity.GenericEntityException;
>>>>> +import org.ofbiz.entity.GenericPK;
>>>>> +import org.ofbiz.entity.GenericValue;
>>>>> +import org.webslinger.cache.ConcurrentCache;
>>>>> +import org.webslinger.concurrent.ExecutionPool;
>>>>> +
>>>>> +public class StatsUpdater {
>>>>> + private static final Updater UPDATER = new Updater();
>>>>> +
>>>>> + public static void updateStats(Delegator delegator,
>>>>> String entityName, Map<String, ? extends Object> keyFields,
>>>>> Map<String, ? extends Long> updateCountFields) throws
>>>>> GenericEntityException {
>>>>> + GenericPK pk = delegator.makePK(entityName, keyFields);
>>>>> + Map<String, Long> value = UPDATER.getValue(pk);
>>>>> + synchronized (value) {
>>>>> + for (Map.Entry<String, ? extends Long> entry:
>>>>> updateCountFields.entrySet()) {
>>>>> + Long oldValue = value.get(entry.getKey());
>>>>> + if (oldValue != null) {
>>>>> + value.put(entry.getKey(),
>>>>> Long.valueOf(oldValue.longValue() + entry.getValue()));
>>>>> + } else {
>>>>> + value.put(entry.getKey(), entry.getValue());
>>>>> + }
>>>>> + }
>>>>> + }
>>>>> + }
>>>>> +
>>>>> + private static final class Updater implements
>>>>> Callable<Void> {
>>>>> + protected AtomicReference<EntityHolder> entities =
>>>>> new AtomicReference<EntityHolder>(new
>>>>> EntityHolder(Updater.class, "entities", null));
>>>>> + protected ScheduledFuture<Void> future;
>>>>> +
>>>>> + protected Map<String, Long> getValue(GenericPK pk)
>>>>> throws GenericEntityException {
>>>>> + synchronized (this) {
>>>>> + if (future == null || future.isDone()) {
>>>>> + future = ExecutionPool.schedule(this, 1,
>>>>> TimeUnit.SECONDS);
>>>>> + }
>>>>> + }
>>>>> + try {
>>>>> + return entities.get().get(pk);
>>>>> + } catch (RuntimeException e) {
>>>>> + throw e;
>>>>> + } catch (GenericEntityException e) {
>>>>> + throw e;
>>>>> + } catch (Exception e) {
>>>>> + throw UtilMisc.initCause(new
>>>>> GenericEntityException(e.getMessage()), e);
>>>>> + }
>>>>> + }
>>>>> +
>>>>> + public Void call() {
>>>>> + EntityHolder oldEntities;
>>>>> + EntityHolder newEntities = new
>>>>> EntityHolder(Updater.class, "entities", null);
>>>>> + do {
>>>>> + oldEntities = entities.get();
>>>>> + } while (!entities.compareAndSet(oldEntities,
>>>>> newEntities));
>>>>> + synchronized (Updater.class) {
>>>>> + for (GenericPK pk: oldEntities.keys()) {
>>>>> + try {
>>>>> + Map<String, Long> add =
>>>>> oldEntities.get(pk);
>>>>> + GenericValue existing =
>>>>> pk.getDelegator().findOne(pk.getEntityName(), pk, false);
>>>>> + if (existing == null) {
>>>>> + existing =
>>>>> pk.getDelegator().create(pk.getEntityName(), pk);
>>>>> + }
>>>>> + for (Map.Entry<String, Long> entry:
>>>>> add.entrySet()) {
>>>>> + Long value = entry.getValue();
>>>>> + Long oldValue =
>>>>> existing.getLong(entry.getKey());
>>>>> + if (oldValue != null) {
>>>>> + existing.put(entry.getKey(),
>>>>> Long.valueOf(value.longValue() + oldValue.longValue()));
>>>>> + } else {
>>>>> + existing.put(entry.getKey(),
>>>>> value);
>>>>> + }
>>>>> + }
>>>>> + existing.store();
>>>>> + } catch (Exception e) {
>>>>> + e.printStackTrace();
>>>>> + }
>>>>> + }
>>>>> + }
>>>>> + return null;
>>>>> + }
>>>>> + }
>>>>> +
>>>>> + private static final class EntityHolder extends
>>>>> ConcurrentCache<GenericPK, Map<String, Long>> {
>>>>> + protected EntityHolder(Class<?> owner, String field,
>>>>> String label) {
>>>>> + super(owner, field, label, HARD);
>>>>> + }
>>>>> +
>>>>> + @Override
>>>>> + protected Map<String, Long> createValue(GenericPK pk)
>>>>> throws Exception {
>>>>> + return new HashMap<String, Long>();
>>>>> + }
>>>>> + }
>>>>> +}
>>>>>
>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/
>>>>> webslinger/ WebslingerContextMapper.java
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>> = = = = = = = = = =
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>>>> WebslingerContextMapper.java (original)
>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>>>> WebslingerContextMapper.java Sat Nov 7 18:18:33 2009
>>>>> @@ -1,218 +1,216 @@
>>>>> -/
>>>>> *******************************************************************************
>>>>> - * 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.webslinger;
>>>>> -
>>>>> -import java.io.IOException;
>>>>> -import java.net.URL;
>>>>> -import java.util.ArrayList;
>>>>> -import java.util.Arrays;
>>>>> -import java.util.HashSet;
>>>>> -import java.util.List;
>>>>> -import java.util.Set;
>>>>> -
>>>>> -import javax.servlet.ServletConfig;
>>>>> -import javax.servlet.ServletContext;
>>>>> -import javax.servlet.ServletException;
>>>>> -import javax.servlet.http.HttpServletRequest;
>>>>> -
>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>> -import org.ofbiz.base.util.UtilProperties;
>>>>> -import org.ofbiz.entity.Delegator;
>>>>> -import org.ofbiz.entity.DelegatorFactory;
>>>>> -import org.ofbiz.entity.GenericEntityException;
>>>>> -import org.ofbiz.entity.GenericValue;
>>>>> -import org.ofbiz.entity.cache.Cache;
>>>>> -import org.ofbiz.entity.util.EntityUtil;
>>>>> -import org.ofbiz.security.SecurityFactory;
>>>>> -import org.ofbiz.security.authz.AuthorizationFactory;
>>>>> -import org.ofbiz.service.GenericDispatcher;
>>>>> -import org.ofbiz.service.LocalDispatcher;
>>>>> -import org.ofbiz.service.ServiceDispatcher;
>>>>> -import org.ofbiz.service.DispatchContext;
>>>>> -
>>>>> -import
>>>>> org.webslinger.AbstractMappingWebslingerServletContextFactory;
>>>>> -import org.webslinger.WebslingerServletContext;
>>>>> -import org.webslinger.collections.CollectionUtil;
>>>>> -import org.webslinger.lang.ObjectUtil;
>>>>> -
>>>>> -public class WebslingerContextMapper extends
>>>>> AbstractMappingWebslingerServletContextFactory {
>>>>> - protected ServletContext servletContext;
>>>>> - protected Delegator delegator;
>>>>> - protected final ArrayList<URL> globalReaderURLs = new
>>>>> ArrayList<URL>();
>>>>> -
>>>>> - public void init(ServletConfig config) throws
>>>>> ServletException, IOException {
>>>>> -
>>>>> System
>>>>> .err
>>>>> .println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
>>>>> - servletContext = config.getServletContext();
>>>>> - String delegatorName =
>>>>> servletContext.getInitParameter("entityDelegatorName");
>>>>> - delegator = DelegatorFactory.getDelegator(delegatorName);
>>>>> - String readerFiles =
>>>>> servletContext.getInitParameter("serviceReaderUrls");
>>>>> - if (readerFiles != null) {
>>>>> - for (String reader:
>>>>> CollectionUtil.split(readerFiles, ";")) {
>>>>> - URL url =
>>>>> config.getServletContext().getResource(reader);
>>>>> - if (url != null) globalReaderURLs.add(url);
>>>>> - }
>>>>> - }
>>>>> - super.init(config,
>>>>> UtilProperties.getPropertyValue("webslinger.properties",
>>>>> "moduleBase"));
>>>>> - }
>>>>> -
>>>>> - @Override
>>>>> - protected Layout[] getStartLayouts() throws Exception {
>>>>> - ArrayList<Layout> layouts = new ArrayList<Layout>();
>>>>> - try {
>>>>> - for (GenericValue value:
>>>>> delegator.findByAnd("WebslingerServer",
>>>>> UtilMisc.toMap("loadAtStart", "Y"))) {
>>>>> - layouts.add(new OfbizLayout(value));
>>>>> - }
>>>>> - } catch (GenericEntityException e) {
>>>>> - }
>>>>> - return layouts.toArray(new Layout[layouts.size()]);
>>>>> - }
>>>>> -
>>>>> - @Override
>>>>> - public void initializeRequest(WebslingerServletContext
>>>>> context, HttpServletRequest request) {
>>>>> - request.setAttribute("servletContext", context);
>>>>> - Object delegator = context.getAttribute("delegator");
>>>>> - Object dispatcher = context.getAttribute("dispatcher");
>>>>> - Object authz = context.getAttribute("authz");
>>>>> - Object security = context.getAttribute("security");
>>>>> - request.setAttribute("delegator", delegator);
>>>>> - request.setAttribute("dispatcher", dispatcher);
>>>>> - request.setAttribute("authz", authz);
>>>>> - request.setAttribute("security", security);
>>>>> - // FIXME!!! These next two are a hack until proper
>>>>> fake/ wrapped session support is done in webslinger
>>>>> - servletContext.setAttribute("delegator", delegator);
>>>>> - servletContext.setAttribute("dispatcher", dispatcher);
>>>>> - servletContext.setAttribute("authz", authz);
>>>>> - servletContext.setAttribute("security", security);
>>>>> - }
>>>>> -
>>>>> - @Override
>>>>> - protected void initializeContext(WebslingerServletContext
>>>>> context, Layout layout) throws Exception {
>>>>> - OfbizLayout ofbizLayout = (OfbizLayout) layout;
>>>>> - Delegator delegator = null;
>>>>> - delegator =
>>>>> DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
>>>>> - context.setAttribute("delegator", delegator);
>>>>> - context.setAttribute("dispatcher", new
>>>>> WebslingerGenericDispatcher(context, layout.getTarget(),
>>>>> delegator, globalReaderURLs));
>>>>> - context.setAttribute("authz",
>>>>> AuthorizationFactory.getInstance(delegator));
>>>>> - context.setAttribute("security",
>>>>> SecurityFactory.getInstance(delegator));
>>>>> - }
>>>>> -
>>>>> - protected static final class WebslingerGenericDispatcher
>>>>> extends GenericDispatcher {
>>>>> - protected
>>>>> WebslingerGenericDispatcher(WebslingerServletContext context,
>>>>> String name, Delegator delegator, List<URL> globalReaderURLs)
>>>>> throws IOException {
>>>>> - ArrayList<URL> readerURLs = new
>>>>> ArrayList<URL>(globalReaderURLs);
>>>>> - String readerFiles =
>>>>> context.getInitParameter("serviceReaderUrls");
>>>>> - if (readerFiles != null) {
>>>>> - for (String reader:
>>>>> CollectionUtil.split(readerFiles, ";")) {
>>>>> - URL url = context.getResource(reader);
>>>>> - if (url != null) readerURLs.add(url);
>>>>> - }
>>>>> - }
>>>>> - System.err.println(readerURLs);
>>>>> - this.dispatcher = new
>>>>> ServiceDispatcher(delegator, true, true, true) {
>>>>> - };
>>>>> - ClassLoader loader = null;
>>>>> - try {
>>>>> - loader =
>>>>> Thread.currentThread().getContextClassLoader();
>>>>> - } catch (SecurityException e) {
>>>>> - loader =
>>>>> WebslingerContextMapper.class.getClassLoader();
>>>>> - }
>>>>> - DispatchContext dc = new DispatchContext(name,
>>>>> readerURLs, loader, null);
>>>>> - init(name, delegator, dc);
>>>>> - }
>>>>> - }
>>>>> -
>>>>> - @Override
>>>>> - protected Set<String> getSuffixes() throws Exception {
>>>>> - Cache cache = delegator.getCache();
>>>>> - Set<String> suffixes;
>>>>> - synchronized (WebslingerContextMapper.class) {
>>>>> - suffixes = cache.get("WebslingerHostSuffix",
>>>>> null, "WebslingerContextMapper.Suffixes");
>>>>> - if (suffixes == null) {
>>>>> - suffixes = new HashSet<String>();
>>>>> - for (GenericValue value:
>>>>> delegator.findList("WebslingerHostSuffix", null, null, null,
>>>>> null, false)) {
>>>>> - suffixes.add(value.getString("hostSuffix"));
>>>>> - }
>>>>> - cache.put("WebslingerHostSuffix", null,
>>>>> "WebslingerContextMapper.Suffixes", suffixes);
>>>>> - }
>>>>> - }
>>>>> - return suffixes;
>>>>> - }
>>>>> -
>>>>> - @Override
>>>>> - protected Layout lookupLayout(String hostName, String
>>>>> contextPath) throws Exception {
>>>>> - GenericValue layout =
>>>>> EntityUtil
>>>>> .getOnly(delegator.findByAndCache("WebslingerLayout",
>>>>> UtilMisc.toMap("hostName", hostName, "contextPath",
>>>>> contextPath)));
>>>>> - if (layout == null) return null;
>>>>> - return new OfbizLayout(layout);
>>>>> - }
>>>>> -
>>>>> - protected class OfbizLayout implements Layout {
>>>>> - private final String contextPath;
>>>>> - private final String id;
>>>>> - private final String target;
>>>>> - private final String[] bases;
>>>>> - private final int hashCode;
>>>>> - protected final String delegatorName;
>>>>> - protected final String dispatcherName;
>>>>> -
>>>>> - protected OfbizLayout(GenericValue server) throws
>>>>> GenericEntityException {
>>>>> - contextPath = server.getString("contextPath");
>>>>> - id = server.getString("webslingerServerId");
>>>>> - target = server.getString("target");
>>>>> - List<GenericValue> baseValues =
>>>>> server.getRelatedCache("WebslingerServerBase",
>>>>> UtilMisc.toList("seqNum"));
>>>>> - bases = new String[baseValues.size()];
>>>>> - for (int i = 0; i < bases.length; i++) {
>>>>> - GenericValue baseValue = baseValues.get(i);
>>>>> - bases[i] = baseValue.getString("baseName");
>>>>> - }
>>>>> - delegatorName = server.getString("delegatorName");
>>>>> - dispatcherName = server.getString("dispatcherName");
>>>>> - hashCode = target.hashCode() ^
>>>>> ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
>>>>> - }
>>>>> -
>>>>> - public String getContextPath() {
>>>>> - return contextPath;
>>>>> - }
>>>>> -
>>>>> - public String getId() {
>>>>> - return id;
>>>>> - }
>>>>> -
>>>>> - public String getTarget() {
>>>>> - return target;
>>>>> - }
>>>>> -
>>>>> - public String[] getBases() {
>>>>> - return bases;
>>>>> - }
>>>>> -
>>>>> - @Override
>>>>> - public int hashCode() {
>>>>> - return hashCode;
>>>>> - }
>>>>> -
>>>>> - @Override
>>>>> - public boolean equals(Object o) {
>>>>> - if (!(o instanceof OfbizLayout)) return false;
>>>>> - OfbizLayout other = (OfbizLayout) o;
>>>>> - if (!contextPath.equals(other.contextPath)) return
>>>>> false;
>>>>> - if (!target.equals(other.target)) return false;
>>>>> - if (!ObjectUtil.equalsHelper(delegatorName,
>>>>> other.delegatorName)) return false;
>>>>> - return Arrays.equals(bases, other.bases);
>>>>> - }
>>>>> - }
>>>>> -}
>>>>> +/
>>>>> *******************************************************************************
>>>>> + * 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.webslinger;
>>>>> +
>>>>> +import java.io.IOException;
>>>>> +import java.net.URL;
>>>>> +import java.util.ArrayList;
>>>>> +import java.util.Arrays;
>>>>> +import java.util.HashSet;
>>>>> +import java.util.List;
>>>>> +import java.util.Set;
>>>>> +
>>>>> +import javax.servlet.ServletConfig;
>>>>> +import javax.servlet.ServletContext;
>>>>> +import javax.servlet.ServletException;
>>>>> +import javax.servlet.http.HttpServletRequest;
>>>>> +
>>>>> +import org.ofbiz.base.util.UtilMisc;
>>>>> +import org.ofbiz.base.util.UtilProperties;
>>>>> +import org.ofbiz.entity.Delegator;
>>>>> +import org.ofbiz.entity.DelegatorFactory;
>>>>> +import org.ofbiz.entity.GenericEntityException;
>>>>> +import org.ofbiz.entity.GenericValue;
>>>>> +import org.ofbiz.entity.cache.Cache;
>>>>> +import org.ofbiz.entity.util.EntityUtil;
>>>>> +import org.ofbiz.security.SecurityFactory;
>>>>> +import org.ofbiz.security.authz.AuthorizationFactory;
>>>>> +import org.ofbiz.service.DispatchContext;
>>>>> +import org.ofbiz.service.GenericDispatcher;
>>>>> +import org.ofbiz.service.ServiceDispatcher;
>>>>> +import
>>>>> org.webslinger.AbstractMappingWebslingerServletContextFactory;
>>>>> +import org.webslinger.WebslingerServletContext;
>>>>> +import org.webslinger.collections.CollectionUtil;
>>>>> +import org.webslinger.lang.ObjectUtil;
>>>>> +
>>>>> +public class WebslingerContextMapper extends
>>>>> AbstractMappingWebslingerServletContextFactory {
>>>>> + protected ServletContext servletContext;
>>>>> + protected Delegator delegator;
>>>>> + protected final ArrayList<URL> globalReaderURLs = new
>>>>> ArrayList<URL>();
>>>>> +
>>>>> + public void init(ServletConfig config) throws
>>>>> ServletException, IOException {
>>>>> +
>>>>> System
>>>>> .err
>>>>> .println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
>>>>> + servletContext = config.getServletContext();
>>>>> + String delegatorName =
>>>>> servletContext.getInitParameter("entityDelegatorName");
>>>>> + delegator = DelegatorFactory.getDelegator(delegatorName);
>>>>> + String readerFiles =
>>>>> servletContext.getInitParameter("serviceReaderUrls");
>>>>> + if (readerFiles != null) {
>>>>> + for (String reader:
>>>>> CollectionUtil.split(readerFiles, ";")) {
>>>>> + URL url =
>>>>> config.getServletContext().getResource(reader);
>>>>> + if (url != null) globalReaderURLs.add(url);
>>>>> + }
>>>>> + }
>>>>> + super.init(config,
>>>>> UtilProperties.getPropertyValue("webslinger.properties",
>>>>> "moduleBase"));
>>>>> + }
>>>>> +
>>>>> + @Override
>>>>> + protected Layout[] getStartLayouts() throws Exception {
>>>>> + ArrayList<Layout> layouts = new ArrayList<Layout>();
>>>>> + try {
>>>>> + for (GenericValue value:
>>>>> delegator.findByAnd("WebslingerServer",
>>>>> UtilMisc.toMap("loadAtStart", "Y"))) {
>>>>> + layouts.add(new OfbizLayout(value));
>>>>> + }
>>>>> + } catch (GenericEntityException e) {
>>>>> + }
>>>>> + return layouts.toArray(new Layout[layouts.size()]);
>>>>> + }
>>>>> +
>>>>> + @Override
>>>>> + public void initializeRequest(WebslingerServletContext
>>>>> context, HttpServletRequest request) {
>>>>> + request.setAttribute("servletContext", context);
>>>>> + Object delegator = context.getAttribute("delegator");
>>>>> + Object dispatcher = context.getAttribute("dispatcher");
>>>>> + Object authz = context.getAttribute("authz");
>>>>> + Object security = context.getAttribute("security");
>>>>> + request.setAttribute("delegator", delegator);
>>>>> + request.setAttribute("dispatcher", dispatcher);
>>>>> + request.setAttribute("authz", authz);
>>>>> + request.setAttribute("security", security);
>>>>> + // FIXME!!! These next two are a hack until proper
>>>>> fake/ wrapped session support is done in webslinger
>>>>> + servletContext.setAttribute("delegator", delegator);
>>>>> + servletContext.setAttribute("dispatcher", dispatcher);
>>>>> + servletContext.setAttribute("authz", authz);
>>>>> + servletContext.setAttribute("security", security);
>>>>> + }
>>>>> +
>>>>> + @Override
>>>>> + protected void initializeContext(WebslingerServletContext
>>>>> context, Layout layout) throws Exception {
>>>>> + OfbizLayout ofbizLayout = (OfbizLayout) layout;
>>>>> + Delegator delegator = null;
>>>>> + delegator =
>>>>> DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
>>>>> + context.setAttribute("delegator", delegator);
>>>>> + context.setAttribute("dispatcher", new
>>>>> WebslingerGenericDispatcher(context, layout.getTarget(),
>>>>> delegator, globalReaderURLs));
>>>>> + context.setAttribute("authz",
>>>>> AuthorizationFactory.getInstance(delegator));
>>>>> + context.setAttribute("security",
>>>>> SecurityFactory.getInstance(delegator));
>>>>> + }
>>>>> +
>>>>> + protected static final class WebslingerGenericDispatcher
>>>>> extends GenericDispatcher {
>>>>> + protected
>>>>> WebslingerGenericDispatcher(WebslingerServletContext context,
>>>>> String name, Delegator delegator, List<URL> globalReaderURLs)
>>>>> throws IOException {
>>>>> + ArrayList<URL> readerURLs = new
>>>>> ArrayList<URL>(globalReaderURLs);
>>>>> + String readerFiles =
>>>>> context.getInitParameter("serviceReaderUrls");
>>>>> + if (readerFiles != null) {
>>>>> + for (String reader:
>>>>> CollectionUtil.split(readerFiles, ";")) {
>>>>> + URL url = context.getResource(reader);
>>>>> + if (url != null) readerURLs.add(url);
>>>>> + }
>>>>> + }
>>>>> + System.err.println(readerURLs);
>>>>> + this.dispatcher = new
>>>>> ServiceDispatcher(delegator, true, true, true) {
>>>>> + };
>>>>> + ClassLoader loader = null;
>>>>> + try {
>>>>> + loader =
>>>>> Thread.currentThread().getContextClassLoader();
>>>>> + } catch (SecurityException e) {
>>>>> + loader =
>>>>> WebslingerContextMapper.class.getClassLoader();
>>>>> + }
>>>>> + DispatchContext dc = new DispatchContext(name,
>>>>> readerURLs, loader, null);
>>>>> + init(name, delegator, dc);
>>>>> + }
>>>>> + }
>>>>> +
>>>>> + @Override
>>>>> + protected Set<String> getSuffixes() throws Exception {
>>>>> + Cache cache = delegator.getCache();
>>>>> + Set<String> suffixes;
>>>>> + synchronized (WebslingerContextMapper.class) {
>>>>> + suffixes = cache.get("WebslingerHostSuffix",
>>>>> null, "WebslingerContextMapper.Suffixes");
>>>>> + if (suffixes == null) {
>>>>> + suffixes = new HashSet<String>();
>>>>> + for (GenericValue value:
>>>>> delegator.findList("WebslingerHostSuffix", null, null, null,
>>>>> null, false)) {
>>>>> + suffixes.add(value.getString("hostSuffix"));
>>>>> + }
>>>>> + cache.put("WebslingerHostSuffix", null,
>>>>> "WebslingerContextMapper.Suffixes", suffixes);
>>>>> + }
>>>>> + }
>>>>> + return suffixes;
>>>>> + }
>>>>> +
>>>>> + @Override
>>>>> + protected Layout lookupLayout(String hostName, String
>>>>> contextPath) throws Exception {
>>>>> + GenericValue layout =
>>>>> EntityUtil
>>>>> .getOnly(delegator.findByAndCache("WebslingerLayout",
>>>>> UtilMisc.toMap("hostName", hostName, "contextPath",
>>>>> contextPath)));
>>>>> + if (layout == null) return null;
>>>>> + return new OfbizLayout(layout);
>>>>> + }
>>>>> +
>>>>> + protected class OfbizLayout implements Layout {
>>>>> + private final String contextPath;
>>>>> + private final String id;
>>>>> + private final String target;
>>>>> + private final String[] bases;
>>>>> + private final int hashCode;
>>>>> + protected final String delegatorName;
>>>>> + protected final String dispatcherName;
>>>>> +
>>>>> + protected OfbizLayout(GenericValue server) throws
>>>>> GenericEntityException {
>>>>> + contextPath = server.getString("contextPath");
>>>>> + id = server.getString("webslingerServerId");
>>>>> + target = server.getString("target");
>>>>> + List<GenericValue> baseValues =
>>>>> server.getRelatedCache("WebslingerServerBase",
>>>>> UtilMisc.toList("seqNum"));
>>>>> + bases = new String[baseValues.size()];
>>>>> + for (int i = 0; i < bases.length; i++) {
>>>>> + GenericValue baseValue = baseValues.get(i);
>>>>> + bases[i] = baseValue.getString("baseName");
>>>>> + }
>>>>> + delegatorName = server.getString("delegatorName");
>>>>> + dispatcherName = server.getString("dispatcherName");
>>>>> + hashCode = target.hashCode() ^
>>>>> ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
>>>>> + }
>>>>> +
>>>>> + public String getContextPath() {
>>>>> + return contextPath;
>>>>> + }
>>>>> +
>>>>> + public String getId() {
>>>>> + return id;
>>>>> + }
>>>>> +
>>>>> + public String getTarget() {
>>>>> + return target;
>>>>> + }
>>>>> +
>>>>> + public String[] getBases() {
>>>>> + return bases;
>>>>> + }
>>>>> +
>>>>> + @Override
>>>>> + public int hashCode() {
>>>>> + return hashCode;
>>>>> + }
>>>>> +
>>>>> + @Override
>>>>> + public boolean equals(Object o) {
>>>>> + if (!(o instanceof OfbizLayout)) return false;
>>>>> + OfbizLayout other = (OfbizLayout) o;
>>>>> + if (!contextPath.equals(other.contextPath)) return
>>>>> false;
>>>>> + if (!target.equals(other.target)) return false;
>>>>> + if (!ObjectUtil.equalsHelper(delegatorName,
>>>>> other.delegatorName)) return false;
>>>>> + return Arrays.equals(bases, other.bases);
>>>>> + }
>>>>> + }
>>>>> +}
>>>>>
>>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/
>>>>> webslinger/ WebslingerServerEngine.java
>>>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java?rev=833727&r1=833726&r2=833727&view=diff
>>>>> = = = = = = = = = =
>>>>> =
>>>>> =
>>>>> ==================================================================
>>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>>>> WebslingerServerEngine.java (original)
>>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>>>> WebslingerServerEngine.java Sat Nov 7 18:18:33 2009
>>>>> @@ -1,64 +1,59 @@
>>>>> -/
>>>>> *******************************************************************************
>>>>> - * 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.webslinger;
>>>>> -
>>>>> -import java.io.IOException;
>>>>> -import java.io.StringReader;
>>>>> -import java.io.StringWriter;
>>>>> -import java.util.Collections;
>>>>> -import java.util.Map;
>>>>> -
>>>>> -import org.ofbiz.base.util.UtilGenerics;
>>>>> -import org.ofbiz.base.util.UtilMisc;
>>>>> -import org.ofbiz.entity.Delegator;
>>>>> -import org.ofbiz.entity.GenericValue;
>>>>> -import org.ofbiz.entity.util.EntityUtil;
>>>>> -import org.ofbiz.service.GenericServiceException;
>>>>> -import org.ofbiz.service.ModelService;
>>>>> -import org.ofbiz.service.ServiceDispatcher;
>>>>> -import org.ofbiz.service.engine.GenericAsyncEngine;
>>>>> -
>>>>> -import org.webslinger.WebslingerServletContext;
>>>>> -
>>>>> -public class WebslingerServerEngine extends GenericAsyncEngine {
>>>>> - public WebslingerServerEngine(ServiceDispatcher dispatcher) {
>>>>> - super(dispatcher);
>>>>> - }
>>>>> -
>>>>> - @Override
>>>>> - public void runSyncIgnore(String localName, ModelService
>>>>> modelService, Map<String, Object> context) throws
>>>>> GenericServiceException {
>>>>> - runSync(localName, modelService, context);
>>>>> - }
>>>>> -
>>>>> - @Override
>>>>> - public Map<String, Object> runSync(String localName,
>>>>> ModelService modelService, Map<String, Object> context) throws
>>>>> GenericServiceException {
>>>>> - Delegator delegator = dispatcher.getDelegator();
>>>>> - try {
>>>>> - GenericValue found =
>>>>> EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout",
>>>>> UtilMisc.toMap("webslingerServerId", modelService.location)));
>>>>> - if (found == null) throw new
>>>>> GenericServiceException("Couldn't find server mapping for(" +
>>>>> modelService.location + ")");
>>>>> - return UtilGenerics .checkMap
>>>>> (WebslingerServletContext
>>>>> .invokeInVM(found.getString("hostName"), 8080,
>>>>> modelService.invoke, context));
>>>>> - } catch (RuntimeException e) {
>>>>> - throw e;
>>>>> - } catch (GenericServiceException e) {
>>>>> - throw e;
>>>>> - } catch (Exception e) {
>>>>> - throw UtilMisc.initCause(new
>>>>> GenericServiceException(e.getMessage()), e);
>>>>> - }
>>>>> - }
>>>>> -}
>>>>> +/
>>>>> *******************************************************************************
>>>>> + * 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.webslinger;
>>>>> +
>>>>> +import java.util.Map;
>>>>> +
>>>>> +import org.ofbiz.base.util.UtilGenerics;
>>>>> +import org.ofbiz.base.util.UtilMisc;
>>>>> +import org.ofbiz.entity.Delegator;
>>>>> +import org.ofbiz.entity.GenericValue;
>>>>> +import org.ofbiz.entity.util.EntityUtil;
>>>>> +import org.ofbiz.service.GenericServiceException;
>>>>> +import org.ofbiz.service.ModelService;
>>>>> +import org.ofbiz.service.ServiceDispatcher;
>>>>> +import org.ofbiz.service.engine.GenericAsyncEngine;
>>>>> +import org.webslinger.WebslingerServletContext;
>>>>> +
>>>>> +public class WebslingerServerEngine extends GenericAsyncEngine {
>>>>> + public WebslingerServerEngine(ServiceDispatcher dispatcher) {
>>>>> + super(dispatcher);
>>>>> + }
>>>>> +
>>>>> + @Override
>>>>> + public void runSyncIgnore(String localName, ModelService
>>>>> modelService, Map<String, Object> context) throws
>>>>> GenericServiceException {
>>>>> + runSync(localName, modelService, context);
>>>>> + }
>>>>> +
>>>>> + @Override
>>>>> + public Map<String, Object> runSync(String localName,
>>>>> ModelService modelService, Map<String, Object> context) throws
>>>>> GenericServiceException {
>>>>> + Delegator delegator = dispatcher.getDelegator();
>>>>> + try {
>>>>> + GenericValue found =
>>>>> EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout",
>>>>> UtilMisc.toMap("webslingerServerId", modelService.location)));
>>>>> + if (found == null) throw new
>>>>> GenericServiceException("Couldn't find server mapping for(" +
>>>>> modelService.location + ")");
>>>>> + return UtilGenerics .checkMap
>>>>> (WebslingerServletContext
>>>>> .invokeInVM(found.getString("hostName"), 8080,
>>>>> modelService.invoke, context));
>>>>> + } catch (RuntimeException e) {
>>>>> + throw e;
>>>>> + } catch (GenericServiceException e) {
>>>>> + throw e;
>>>>> + } catch (Exception e) {
>>>>> + throw UtilMisc.initCause(new
>>>>> GenericServiceException(e.getMessage()), e);
>>>>> + }
>>>>> + }
>>>>> +}
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>
>
Re: svn commit: r833727 - in /ofbiz/trunk/framework/webslinger/src/org/ofbiz: commons/vfs/ commons/vfs/ofbiz/ webslinger/
Posted by Jacques Le Roux <ja...@les7arts.com>.
I replaced my .subversion/config by ours. Not sure why it has been replaced, by an install maybe or as I'm on Windows, Tortoise
while changing the setting...
Jacques
From: "Scott Gray" <sc...@hotwaxmedia.com>
> Hi Jacques,
>
> I think the problem is related to files in svn that do not have any svn properties set (specifically eol-style), I just came
> across this myself in r833931 and r833933. When I initially applied the patch the entire file changed but after setting the svn
> properties the issue went away.
>
> Regards
> Scott
>
> On 9/11/2009, at 11:32 AM, Jacques Le Roux wrote:
>
>> Sorry Scott,
>>
>> I have still not got the reflex... As I have not touched the patch (ok you have to trust me) you may review the patch itself...
>>
>> Jacques
>>
>> From: "Scott Gray" <sc...@hotwaxmedia.com>
>>> Hi Jacques,
>>>
>>> This is that same problem with the patch again, please keep an eye out for these as the commits are impossible to review.
>>>
>>> Thanks
>>> Scott
>>>
>>> HotWax Media
>>> http://www.hotwaxmedia.com
>>>
>>> On 8/11/2009, at 7:18 AM, jleroux@apache.org wrote:
>>>
>>>> Author: jleroux
>>>> Date: Sat Nov 7 18:18:33 2009
>>>> New Revision: 833727
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=833727&view=rev
>>>> Log:
>>>> A patch from Marc Morin "Resolve java warnings exposed in Eclipse : framework - webslinger"
>>>> (https://issues.apache.org/jira/browse/OFBIZ-3121 ) - OFBIZ-3121
>>>>
>>>> Modified:
>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ CommonsVfsContainer.java
>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/ OfbizComponentProvider.java
>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/ OfbizHomeProvider.java
>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ EntityHttpUtil.java
>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ StatsUpdater.java
>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerContextMapper.java
>>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerServerEngine.java
>>>>
>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/ vfs/ CommonsVfsContainer.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java?rev=833727&r1=833726&r2=833727&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ CommonsVfsContainer.java (original)
>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ CommonsVfsContainer.java Sat Nov 7 18:18:33 2009
>>>> @@ -1,68 +1,66 @@
>>>> -/ *******************************************************************************
>>>> - * 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.commons.vfs;
>>>> -
>>>> -import java.io.File;
>>>> -import java.io.IOException;
>>>> -import java.net.MalformedURLException;
>>>> -
>>>> -import org.apache.commons.vfs.CacheStrategy;
>>>> -import org.apache.commons.vfs.FileObject;
>>>> -import org.apache.commons.vfs.FileSystemException;
>>>> -import org.apache.commons.vfs.FileSystemManager;
>>>> -import org.apache.commons.vfs.impl.StandardFileSystemManager;
>>>> -
>>>> -import org.ofbiz.base.container.Container;
>>>> -import org.ofbiz.base.container.ContainerException;
>>>> -import org.ofbiz.base.util.UtilMisc;
>>>> -import org.webslinger.commons.vfs.VFSUtil;
>>>> -
>>>> -public class CommonsVfsContainer implements Container {
>>>> - private static StandardFileSystemManager sfsm;
>>>> -
>>>> - public void init(String[] args, String configFile) throws ContainerException {
>>>> - }
>>>> -
>>>> - public boolean start() throws ContainerException {
>>>> - try {
>>>> - StandardFileSystemManager sfsm = VFSUtil.createStandardFileSystemManager();
>>>> - FileObject currentDir = sfsm.resolveFile(new File(".").toURI().toURL().toString());
>>>> - sfsm.setBaseFile(currentDir);
>>>> - CommonsVfsContainer.sfsm = sfsm;
>>>> - } catch (FileSystemException e) {
>>>> - throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
>>>> - } catch (MalformedURLException e) {
>>>> - throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
>>>> - }
>>>> - return true;
>>>> - }
>>>> -
>>>> - public void stop() throws ContainerException {
>>>> - sfsm.close();
>>>> - sfsm = null;
>>>> - }
>>>> -
>>>> - public static FileObject resolveFile(String uri) throws IOException {
>>>> - return sfsm.resolveFile(uri);
>>>> - }
>>>> -
>>>> - public static FileSystemManager getFileSystemManager() {
>>>> - return sfsm;
>>>> - }
>>>> -}
>>>> +/ *******************************************************************************
>>>> + * 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.commons.vfs;
>>>> +
>>>> +import java.io.File;
>>>> +import java.io.IOException;
>>>> +import java.net.MalformedURLException;
>>>> +
>>>> +import org.apache.commons.vfs.FileObject;
>>>> +import org.apache.commons.vfs.FileSystemException;
>>>> +import org.apache.commons.vfs.FileSystemManager;
>>>> +import org.apache.commons.vfs.impl.StandardFileSystemManager;
>>>> +import org.ofbiz.base.container.Container;
>>>> +import org.ofbiz.base.container.ContainerException;
>>>> +import org.ofbiz.base.util.UtilMisc;
>>>> +import org.webslinger.commons.vfs.VFSUtil;
>>>> +
>>>> +public class CommonsVfsContainer implements Container {
>>>> + private static StandardFileSystemManager sfsm;
>>>> +
>>>> + public void init(String[] args, String configFile) throws ContainerException {
>>>> + }
>>>> +
>>>> + public boolean start() throws ContainerException {
>>>> + try {
>>>> + StandardFileSystemManager sfsm = VFSUtil.createStandardFileSystemManager();
>>>> + FileObject currentDir = sfsm.resolveFile(new File(".").toURI().toURL().toString());
>>>> + sfsm.setBaseFile(currentDir);
>>>> + CommonsVfsContainer.sfsm = sfsm;
>>>> + } catch (FileSystemException e) {
>>>> + throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
>>>> + } catch (MalformedURLException e) {
>>>> + throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
>>>> + }
>>>> + return true;
>>>> + }
>>>> +
>>>> + public void stop() throws ContainerException {
>>>> + sfsm.close();
>>>> + sfsm = null;
>>>> + }
>>>> +
>>>> + public static FileObject resolveFile(String uri) throws IOException {
>>>> + return sfsm.resolveFile(uri);
>>>> + }
>>>> +
>>>> + public static FileSystemManager getFileSystemManager() {
>>>> + return sfsm;
>>>> + }
>>>> +}
>>>>
>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/ vfs/ ofbiz/OfbizComponentProvider.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java?rev=833727&r1=833726&r2=833727&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/ OfbizComponentProvider.java (original)
>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/ OfbizComponentProvider.java Sat Nov 7 18:18:33 2009
>>>> @@ -1,58 +1,58 @@
>>>> -/ *******************************************************************************
>>>> - * 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.commons.vfs.ofbiz;
>>>> -
>>>> -import java.net.URL;
>>>> -import java.util.Collection;
>>>> -import org.apache.commons.vfs.FileObject;
>>>> -import org.apache.commons.vfs.FileSystemException;
>>>> -import org.apache.commons.vfs.FileSystemOptions;
>>>> -import org.apache.commons.vfs.provider.AbstractFileProvider;
>>>> -import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>>> -import org.ofbiz.base.location.FlexibleLocation;
>>>> -import org.ofbiz.base.util.UtilMisc;
>>>> -import org.webslinger.commons.vfs.VFSUtil;
>>>> -
>>>> -public class OfbizComponentProvider extends AbstractFileProvider {
>>>> - public Collection getCapabilities() {
>>>> - return DefaultLocalFileProvider.capabilities;
>>>> - }
>>>> -
>>>> - public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
>>>> - try {
>>>> - //name = name.replaceAll("^ofbiz-component://", "");
>>>> - int nameLength = name.length();
>>>> - int componentNameStart = 16;
>>>> - while (componentNameStart < nameLength && name.charAt(componentNameStart) == '/') componentNameStart++;
>>>> - if (componentNameStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>>>> - int componentNameEnd = componentNameStart;
>>>> - while (componentNameEnd < nameLength && name.charAt(componentNameEnd) != '/') componentNameEnd++;
>>>> - if (componentNameEnd == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>>>> - int restStart = componentNameEnd;
>>>> - while (restStart < nameLength && name.charAt(restStart) == '/') restStart++;
>>>> - if (restStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>>>> - String componentName = name.substring(componentNameStart, componentNameEnd);
>>>> - URL location = FlexibleLocation.resolveLocation("component://" + componentName + "/.");
>>>> - FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
>>>> - return VFSUtil .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase
>>>> .resolveFile(name.substring(restStart)).getURL().toString(), properties);
>>>> - } catch (Exception e) {
>>>> - throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
>>>> - }
>>>> - }
>>>> -}
>>>> +/ *******************************************************************************
>>>> + * 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.commons.vfs.ofbiz;
>>>> +
>>>> +import java.net.URL;
>>>> +import java.util.Collection;
>>>> +import org.apache.commons.vfs.FileObject;
>>>> +import org.apache.commons.vfs.FileSystemException;
>>>> +import org.apache.commons.vfs.FileSystemOptions;
>>>> +import org.apache.commons.vfs.provider.AbstractFileProvider;
>>>> +import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>>> +import org.ofbiz.base.location.FlexibleLocation;
>>>> +import org.ofbiz.base.util.UtilMisc;
>>>> +import org.webslinger.commons.vfs.VFSUtil;
>>>> +
>>>> +public class OfbizComponentProvider extends AbstractFileProvider {
>>>> + public Collection<?> getCapabilities() {
>>>> + return DefaultLocalFileProvider.capabilities;
>>>> + }
>>>> +
>>>> + public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
>>>> + try {
>>>> + //name = name.replaceAll("^ofbiz-component://", "");
>>>> + int nameLength = name.length();
>>>> + int componentNameStart = 16;
>>>> + while (componentNameStart < nameLength && name.charAt(componentNameStart) == '/') componentNameStart++;
>>>> + if (componentNameStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>>>> + int componentNameEnd = componentNameStart;
>>>> + while (componentNameEnd < nameLength && name.charAt(componentNameEnd) != '/') componentNameEnd++;
>>>> + if (componentNameEnd == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>>>> + int restStart = componentNameEnd;
>>>> + while (restStart < nameLength && name.charAt(restStart) == '/') restStart++;
>>>> + if (restStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>>>> + String componentName = name.substring(componentNameStart, componentNameEnd);
>>>> + URL location = FlexibleLocation.resolveLocation("component://" + componentName + "/.");
>>>> + FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
>>>> + return VFSUtil .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase
>>>> .resolveFile(name.substring(restStart)).getURL().toString(), properties);
>>>> + } catch (Exception e) {
>>>> + throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
>>>> + }
>>>> + }
>>>> +}
>>>>
>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/ vfs/ ofbiz/OfbizHomeProvider.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java?rev=833727&r1=833726&r2=833727&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/ OfbizHomeProvider.java (original)
>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/ OfbizHomeProvider.java Sat Nov 7 18:18:33 2009
>>>> @@ -1,50 +1,50 @@
>>>> -/ *******************************************************************************
>>>> - * 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.commons.vfs.ofbiz;
>>>> -
>>>> -import java.net.URL;
>>>> -import java.util.Collection;
>>>> -
>>>> -import org.apache.commons.vfs.FileObject;
>>>> -import org.apache.commons.vfs.FileSystemException;
>>>> -import org.apache.commons.vfs.FileSystemOptions;
>>>> -import org.apache.commons.vfs.provider.AbstractFileProvider;
>>>> -import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>>> -
>>>> -import org.ofbiz.base.location.FlexibleLocation;
>>>> -import org.ofbiz.base.util.UtilMisc;
>>>> -
>>>> -import org.webslinger.commons.vfs.VFSUtil;
>>>> -
>>>> -public class OfbizHomeProvider extends AbstractFileProvider {
>>>> - public Collection getCapabilities() {
>>>> - return DefaultLocalFileProvider.capabilities;
>>>> - }
>>>> -
>>>> - public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
>>>> - //new Exception("findFile(" + base + ", " + name + ")").printStackTrace();
>>>> - try {
>>>> - URL location = FlexibleLocation.resolveLocation("ofbizhome://.");
>>>> - FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
>>>> - return VFSUtil .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
>>>> ofbizBase.resolveFile(name.substring(13)).getURL().toString(), properties);
>>>> - } catch (Exception e) {
>>>> - throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
>>>> - }
>>>> - }
>>>> -}
>>>> +/ *******************************************************************************
>>>> + * 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.commons.vfs.ofbiz;
>>>> +
>>>> +import java.net.URL;
>>>> +import java.util.Collection;
>>>> +
>>>> +import org.apache.commons.vfs.FileObject;
>>>> +import org.apache.commons.vfs.FileSystemException;
>>>> +import org.apache.commons.vfs.FileSystemOptions;
>>>> +import org.apache.commons.vfs.provider.AbstractFileProvider;
>>>> +import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>>> +
>>>> +import org.ofbiz.base.location.FlexibleLocation;
>>>> +import org.ofbiz.base.util.UtilMisc;
>>>> +
>>>> +import org.webslinger.commons.vfs.VFSUtil;
>>>> +
>>>> +public class OfbizHomeProvider extends AbstractFileProvider {
>>>> + public Collection<?> getCapabilities() {
>>>> + return DefaultLocalFileProvider.capabilities;
>>>> + }
>>>> +
>>>> + public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
>>>> + //new Exception("findFile(" + base + ", " + name + ")").printStackTrace();
>>>> + try {
>>>> + URL location = FlexibleLocation.resolveLocation("ofbizhome://.");
>>>> + FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
>>>> + return VFSUtil .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
>>>> ofbizBase.resolveFile(name.substring(13)).getURL().toString(), properties);
>>>> + } catch (Exception e) {
>>>> + throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
>>>> + }
>>>> + }
>>>> +}
>>>>
>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/ webslinger/ EntityHttpUtil.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/EntityHttpUtil.java?rev=833727&r1=833726&r2=833727&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ EntityHttpUtil.java (original)
>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ EntityHttpUtil.java Sat Nov 7 18:18:33 2009
>>>> @@ -1,78 +1,73 @@
>>>> -/ *******************************************************************************
>>>> - * 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.webslinger;
>>>> -
>>>> -import java.util.HashMap;
>>>> -import java.util.Iterator;
>>>> -import java.util.Locale;
>>>> -import java.util.Map;
>>>> -
>>>> -import javax.servlet.ServletRequest;
>>>> -import javax.servlet.http.HttpServletRequest;
>>>> -
>>>> -import org.ofbiz.base.util.GeneralException;
>>>> -import org.ofbiz.base.util.ObjectType;
>>>> -import org.ofbiz.base.util.UtilHttp;
>>>> -import org.ofbiz.base.util.UtilMisc;
>>>> -import org.ofbiz.base.util.UtilValidate;
>>>> -import org.ofbiz.entity.Delegator;
>>>> -import org.ofbiz.entity.GenericValue;
>>>> -import org.ofbiz.entity.jdbc.SqlJdbcUtil;
>>>> -import org.ofbiz.entity.model.ModelEntity;
>>>> -import org.ofbiz.entity.model.ModelField;
>>>> -import org.ofbiz.entity.model.ModelFieldType;
>>>> -
>>>> -public class EntityHttpUtil {
>>>> - public static GenericValue makeValidValue(String entityName, ServletRequest request) throws GeneralException {
>>>> - return makeValidValue(entityName, false, request);
>>>> - }
>>>> -
>>>> - public static GenericValue makeValidValue(String entityName, boolean includePks, ServletRequest request) throws
>>>> GeneralException {
>>>> - if (request instanceof HttpServletRequest) return makeValidValue(entityName, includePks, (HttpServletRequest)
>>>> request);
>>>> - throw new IllegalArgumentException("Not an HttpServletRequest");
>>>> - }
>>>> -
>>>> - public static GenericValue makeValidValue(String entityName, HttpServletRequest request) throws GeneralException {
>>>> - return makeValidValue(entityName, false, request);
>>>> - }
>>>> -
>>>> - public static GenericValue makeValidValue(String entityName, boolean includePks, HttpServletRequest request) throws
>>>> GeneralException {
>>>> - Delegator delegator = (Delegator) request.getAttribute("delegator");
>>>> - GenericValue value = delegator.makeValue(entityName);
>>>> - ModelEntity model = value.getModelEntity();
>>>> - Iterator<ModelField> it = includePks ? model.getFieldsIterator() : model.getNopksIterator();
>>>> - Locale locale = UtilHttp.getLocale(request);
>>>> - while (it.hasNext()) {
>>>> - ModelField field = it.next();
>>>> - String fieldName = field.getName();
>>>> - String parameterValue = request.getParameter(fieldName);
>>>> - Object fieldValue;
>>>> - if (parameterValue == null) {
>>>> - fieldValue = null;
>>>> - } else {
>>>> - ModelFieldType fieldType = delegator.getEntityFieldType(model, field.getType());
>>>> - String wantedType = fieldType.getJavaType();
>>>> - fieldValue = ObjectType.simpleTypeConvert(parameterValue, wantedType, null, locale, true);
>>>> - }
>>>> - value.put(fieldName, fieldValue);
>>>> - }
>>>> - return value;
>>>> - }
>>>> -}
>>>> -
>>>> +/ *******************************************************************************
>>>> + * 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.webslinger;
>>>> +
>>>> +import java.util.Iterator;
>>>> +import java.util.Locale;
>>>> +
>>>> +import javax.servlet.ServletRequest;
>>>> +import javax.servlet.http.HttpServletRequest;
>>>> +
>>>> +import org.ofbiz.base.util.GeneralException;
>>>> +import org.ofbiz.base.util.ObjectType;
>>>> +import org.ofbiz.base.util.UtilHttp;
>>>> +import org.ofbiz.entity.Delegator;
>>>> +import org.ofbiz.entity.GenericValue;
>>>> +import org.ofbiz.entity.model.ModelEntity;
>>>> +import org.ofbiz.entity.model.ModelField;
>>>> +import org.ofbiz.entity.model.ModelFieldType;
>>>> +
>>>> +public class EntityHttpUtil {
>>>> + public static GenericValue makeValidValue(String entityName, ServletRequest request) throws GeneralException {
>>>> + return makeValidValue(entityName, false, request);
>>>> + }
>>>> +
>>>> + public static GenericValue makeValidValue(String entityName, boolean includePks, ServletRequest request) throws
>>>> GeneralException {
>>>> + if (request instanceof HttpServletRequest) return makeValidValue(entityName, includePks, (HttpServletRequest)
>>>> request);
>>>> + throw new IllegalArgumentException("Not an HttpServletRequest");
>>>> + }
>>>> +
>>>> + public static GenericValue makeValidValue(String entityName, HttpServletRequest request) throws GeneralException {
>>>> + return makeValidValue(entityName, false, request);
>>>> + }
>>>> +
>>>> + public static GenericValue makeValidValue(String entityName, boolean includePks, HttpServletRequest request) throws
>>>> GeneralException {
>>>> + Delegator delegator = (Delegator) request.getAttribute("delegator");
>>>> + GenericValue value = delegator.makeValue(entityName);
>>>> + ModelEntity model = value.getModelEntity();
>>>> + Iterator<ModelField> it = includePks ? model.getFieldsIterator() : model.getNopksIterator();
>>>> + Locale locale = UtilHttp.getLocale(request);
>>>> + while (it.hasNext()) {
>>>> + ModelField field = it.next();
>>>> + String fieldName = field.getName();
>>>> + String parameterValue = request.getParameter(fieldName);
>>>> + Object fieldValue;
>>>> + if (parameterValue == null) {
>>>> + fieldValue = null;
>>>> + } else {
>>>> + ModelFieldType fieldType = delegator.getEntityFieldType(model, field.getType());
>>>> + String wantedType = fieldType.getJavaType();
>>>> + fieldValue = ObjectType.simpleTypeConvert(parameterValue, wantedType, null, locale, true);
>>>> + }
>>>> + value.put(fieldName, fieldValue);
>>>> + }
>>>> + return value;
>>>> + }
>>>> +}
>>>> +
>>>>
>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/ webslinger/ StatsUpdater.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java?rev=833727&r1=833726&r2=833727&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ StatsUpdater.java (original)
>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ StatsUpdater.java Sat Nov 7 18:18:33 2009
>>>> @@ -1,121 +1,118 @@
>>>> -/ *******************************************************************************
>>>> - * 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.webslinger;
>>>> -
>>>> -import java.util.HashMap;
>>>> -import java.util.Iterator;
>>>> -import java.util.Map;
>>>> -import java.util.concurrent.Callable;
>>>> -import java.util.concurrent.ConcurrentHashMap;
>>>> -import java.util.concurrent.ScheduledFuture;
>>>> -import java.util.concurrent.TimeUnit;
>>>> -import java.util.concurrent.atomic.AtomicReference;
>>>> -
>>>> -import org.ofbiz.base.util.UtilMisc;
>>>> -import org.ofbiz.entity.Delegator;
>>>> -import org.ofbiz.entity.GenericEntityException;
>>>> -import org.ofbiz.entity.GenericPK;
>>>> -import org.ofbiz.entity.GenericValue;
>>>> -
>>>> -import org.webslinger.cache.ConcurrentCache;
>>>> -import org.webslinger.concurrent.ExecutionPool;
>>>> -
>>>> -public class StatsUpdater {
>>>> - private static final Updater UPDATER = new Updater();
>>>> -
>>>> - public static void updateStats(Delegator delegator, String entityName, Map<String, ? extends Object> keyFields,
>>>> Map<String, ? extends Long> updateCountFields) throws GenericEntityException {
>>>> - GenericPK pk = delegator.makePK(entityName, keyFields);
>>>> - Map<String, Long> value = UPDATER.getValue(pk);
>>>> - synchronized (value) {
>>>> - for (Map.Entry<String, ? extends Long> entry: updateCountFields.entrySet()) {
>>>> - Long oldValue = value.get(entry.getKey());
>>>> - if (oldValue != null) {
>>>> - value.put(entry.getKey(), Long.valueOf(oldValue.longValue() + entry.getValue()));
>>>> - } else {
>>>> - value.put(entry.getKey(), entry.getValue());
>>>> - }
>>>> - }
>>>> - }
>>>> - }
>>>> -
>>>> - private static final class Updater implements Callable<Void> {
>>>> - protected AtomicReference<EntityHolder> entities = new AtomicReference<EntityHolder>(new EntityHolder(Updater.class,
>>>> "entities", null));
>>>> - protected ScheduledFuture<Void> future;
>>>> -
>>>> - protected Map<String, Long> getValue(GenericPK pk) throws GenericEntityException {
>>>> - synchronized (this) {
>>>> - if (future == null || future.isDone()) {
>>>> - future = ExecutionPool.schedule(this, 1, TimeUnit.SECONDS);
>>>> - }
>>>> - }
>>>> - try {
>>>> - return entities.get().get(pk);
>>>> - } catch (RuntimeException e) {
>>>> - throw e;
>>>> - } catch (GenericEntityException e) {
>>>> - throw e;
>>>> - } catch (Exception e) {
>>>> - throw UtilMisc.initCause(new GenericEntityException(e.getMessage()), e);
>>>> - }
>>>> - }
>>>> -
>>>> - public Void call() {
>>>> - EntityHolder oldEntities;
>>>> - EntityHolder newEntities = new EntityHolder(Updater.class, "entities", null);
>>>> - do {
>>>> - oldEntities = entities.get();
>>>> - } while (!entities.compareAndSet(oldEntities, newEntities));
>>>> - synchronized (Updater.class) {
>>>> - for (GenericPK pk: oldEntities.keys()) {
>>>> - try {
>>>> - Map<String, Long> add = oldEntities.get(pk);
>>>> - GenericValue existing = pk.getDelegator().findOne(pk.getEntityName(), pk, false);
>>>> - if (existing == null) {
>>>> - existing = pk.getDelegator().create(pk.getEntityName(), pk);
>>>> - }
>>>> - for (Map.Entry<String, Long> entry: add.entrySet()) {
>>>> - Long value = entry.getValue();
>>>> - Long oldValue = existing.getLong(entry.getKey());
>>>> - if (oldValue != null) {
>>>> - existing.put(entry.getKey(), Long.valueOf(value.longValue() + oldValue.longValue()));
>>>> - } else {
>>>> - existing.put(entry.getKey(), value);
>>>> - }
>>>> - }
>>>> - existing.store();
>>>> - } catch (Exception e) {
>>>> - e.printStackTrace();
>>>> - }
>>>> - }
>>>> - }
>>>> - return null;
>>>> - }
>>>> - }
>>>> -
>>>> - private static final class EntityHolder extends ConcurrentCache<GenericPK, Map<String, Long>> {
>>>> - protected EntityHolder(Class<?> owner, String field, String label) {
>>>> - super(owner, field, label, HARD);
>>>> - }
>>>> -
>>>> - @Override
>>>> - protected Map<String, Long> createValue(GenericPK pk) throws Exception {
>>>> - return new HashMap<String, Long>();
>>>> - }
>>>> - }
>>>> -}
>>>> +/ *******************************************************************************
>>>> + * 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.webslinger;
>>>> +
>>>> +import java.util.HashMap;
>>>> +import java.util.Map;
>>>> +import java.util.concurrent.Callable;
>>>> +import java.util.concurrent.ScheduledFuture;
>>>> +import java.util.concurrent.TimeUnit;
>>>> +import java.util.concurrent.atomic.AtomicReference;
>>>> +
>>>> +import org.ofbiz.base.util.UtilMisc;
>>>> +import org.ofbiz.entity.Delegator;
>>>> +import org.ofbiz.entity.GenericEntityException;
>>>> +import org.ofbiz.entity.GenericPK;
>>>> +import org.ofbiz.entity.GenericValue;
>>>> +import org.webslinger.cache.ConcurrentCache;
>>>> +import org.webslinger.concurrent.ExecutionPool;
>>>> +
>>>> +public class StatsUpdater {
>>>> + private static final Updater UPDATER = new Updater();
>>>> +
>>>> + public static void updateStats(Delegator delegator, String entityName, Map<String, ? extends Object> keyFields,
>>>> Map<String, ? extends Long> updateCountFields) throws GenericEntityException {
>>>> + GenericPK pk = delegator.makePK(entityName, keyFields);
>>>> + Map<String, Long> value = UPDATER.getValue(pk);
>>>> + synchronized (value) {
>>>> + for (Map.Entry<String, ? extends Long> entry: updateCountFields.entrySet()) {
>>>> + Long oldValue = value.get(entry.getKey());
>>>> + if (oldValue != null) {
>>>> + value.put(entry.getKey(), Long.valueOf(oldValue.longValue() + entry.getValue()));
>>>> + } else {
>>>> + value.put(entry.getKey(), entry.getValue());
>>>> + }
>>>> + }
>>>> + }
>>>> + }
>>>> +
>>>> + private static final class Updater implements Callable<Void> {
>>>> + protected AtomicReference<EntityHolder> entities = new AtomicReference<EntityHolder>(new EntityHolder(Updater.class,
>>>> "entities", null));
>>>> + protected ScheduledFuture<Void> future;
>>>> +
>>>> + protected Map<String, Long> getValue(GenericPK pk) throws GenericEntityException {
>>>> + synchronized (this) {
>>>> + if (future == null || future.isDone()) {
>>>> + future = ExecutionPool.schedule(this, 1, TimeUnit.SECONDS);
>>>> + }
>>>> + }
>>>> + try {
>>>> + return entities.get().get(pk);
>>>> + } catch (RuntimeException e) {
>>>> + throw e;
>>>> + } catch (GenericEntityException e) {
>>>> + throw e;
>>>> + } catch (Exception e) {
>>>> + throw UtilMisc.initCause(new GenericEntityException(e.getMessage()), e);
>>>> + }
>>>> + }
>>>> +
>>>> + public Void call() {
>>>> + EntityHolder oldEntities;
>>>> + EntityHolder newEntities = new EntityHolder(Updater.class, "entities", null);
>>>> + do {
>>>> + oldEntities = entities.get();
>>>> + } while (!entities.compareAndSet(oldEntities, newEntities));
>>>> + synchronized (Updater.class) {
>>>> + for (GenericPK pk: oldEntities.keys()) {
>>>> + try {
>>>> + Map<String, Long> add = oldEntities.get(pk);
>>>> + GenericValue existing = pk.getDelegator().findOne(pk.getEntityName(), pk, false);
>>>> + if (existing == null) {
>>>> + existing = pk.getDelegator().create(pk.getEntityName(), pk);
>>>> + }
>>>> + for (Map.Entry<String, Long> entry: add.entrySet()) {
>>>> + Long value = entry.getValue();
>>>> + Long oldValue = existing.getLong(entry.getKey());
>>>> + if (oldValue != null) {
>>>> + existing.put(entry.getKey(), Long.valueOf(value.longValue() + oldValue.longValue()));
>>>> + } else {
>>>> + existing.put(entry.getKey(), value);
>>>> + }
>>>> + }
>>>> + existing.store();
>>>> + } catch (Exception e) {
>>>> + e.printStackTrace();
>>>> + }
>>>> + }
>>>> + }
>>>> + return null;
>>>> + }
>>>> + }
>>>> +
>>>> + private static final class EntityHolder extends ConcurrentCache<GenericPK, Map<String, Long>> {
>>>> + protected EntityHolder(Class<?> owner, String field, String label) {
>>>> + super(owner, field, label, HARD);
>>>> + }
>>>> +
>>>> + @Override
>>>> + protected Map<String, Long> createValue(GenericPK pk) throws Exception {
>>>> + return new HashMap<String, Long>();
>>>> + }
>>>> + }
>>>> +}
>>>>
>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/ webslinger/ WebslingerContextMapper.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java?rev=833727&r1=833726&r2=833727&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerContextMapper.java (original)
>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerContextMapper.java Sat Nov 7 18:18:33 2009
>>>> @@ -1,218 +1,216 @@
>>>> -/ *******************************************************************************
>>>> - * 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.webslinger;
>>>> -
>>>> -import java.io.IOException;
>>>> -import java.net.URL;
>>>> -import java.util.ArrayList;
>>>> -import java.util.Arrays;
>>>> -import java.util.HashSet;
>>>> -import java.util.List;
>>>> -import java.util.Set;
>>>> -
>>>> -import javax.servlet.ServletConfig;
>>>> -import javax.servlet.ServletContext;
>>>> -import javax.servlet.ServletException;
>>>> -import javax.servlet.http.HttpServletRequest;
>>>> -
>>>> -import org.ofbiz.base.util.UtilMisc;
>>>> -import org.ofbiz.base.util.UtilProperties;
>>>> -import org.ofbiz.entity.Delegator;
>>>> -import org.ofbiz.entity.DelegatorFactory;
>>>> -import org.ofbiz.entity.GenericEntityException;
>>>> -import org.ofbiz.entity.GenericValue;
>>>> -import org.ofbiz.entity.cache.Cache;
>>>> -import org.ofbiz.entity.util.EntityUtil;
>>>> -import org.ofbiz.security.SecurityFactory;
>>>> -import org.ofbiz.security.authz.AuthorizationFactory;
>>>> -import org.ofbiz.service.GenericDispatcher;
>>>> -import org.ofbiz.service.LocalDispatcher;
>>>> -import org.ofbiz.service.ServiceDispatcher;
>>>> -import org.ofbiz.service.DispatchContext;
>>>> -
>>>> -import org.webslinger.AbstractMappingWebslingerServletContextFactory;
>>>> -import org.webslinger.WebslingerServletContext;
>>>> -import org.webslinger.collections.CollectionUtil;
>>>> -import org.webslinger.lang.ObjectUtil;
>>>> -
>>>> -public class WebslingerContextMapper extends AbstractMappingWebslingerServletContextFactory {
>>>> - protected ServletContext servletContext;
>>>> - protected Delegator delegator;
>>>> - protected final ArrayList<URL> globalReaderURLs = new ArrayList<URL>();
>>>> -
>>>> - public void init(ServletConfig config) throws ServletException, IOException {
>>>> - System .err .println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
>>>> - servletContext = config.getServletContext();
>>>> - String delegatorName = servletContext.getInitParameter("entityDelegatorName");
>>>> - delegator = DelegatorFactory.getDelegator(delegatorName);
>>>> - String readerFiles = servletContext.getInitParameter("serviceReaderUrls");
>>>> - if (readerFiles != null) {
>>>> - for (String reader: CollectionUtil.split(readerFiles, ";")) {
>>>> - URL url = config.getServletContext().getResource(reader);
>>>> - if (url != null) globalReaderURLs.add(url);
>>>> - }
>>>> - }
>>>> - super.init(config, UtilProperties.getPropertyValue("webslinger.properties", "moduleBase"));
>>>> - }
>>>> -
>>>> - @Override
>>>> - protected Layout[] getStartLayouts() throws Exception {
>>>> - ArrayList<Layout> layouts = new ArrayList<Layout>();
>>>> - try {
>>>> - for (GenericValue value: delegator.findByAnd("WebslingerServer", UtilMisc.toMap("loadAtStart", "Y"))) {
>>>> - layouts.add(new OfbizLayout(value));
>>>> - }
>>>> - } catch (GenericEntityException e) {
>>>> - }
>>>> - return layouts.toArray(new Layout[layouts.size()]);
>>>> - }
>>>> -
>>>> - @Override
>>>> - public void initializeRequest(WebslingerServletContext context, HttpServletRequest request) {
>>>> - request.setAttribute("servletContext", context);
>>>> - Object delegator = context.getAttribute("delegator");
>>>> - Object dispatcher = context.getAttribute("dispatcher");
>>>> - Object authz = context.getAttribute("authz");
>>>> - Object security = context.getAttribute("security");
>>>> - request.setAttribute("delegator", delegator);
>>>> - request.setAttribute("dispatcher", dispatcher);
>>>> - request.setAttribute("authz", authz);
>>>> - request.setAttribute("security", security);
>>>> - // FIXME!!! These next two are a hack until proper fake/ wrapped session support is done in webslinger
>>>> - servletContext.setAttribute("delegator", delegator);
>>>> - servletContext.setAttribute("dispatcher", dispatcher);
>>>> - servletContext.setAttribute("authz", authz);
>>>> - servletContext.setAttribute("security", security);
>>>> - }
>>>> -
>>>> - @Override
>>>> - protected void initializeContext(WebslingerServletContext context, Layout layout) throws Exception {
>>>> - OfbizLayout ofbizLayout = (OfbizLayout) layout;
>>>> - Delegator delegator = null;
>>>> - delegator = DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
>>>> - context.setAttribute("delegator", delegator);
>>>> - context.setAttribute("dispatcher", new WebslingerGenericDispatcher(context, layout.getTarget(), delegator,
>>>> globalReaderURLs));
>>>> - context.setAttribute("authz", AuthorizationFactory.getInstance(delegator));
>>>> - context.setAttribute("security", SecurityFactory.getInstance(delegator));
>>>> - }
>>>> -
>>>> - protected static final class WebslingerGenericDispatcher extends GenericDispatcher {
>>>> - protected WebslingerGenericDispatcher(WebslingerServletContext context, String name, Delegator delegator,
>>>> List<URL> globalReaderURLs) throws IOException {
>>>> - ArrayList<URL> readerURLs = new ArrayList<URL>(globalReaderURLs);
>>>> - String readerFiles = context.getInitParameter("serviceReaderUrls");
>>>> - if (readerFiles != null) {
>>>> - for (String reader: CollectionUtil.split(readerFiles, ";")) {
>>>> - URL url = context.getResource(reader);
>>>> - if (url != null) readerURLs.add(url);
>>>> - }
>>>> - }
>>>> - System.err.println(readerURLs);
>>>> - this.dispatcher = new ServiceDispatcher(delegator, true, true, true) {
>>>> - };
>>>> - ClassLoader loader = null;
>>>> - try {
>>>> - loader = Thread.currentThread().getContextClassLoader();
>>>> - } catch (SecurityException e) {
>>>> - loader = WebslingerContextMapper.class.getClassLoader();
>>>> - }
>>>> - DispatchContext dc = new DispatchContext(name, readerURLs, loader, null);
>>>> - init(name, delegator, dc);
>>>> - }
>>>> - }
>>>> -
>>>> - @Override
>>>> - protected Set<String> getSuffixes() throws Exception {
>>>> - Cache cache = delegator.getCache();
>>>> - Set<String> suffixes;
>>>> - synchronized (WebslingerContextMapper.class) {
>>>> - suffixes = cache.get("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes");
>>>> - if (suffixes == null) {
>>>> - suffixes = new HashSet<String>();
>>>> - for (GenericValue value: delegator.findList("WebslingerHostSuffix", null, null, null, null, false)) {
>>>> - suffixes.add(value.getString("hostSuffix"));
>>>> - }
>>>> - cache.put("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes", suffixes);
>>>> - }
>>>> - }
>>>> - return suffixes;
>>>> - }
>>>> -
>>>> - @Override
>>>> - protected Layout lookupLayout(String hostName, String contextPath) throws Exception {
>>>> - GenericValue layout = EntityUtil.getOnly(delegator.findByAndCache("WebslingerLayout", UtilMisc.toMap("hostName",
>>>> hostName, "contextPath", contextPath)));
>>>> - if (layout == null) return null;
>>>> - return new OfbizLayout(layout);
>>>> - }
>>>> -
>>>> - protected class OfbizLayout implements Layout {
>>>> - private final String contextPath;
>>>> - private final String id;
>>>> - private final String target;
>>>> - private final String[] bases;
>>>> - private final int hashCode;
>>>> - protected final String delegatorName;
>>>> - protected final String dispatcherName;
>>>> -
>>>> - protected OfbizLayout(GenericValue server) throws GenericEntityException {
>>>> - contextPath = server.getString("contextPath");
>>>> - id = server.getString("webslingerServerId");
>>>> - target = server.getString("target");
>>>> - List<GenericValue> baseValues = server.getRelatedCache("WebslingerServerBase", UtilMisc.toList("seqNum"));
>>>> - bases = new String[baseValues.size()];
>>>> - for (int i = 0; i < bases.length; i++) {
>>>> - GenericValue baseValue = baseValues.get(i);
>>>> - bases[i] = baseValue.getString("baseName");
>>>> - }
>>>> - delegatorName = server.getString("delegatorName");
>>>> - dispatcherName = server.getString("dispatcherName");
>>>> - hashCode = target.hashCode() ^ ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
>>>> - }
>>>> -
>>>> - public String getContextPath() {
>>>> - return contextPath;
>>>> - }
>>>> -
>>>> - public String getId() {
>>>> - return id;
>>>> - }
>>>> -
>>>> - public String getTarget() {
>>>> - return target;
>>>> - }
>>>> -
>>>> - public String[] getBases() {
>>>> - return bases;
>>>> - }
>>>> -
>>>> - @Override
>>>> - public int hashCode() {
>>>> - return hashCode;
>>>> - }
>>>> -
>>>> - @Override
>>>> - public boolean equals(Object o) {
>>>> - if (!(o instanceof OfbizLayout)) return false;
>>>> - OfbizLayout other = (OfbizLayout) o;
>>>> - if (!contextPath.equals(other.contextPath)) return false;
>>>> - if (!target.equals(other.target)) return false;
>>>> - if (!ObjectUtil.equalsHelper(delegatorName, other.delegatorName)) return false;
>>>> - return Arrays.equals(bases, other.bases);
>>>> - }
>>>> - }
>>>> -}
>>>> +/ *******************************************************************************
>>>> + * 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.webslinger;
>>>> +
>>>> +import java.io.IOException;
>>>> +import java.net.URL;
>>>> +import java.util.ArrayList;
>>>> +import java.util.Arrays;
>>>> +import java.util.HashSet;
>>>> +import java.util.List;
>>>> +import java.util.Set;
>>>> +
>>>> +import javax.servlet.ServletConfig;
>>>> +import javax.servlet.ServletContext;
>>>> +import javax.servlet.ServletException;
>>>> +import javax.servlet.http.HttpServletRequest;
>>>> +
>>>> +import org.ofbiz.base.util.UtilMisc;
>>>> +import org.ofbiz.base.util.UtilProperties;
>>>> +import org.ofbiz.entity.Delegator;
>>>> +import org.ofbiz.entity.DelegatorFactory;
>>>> +import org.ofbiz.entity.GenericEntityException;
>>>> +import org.ofbiz.entity.GenericValue;
>>>> +import org.ofbiz.entity.cache.Cache;
>>>> +import org.ofbiz.entity.util.EntityUtil;
>>>> +import org.ofbiz.security.SecurityFactory;
>>>> +import org.ofbiz.security.authz.AuthorizationFactory;
>>>> +import org.ofbiz.service.DispatchContext;
>>>> +import org.ofbiz.service.GenericDispatcher;
>>>> +import org.ofbiz.service.ServiceDispatcher;
>>>> +import org.webslinger.AbstractMappingWebslingerServletContextFactory;
>>>> +import org.webslinger.WebslingerServletContext;
>>>> +import org.webslinger.collections.CollectionUtil;
>>>> +import org.webslinger.lang.ObjectUtil;
>>>> +
>>>> +public class WebslingerContextMapper extends AbstractMappingWebslingerServletContextFactory {
>>>> + protected ServletContext servletContext;
>>>> + protected Delegator delegator;
>>>> + protected final ArrayList<URL> globalReaderURLs = new ArrayList<URL>();
>>>> +
>>>> + public void init(ServletConfig config) throws ServletException, IOException {
>>>> + System .err .println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
>>>> + servletContext = config.getServletContext();
>>>> + String delegatorName = servletContext.getInitParameter("entityDelegatorName");
>>>> + delegator = DelegatorFactory.getDelegator(delegatorName);
>>>> + String readerFiles = servletContext.getInitParameter("serviceReaderUrls");
>>>> + if (readerFiles != null) {
>>>> + for (String reader: CollectionUtil.split(readerFiles, ";")) {
>>>> + URL url = config.getServletContext().getResource(reader);
>>>> + if (url != null) globalReaderURLs.add(url);
>>>> + }
>>>> + }
>>>> + super.init(config, UtilProperties.getPropertyValue("webslinger.properties", "moduleBase"));
>>>> + }
>>>> +
>>>> + @Override
>>>> + protected Layout[] getStartLayouts() throws Exception {
>>>> + ArrayList<Layout> layouts = new ArrayList<Layout>();
>>>> + try {
>>>> + for (GenericValue value: delegator.findByAnd("WebslingerServer", UtilMisc.toMap("loadAtStart", "Y"))) {
>>>> + layouts.add(new OfbizLayout(value));
>>>> + }
>>>> + } catch (GenericEntityException e) {
>>>> + }
>>>> + return layouts.toArray(new Layout[layouts.size()]);
>>>> + }
>>>> +
>>>> + @Override
>>>> + public void initializeRequest(WebslingerServletContext context, HttpServletRequest request) {
>>>> + request.setAttribute("servletContext", context);
>>>> + Object delegator = context.getAttribute("delegator");
>>>> + Object dispatcher = context.getAttribute("dispatcher");
>>>> + Object authz = context.getAttribute("authz");
>>>> + Object security = context.getAttribute("security");
>>>> + request.setAttribute("delegator", delegator);
>>>> + request.setAttribute("dispatcher", dispatcher);
>>>> + request.setAttribute("authz", authz);
>>>> + request.setAttribute("security", security);
>>>> + // FIXME!!! These next two are a hack until proper fake/ wrapped session support is done in webslinger
>>>> + servletContext.setAttribute("delegator", delegator);
>>>> + servletContext.setAttribute("dispatcher", dispatcher);
>>>> + servletContext.setAttribute("authz", authz);
>>>> + servletContext.setAttribute("security", security);
>>>> + }
>>>> +
>>>> + @Override
>>>> + protected void initializeContext(WebslingerServletContext context, Layout layout) throws Exception {
>>>> + OfbizLayout ofbizLayout = (OfbizLayout) layout;
>>>> + Delegator delegator = null;
>>>> + delegator = DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
>>>> + context.setAttribute("delegator", delegator);
>>>> + context.setAttribute("dispatcher", new WebslingerGenericDispatcher(context, layout.getTarget(), delegator,
>>>> globalReaderURLs));
>>>> + context.setAttribute("authz", AuthorizationFactory.getInstance(delegator));
>>>> + context.setAttribute("security", SecurityFactory.getInstance(delegator));
>>>> + }
>>>> +
>>>> + protected static final class WebslingerGenericDispatcher extends GenericDispatcher {
>>>> + protected WebslingerGenericDispatcher(WebslingerServletContext context, String name, Delegator delegator,
>>>> List<URL> globalReaderURLs) throws IOException {
>>>> + ArrayList<URL> readerURLs = new ArrayList<URL>(globalReaderURLs);
>>>> + String readerFiles = context.getInitParameter("serviceReaderUrls");
>>>> + if (readerFiles != null) {
>>>> + for (String reader: CollectionUtil.split(readerFiles, ";")) {
>>>> + URL url = context.getResource(reader);
>>>> + if (url != null) readerURLs.add(url);
>>>> + }
>>>> + }
>>>> + System.err.println(readerURLs);
>>>> + this.dispatcher = new ServiceDispatcher(delegator, true, true, true) {
>>>> + };
>>>> + ClassLoader loader = null;
>>>> + try {
>>>> + loader = Thread.currentThread().getContextClassLoader();
>>>> + } catch (SecurityException e) {
>>>> + loader = WebslingerContextMapper.class.getClassLoader();
>>>> + }
>>>> + DispatchContext dc = new DispatchContext(name, readerURLs, loader, null);
>>>> + init(name, delegator, dc);
>>>> + }
>>>> + }
>>>> +
>>>> + @Override
>>>> + protected Set<String> getSuffixes() throws Exception {
>>>> + Cache cache = delegator.getCache();
>>>> + Set<String> suffixes;
>>>> + synchronized (WebslingerContextMapper.class) {
>>>> + suffixes = cache.get("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes");
>>>> + if (suffixes == null) {
>>>> + suffixes = new HashSet<String>();
>>>> + for (GenericValue value: delegator.findList("WebslingerHostSuffix", null, null, null, null, false)) {
>>>> + suffixes.add(value.getString("hostSuffix"));
>>>> + }
>>>> + cache.put("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes", suffixes);
>>>> + }
>>>> + }
>>>> + return suffixes;
>>>> + }
>>>> +
>>>> + @Override
>>>> + protected Layout lookupLayout(String hostName, String contextPath) throws Exception {
>>>> + GenericValue layout = EntityUtil.getOnly(delegator.findByAndCache("WebslingerLayout", UtilMisc.toMap("hostName",
>>>> hostName, "contextPath", contextPath)));
>>>> + if (layout == null) return null;
>>>> + return new OfbizLayout(layout);
>>>> + }
>>>> +
>>>> + protected class OfbizLayout implements Layout {
>>>> + private final String contextPath;
>>>> + private final String id;
>>>> + private final String target;
>>>> + private final String[] bases;
>>>> + private final int hashCode;
>>>> + protected final String delegatorName;
>>>> + protected final String dispatcherName;
>>>> +
>>>> + protected OfbizLayout(GenericValue server) throws GenericEntityException {
>>>> + contextPath = server.getString("contextPath");
>>>> + id = server.getString("webslingerServerId");
>>>> + target = server.getString("target");
>>>> + List<GenericValue> baseValues = server.getRelatedCache("WebslingerServerBase", UtilMisc.toList("seqNum"));
>>>> + bases = new String[baseValues.size()];
>>>> + for (int i = 0; i < bases.length; i++) {
>>>> + GenericValue baseValue = baseValues.get(i);
>>>> + bases[i] = baseValue.getString("baseName");
>>>> + }
>>>> + delegatorName = server.getString("delegatorName");
>>>> + dispatcherName = server.getString("dispatcherName");
>>>> + hashCode = target.hashCode() ^ ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
>>>> + }
>>>> +
>>>> + public String getContextPath() {
>>>> + return contextPath;
>>>> + }
>>>> +
>>>> + public String getId() {
>>>> + return id;
>>>> + }
>>>> +
>>>> + public String getTarget() {
>>>> + return target;
>>>> + }
>>>> +
>>>> + public String[] getBases() {
>>>> + return bases;
>>>> + }
>>>> +
>>>> + @Override
>>>> + public int hashCode() {
>>>> + return hashCode;
>>>> + }
>>>> +
>>>> + @Override
>>>> + public boolean equals(Object o) {
>>>> + if (!(o instanceof OfbizLayout)) return false;
>>>> + OfbizLayout other = (OfbizLayout) o;
>>>> + if (!contextPath.equals(other.contextPath)) return false;
>>>> + if (!target.equals(other.target)) return false;
>>>> + if (!ObjectUtil.equalsHelper(delegatorName, other.delegatorName)) return false;
>>>> + return Arrays.equals(bases, other.bases);
>>>> + }
>>>> + }
>>>> +}
>>>>
>>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/ webslinger/ WebslingerServerEngine.java
>>>> URL:
>>>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java?rev=833727&r1=833726&r2=833727&view=diff
>>>> = = = = = = = = = = ====================================================================
>>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerServerEngine.java (original)
>>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerServerEngine.java Sat Nov 7 18:18:33 2009
>>>> @@ -1,64 +1,59 @@
>>>> -/ *******************************************************************************
>>>> - * 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.webslinger;
>>>> -
>>>> -import java.io.IOException;
>>>> -import java.io.StringReader;
>>>> -import java.io.StringWriter;
>>>> -import java.util.Collections;
>>>> -import java.util.Map;
>>>> -
>>>> -import org.ofbiz.base.util.UtilGenerics;
>>>> -import org.ofbiz.base.util.UtilMisc;
>>>> -import org.ofbiz.entity.Delegator;
>>>> -import org.ofbiz.entity.GenericValue;
>>>> -import org.ofbiz.entity.util.EntityUtil;
>>>> -import org.ofbiz.service.GenericServiceException;
>>>> -import org.ofbiz.service.ModelService;
>>>> -import org.ofbiz.service.ServiceDispatcher;
>>>> -import org.ofbiz.service.engine.GenericAsyncEngine;
>>>> -
>>>> -import org.webslinger.WebslingerServletContext;
>>>> -
>>>> -public class WebslingerServerEngine extends GenericAsyncEngine {
>>>> - public WebslingerServerEngine(ServiceDispatcher dispatcher) {
>>>> - super(dispatcher);
>>>> - }
>>>> -
>>>> - @Override
>>>> - public void runSyncIgnore(String localName, ModelService modelService, Map<String, Object> context) throws
>>>> GenericServiceException {
>>>> - runSync(localName, modelService, context);
>>>> - }
>>>> -
>>>> - @Override
>>>> - public Map<String, Object> runSync(String localName, ModelService modelService, Map<String, Object> context) throws
>>>> GenericServiceException {
>>>> - Delegator delegator = dispatcher.getDelegator();
>>>> - try {
>>>> - GenericValue found = EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout",
>>>> UtilMisc.toMap("webslingerServerId", modelService.location)));
>>>> - if (found == null) throw new GenericServiceException("Couldn't find server mapping for(" +
>>>> modelService.location + ")");
>>>> - return UtilGenerics .checkMap (WebslingerServletContext.invokeInVM(found.getString("hostName"), 8080,
>>>> modelService.invoke, context));
>>>> - } catch (RuntimeException e) {
>>>> - throw e;
>>>> - } catch (GenericServiceException e) {
>>>> - throw e;
>>>> - } catch (Exception e) {
>>>> - throw UtilMisc.initCause(new GenericServiceException(e.getMessage()), e);
>>>> - }
>>>> - }
>>>> -}
>>>> +/ *******************************************************************************
>>>> + * 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.webslinger;
>>>> +
>>>> +import java.util.Map;
>>>> +
>>>> +import org.ofbiz.base.util.UtilGenerics;
>>>> +import org.ofbiz.base.util.UtilMisc;
>>>> +import org.ofbiz.entity.Delegator;
>>>> +import org.ofbiz.entity.GenericValue;
>>>> +import org.ofbiz.entity.util.EntityUtil;
>>>> +import org.ofbiz.service.GenericServiceException;
>>>> +import org.ofbiz.service.ModelService;
>>>> +import org.ofbiz.service.ServiceDispatcher;
>>>> +import org.ofbiz.service.engine.GenericAsyncEngine;
>>>> +import org.webslinger.WebslingerServletContext;
>>>> +
>>>> +public class WebslingerServerEngine extends GenericAsyncEngine {
>>>> + public WebslingerServerEngine(ServiceDispatcher dispatcher) {
>>>> + super(dispatcher);
>>>> + }
>>>> +
>>>> + @Override
>>>> + public void runSyncIgnore(String localName, ModelService modelService, Map<String, Object> context) throws
>>>> GenericServiceException {
>>>> + runSync(localName, modelService, context);
>>>> + }
>>>> +
>>>> + @Override
>>>> + public Map<String, Object> runSync(String localName, ModelService modelService, Map<String, Object> context) throws
>>>> GenericServiceException {
>>>> + Delegator delegator = dispatcher.getDelegator();
>>>> + try {
>>>> + GenericValue found = EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout",
>>>> UtilMisc.toMap("webslingerServerId", modelService.location)));
>>>> + if (found == null) throw new GenericServiceException("Couldn't find server mapping for(" +
>>>> modelService.location + ")");
>>>> + return UtilGenerics .checkMap (WebslingerServletContext.invokeInVM(found.getString("hostName"), 8080,
>>>> modelService.invoke, context));
>>>> + } catch (RuntimeException e) {
>>>> + throw e;
>>>> + } catch (GenericServiceException e) {
>>>> + throw e;
>>>> + } catch (Exception e) {
>>>> + throw UtilMisc.initCause(new GenericServiceException(e.getMessage()), e);
>>>> + }
>>>> + }
>>>> +}
>>>>
>>>>
>>>
>>
>>
>
>
Re: svn commit: r833727 - in /ofbiz/trunk/framework/webslinger/src/org/ofbiz: commons/vfs/ commons/vfs/ofbiz/ webslinger/
Posted by Scott Gray <sc...@hotwaxmedia.com>.
Hi Jacques,
I think the problem is related to files in svn that do not have any
svn properties set (specifically eol-style), I just came across this
myself in r833931 and r833933. When I initially applied the patch the
entire file changed but after setting the svn properties the issue
went away.
Regards
Scott
On 9/11/2009, at 11:32 AM, Jacques Le Roux wrote:
> Sorry Scott,
>
> I have still not got the reflex... As I have not touched the patch
> (ok you have to trust me) you may review the patch itself...
>
> Jacques
>
> From: "Scott Gray" <sc...@hotwaxmedia.com>
>> Hi Jacques,
>>
>> This is that same problem with the patch again, please keep an eye
>> out for these as the commits are impossible to review.
>>
>> Thanks
>> Scott
>>
>> HotWax Media
>> http://www.hotwaxmedia.com
>>
>> On 8/11/2009, at 7:18 AM, jleroux@apache.org wrote:
>>
>>> Author: jleroux
>>> Date: Sat Nov 7 18:18:33 2009
>>> New Revision: 833727
>>>
>>> URL: http://svn.apache.org/viewvc?rev=833727&view=rev
>>> Log:
>>> A patch from Marc Morin "Resolve java warnings exposed in
>>> Eclipse : framework - webslinger" (https://issues.apache.org/jira/browse/OFBIZ-3121
>>> ) - OFBIZ-3121
>>>
>>> Modified:
>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>> CommonsVfsContainer.java
>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>> ofbiz/ OfbizComponentProvider.java
>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>> ofbiz/ OfbizHomeProvider.java
>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>> EntityHttpUtil.java
>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>> StatsUpdater.java
>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>> WebslingerContextMapper.java
>>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>> WebslingerServerEngine.java
>>>
>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/
>>> vfs/ CommonsVfsContainer.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java?rev=833727&r1=833726&r2=833727&view=diff
>>> = = = = = = = =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>> CommonsVfsContainer.java (original)
>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>> CommonsVfsContainer.java Sat Nov 7 18:18:33 2009
>>> @@ -1,68 +1,66 @@
>>> -/
>>> *******************************************************************************
>>> - * 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.commons.vfs;
>>> -
>>> -import java.io.File;
>>> -import java.io.IOException;
>>> -import java.net.MalformedURLException;
>>> -
>>> -import org.apache.commons.vfs.CacheStrategy;
>>> -import org.apache.commons.vfs.FileObject;
>>> -import org.apache.commons.vfs.FileSystemException;
>>> -import org.apache.commons.vfs.FileSystemManager;
>>> -import org.apache.commons.vfs.impl.StandardFileSystemManager;
>>> -
>>> -import org.ofbiz.base.container.Container;
>>> -import org.ofbiz.base.container.ContainerException;
>>> -import org.ofbiz.base.util.UtilMisc;
>>> -import org.webslinger.commons.vfs.VFSUtil;
>>> -
>>> -public class CommonsVfsContainer implements Container {
>>> - private static StandardFileSystemManager sfsm;
>>> -
>>> - public void init(String[] args, String configFile) throws
>>> ContainerException {
>>> - }
>>> -
>>> - public boolean start() throws ContainerException {
>>> - try {
>>> - StandardFileSystemManager sfsm =
>>> VFSUtil.createStandardFileSystemManager();
>>> - FileObject currentDir = sfsm.resolveFile(new
>>> File(".").toURI().toURL().toString());
>>> - sfsm.setBaseFile(currentDir);
>>> - CommonsVfsContainer.sfsm = sfsm;
>>> - } catch (FileSystemException e) {
>>> - throw UtilMisc.initCause(new
>>> ContainerException("Initializing StandardFileSystemManager"), e);
>>> - } catch (MalformedURLException e) {
>>> - throw UtilMisc.initCause(new
>>> ContainerException("Initializing StandardFileSystemManager"), e);
>>> - }
>>> - return true;
>>> - }
>>> -
>>> - public void stop() throws ContainerException {
>>> - sfsm.close();
>>> - sfsm = null;
>>> - }
>>> -
>>> - public static FileObject resolveFile(String uri) throws
>>> IOException {
>>> - return sfsm.resolveFile(uri);
>>> - }
>>> -
>>> - public static FileSystemManager getFileSystemManager() {
>>> - return sfsm;
>>> - }
>>> -}
>>> +/
>>> *******************************************************************************
>>> + * 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.commons.vfs;
>>> +
>>> +import java.io.File;
>>> +import java.io.IOException;
>>> +import java.net.MalformedURLException;
>>> +
>>> +import org.apache.commons.vfs.FileObject;
>>> +import org.apache.commons.vfs.FileSystemException;
>>> +import org.apache.commons.vfs.FileSystemManager;
>>> +import org.apache.commons.vfs.impl.StandardFileSystemManager;
>>> +import org.ofbiz.base.container.Container;
>>> +import org.ofbiz.base.container.ContainerException;
>>> +import org.ofbiz.base.util.UtilMisc;
>>> +import org.webslinger.commons.vfs.VFSUtil;
>>> +
>>> +public class CommonsVfsContainer implements Container {
>>> + private static StandardFileSystemManager sfsm;
>>> +
>>> + public void init(String[] args, String configFile) throws
>>> ContainerException {
>>> + }
>>> +
>>> + public boolean start() throws ContainerException {
>>> + try {
>>> + StandardFileSystemManager sfsm =
>>> VFSUtil.createStandardFileSystemManager();
>>> + FileObject currentDir = sfsm.resolveFile(new
>>> File(".").toURI().toURL().toString());
>>> + sfsm.setBaseFile(currentDir);
>>> + CommonsVfsContainer.sfsm = sfsm;
>>> + } catch (FileSystemException e) {
>>> + throw UtilMisc.initCause(new
>>> ContainerException("Initializing StandardFileSystemManager"), e);
>>> + } catch (MalformedURLException e) {
>>> + throw UtilMisc.initCause(new
>>> ContainerException("Initializing StandardFileSystemManager"), e);
>>> + }
>>> + return true;
>>> + }
>>> +
>>> + public void stop() throws ContainerException {
>>> + sfsm.close();
>>> + sfsm = null;
>>> + }
>>> +
>>> + public static FileObject resolveFile(String uri) throws
>>> IOException {
>>> + return sfsm.resolveFile(uri);
>>> + }
>>> +
>>> + public static FileSystemManager getFileSystemManager() {
>>> + return sfsm;
>>> + }
>>> +}
>>>
>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/
>>> vfs/ ofbiz/OfbizComponentProvider.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java?rev=833727&r1=833726&r2=833727&view=diff
>>> = = = = = = = =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>> ofbiz/ OfbizComponentProvider.java (original)
>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>> ofbiz/ OfbizComponentProvider.java Sat Nov 7 18:18:33 2009
>>> @@ -1,58 +1,58 @@
>>> -/
>>> *******************************************************************************
>>> - * 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.commons.vfs.ofbiz;
>>> -
>>> -import java.net.URL;
>>> -import java.util.Collection;
>>> -import org.apache.commons.vfs.FileObject;
>>> -import org.apache.commons.vfs.FileSystemException;
>>> -import org.apache.commons.vfs.FileSystemOptions;
>>> -import org.apache.commons.vfs.provider.AbstractFileProvider;
>>> -import
>>> org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>> -import org.ofbiz.base.location.FlexibleLocation;
>>> -import org.ofbiz.base.util.UtilMisc;
>>> -import org.webslinger.commons.vfs.VFSUtil;
>>> -
>>> -public class OfbizComponentProvider extends AbstractFileProvider {
>>> - public Collection getCapabilities() {
>>> - return DefaultLocalFileProvider.capabilities;
>>> - }
>>> -
>>> - public FileObject findFile(FileObject base, String name,
>>> FileSystemOptions properties) throws FileSystemException {
>>> - try {
>>> - //name = name.replaceAll("^ofbiz-component://", "");
>>> - int nameLength = name.length();
>>> - int componentNameStart = 16;
>>> - while (componentNameStart < nameLength &&
>>> name.charAt(componentNameStart) == '/') componentNameStart++;
>>> - if (componentNameStart == nameLength) throw new
>>> IllegalArgumentException("Invalid name(" + name + ")");
>>> - int componentNameEnd = componentNameStart;
>>> - while (componentNameEnd < nameLength &&
>>> name.charAt(componentNameEnd) != '/') componentNameEnd++;
>>> - if (componentNameEnd == nameLength) throw new
>>> IllegalArgumentException("Invalid name(" + name + ")");
>>> - int restStart = componentNameEnd;
>>> - while (restStart < nameLength &&
>>> name.charAt(restStart) == '/') restStart++;
>>> - if (restStart == nameLength) throw new
>>> IllegalArgumentException("Invalid name(" + name + ")");
>>> - String componentName =
>>> name.substring(componentNameStart, componentNameEnd);
>>> - URL location =
>>> FlexibleLocation.resolveLocation("component://" + componentName +
>>> "/.");
>>> - FileObject ofbizBase =
>>> getContext().resolveFile(location.toString(), properties);
>>> - return
>>> VFSUtil
>>> .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
>>> ofbizBase
>>> .resolveFile(name.substring(restStart)).getURL().toString(),
>>> properties);
>>> - } catch (Exception e) {
>>> - throw UtilMisc.initCause(new
>>> FileSystemException(e.getMessage(), null, e), e);
>>> - }
>>> - }
>>> -}
>>> +/
>>> *******************************************************************************
>>> + * 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.commons.vfs.ofbiz;
>>> +
>>> +import java.net.URL;
>>> +import java.util.Collection;
>>> +import org.apache.commons.vfs.FileObject;
>>> +import org.apache.commons.vfs.FileSystemException;
>>> +import org.apache.commons.vfs.FileSystemOptions;
>>> +import org.apache.commons.vfs.provider.AbstractFileProvider;
>>> +import
>>> org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>> +import org.ofbiz.base.location.FlexibleLocation;
>>> +import org.ofbiz.base.util.UtilMisc;
>>> +import org.webslinger.commons.vfs.VFSUtil;
>>> +
>>> +public class OfbizComponentProvider extends AbstractFileProvider {
>>> + public Collection<?> getCapabilities() {
>>> + return DefaultLocalFileProvider.capabilities;
>>> + }
>>> +
>>> + public FileObject findFile(FileObject base, String name,
>>> FileSystemOptions properties) throws FileSystemException {
>>> + try {
>>> + //name = name.replaceAll("^ofbiz-component://", "");
>>> + int nameLength = name.length();
>>> + int componentNameStart = 16;
>>> + while (componentNameStart < nameLength &&
>>> name.charAt(componentNameStart) == '/') componentNameStart++;
>>> + if (componentNameStart == nameLength) throw new
>>> IllegalArgumentException("Invalid name(" + name + ")");
>>> + int componentNameEnd = componentNameStart;
>>> + while (componentNameEnd < nameLength &&
>>> name.charAt(componentNameEnd) != '/') componentNameEnd++;
>>> + if (componentNameEnd == nameLength) throw new
>>> IllegalArgumentException("Invalid name(" + name + ")");
>>> + int restStart = componentNameEnd;
>>> + while (restStart < nameLength &&
>>> name.charAt(restStart) == '/') restStart++;
>>> + if (restStart == nameLength) throw new
>>> IllegalArgumentException("Invalid name(" + name + ")");
>>> + String componentName =
>>> name.substring(componentNameStart, componentNameEnd);
>>> + URL location =
>>> FlexibleLocation.resolveLocation("component://" + componentName +
>>> "/.");
>>> + FileObject ofbizBase =
>>> getContext().resolveFile(location.toString(), properties);
>>> + return
>>> VFSUtil
>>> .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
>>> ofbizBase
>>> .resolveFile(name.substring(restStart)).getURL().toString(),
>>> properties);
>>> + } catch (Exception e) {
>>> + throw UtilMisc.initCause(new
>>> FileSystemException(e.getMessage(), null, e), e);
>>> + }
>>> + }
>>> +}
>>>
>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/
>>> vfs/ ofbiz/OfbizHomeProvider.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java?rev=833727&r1=833726&r2=833727&view=diff
>>> = = = = = = = =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>> ofbiz/ OfbizHomeProvider.java (original)
>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/
>>> ofbiz/ OfbizHomeProvider.java Sat Nov 7 18:18:33 2009
>>> @@ -1,50 +1,50 @@
>>> -/
>>> *******************************************************************************
>>> - * 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.commons.vfs.ofbiz;
>>> -
>>> -import java.net.URL;
>>> -import java.util.Collection;
>>> -
>>> -import org.apache.commons.vfs.FileObject;
>>> -import org.apache.commons.vfs.FileSystemException;
>>> -import org.apache.commons.vfs.FileSystemOptions;
>>> -import org.apache.commons.vfs.provider.AbstractFileProvider;
>>> -import
>>> org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>> -
>>> -import org.ofbiz.base.location.FlexibleLocation;
>>> -import org.ofbiz.base.util.UtilMisc;
>>> -
>>> -import org.webslinger.commons.vfs.VFSUtil;
>>> -
>>> -public class OfbizHomeProvider extends AbstractFileProvider {
>>> - public Collection getCapabilities() {
>>> - return DefaultLocalFileProvider.capabilities;
>>> - }
>>> -
>>> - public FileObject findFile(FileObject base, String name,
>>> FileSystemOptions properties) throws FileSystemException {
>>> - //new Exception("findFile(" + base + ", " + name +
>>> ")").printStackTrace();
>>> - try {
>>> - URL location =
>>> FlexibleLocation.resolveLocation("ofbizhome://.");
>>> - FileObject ofbizBase =
>>> getContext().resolveFile(location.toString(), properties);
>>> - return
>>> VFSUtil
>>> .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
>>> ofbizBase.resolveFile(name.substring(13)).getURL().toString(),
>>> properties);
>>> - } catch (Exception e) {
>>> - throw UtilMisc.initCause(new
>>> FileSystemException(e.getMessage(), null, e), e);
>>> - }
>>> - }
>>> -}
>>> +/
>>> *******************************************************************************
>>> + * 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.commons.vfs.ofbiz;
>>> +
>>> +import java.net.URL;
>>> +import java.util.Collection;
>>> +
>>> +import org.apache.commons.vfs.FileObject;
>>> +import org.apache.commons.vfs.FileSystemException;
>>> +import org.apache.commons.vfs.FileSystemOptions;
>>> +import org.apache.commons.vfs.provider.AbstractFileProvider;
>>> +import
>>> org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>>> +
>>> +import org.ofbiz.base.location.FlexibleLocation;
>>> +import org.ofbiz.base.util.UtilMisc;
>>> +
>>> +import org.webslinger.commons.vfs.VFSUtil;
>>> +
>>> +public class OfbizHomeProvider extends AbstractFileProvider {
>>> + public Collection<?> getCapabilities() {
>>> + return DefaultLocalFileProvider.capabilities;
>>> + }
>>> +
>>> + public FileObject findFile(FileObject base, String name,
>>> FileSystemOptions properties) throws FileSystemException {
>>> + //new Exception("findFile(" + base + ", " + name +
>>> ")").printStackTrace();
>>> + try {
>>> + URL location =
>>> FlexibleLocation.resolveLocation("ofbizhome://.");
>>> + FileObject ofbizBase =
>>> getContext().resolveFile(location.toString(), properties);
>>> + return
>>> VFSUtil
>>> .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
>>> ofbizBase.resolveFile(name.substring(13)).getURL().toString(),
>>> properties);
>>> + } catch (Exception e) {
>>> + throw UtilMisc.initCause(new
>>> FileSystemException(e.getMessage(), null, e), e);
>>> + }
>>> + }
>>> +}
>>>
>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/
>>> webslinger/ EntityHttpUtil.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/EntityHttpUtil.java?rev=833727&r1=833726&r2=833727&view=diff
>>> = = = = = = = =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>> EntityHttpUtil.java (original)
>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>> EntityHttpUtil.java Sat Nov 7 18:18:33 2009
>>> @@ -1,78 +1,73 @@
>>> -/
>>> *******************************************************************************
>>> - * 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.webslinger;
>>> -
>>> -import java.util.HashMap;
>>> -import java.util.Iterator;
>>> -import java.util.Locale;
>>> -import java.util.Map;
>>> -
>>> -import javax.servlet.ServletRequest;
>>> -import javax.servlet.http.HttpServletRequest;
>>> -
>>> -import org.ofbiz.base.util.GeneralException;
>>> -import org.ofbiz.base.util.ObjectType;
>>> -import org.ofbiz.base.util.UtilHttp;
>>> -import org.ofbiz.base.util.UtilMisc;
>>> -import org.ofbiz.base.util.UtilValidate;
>>> -import org.ofbiz.entity.Delegator;
>>> -import org.ofbiz.entity.GenericValue;
>>> -import org.ofbiz.entity.jdbc.SqlJdbcUtil;
>>> -import org.ofbiz.entity.model.ModelEntity;
>>> -import org.ofbiz.entity.model.ModelField;
>>> -import org.ofbiz.entity.model.ModelFieldType;
>>> -
>>> -public class EntityHttpUtil {
>>> - public static GenericValue makeValidValue(String entityName,
>>> ServletRequest request) throws GeneralException {
>>> - return makeValidValue(entityName, false, request);
>>> - }
>>> -
>>> - public static GenericValue makeValidValue(String entityName,
>>> boolean includePks, ServletRequest request) throws
>>> GeneralException {
>>> - if (request instanceof HttpServletRequest) return
>>> makeValidValue(entityName, includePks, (HttpServletRequest)
>>> request);
>>> - throw new IllegalArgumentException("Not an
>>> HttpServletRequest");
>>> - }
>>> -
>>> - public static GenericValue makeValidValue(String entityName,
>>> HttpServletRequest request) throws GeneralException {
>>> - return makeValidValue(entityName, false, request);
>>> - }
>>> -
>>> - public static GenericValue makeValidValue(String entityName,
>>> boolean includePks, HttpServletRequest request) throws
>>> GeneralException {
>>> - Delegator delegator = (Delegator)
>>> request.getAttribute("delegator");
>>> - GenericValue value = delegator.makeValue(entityName);
>>> - ModelEntity model = value.getModelEntity();
>>> - Iterator<ModelField> it = includePks ?
>>> model.getFieldsIterator() : model.getNopksIterator();
>>> - Locale locale = UtilHttp.getLocale(request);
>>> - while (it.hasNext()) {
>>> - ModelField field = it.next();
>>> - String fieldName = field.getName();
>>> - String parameterValue =
>>> request.getParameter(fieldName);
>>> - Object fieldValue;
>>> - if (parameterValue == null) {
>>> - fieldValue = null;
>>> - } else {
>>> - ModelFieldType fieldType =
>>> delegator.getEntityFieldType(model, field.getType());
>>> - String wantedType = fieldType.getJavaType();
>>> - fieldValue =
>>> ObjectType.simpleTypeConvert(parameterValue, wantedType, null,
>>> locale, true);
>>> - }
>>> - value.put(fieldName, fieldValue);
>>> - }
>>> - return value;
>>> - }
>>> -}
>>> -
>>> +/
>>> *******************************************************************************
>>> + * 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.webslinger;
>>> +
>>> +import java.util.Iterator;
>>> +import java.util.Locale;
>>> +
>>> +import javax.servlet.ServletRequest;
>>> +import javax.servlet.http.HttpServletRequest;
>>> +
>>> +import org.ofbiz.base.util.GeneralException;
>>> +import org.ofbiz.base.util.ObjectType;
>>> +import org.ofbiz.base.util.UtilHttp;
>>> +import org.ofbiz.entity.Delegator;
>>> +import org.ofbiz.entity.GenericValue;
>>> +import org.ofbiz.entity.model.ModelEntity;
>>> +import org.ofbiz.entity.model.ModelField;
>>> +import org.ofbiz.entity.model.ModelFieldType;
>>> +
>>> +public class EntityHttpUtil {
>>> + public static GenericValue makeValidValue(String entityName,
>>> ServletRequest request) throws GeneralException {
>>> + return makeValidValue(entityName, false, request);
>>> + }
>>> +
>>> + public static GenericValue makeValidValue(String entityName,
>>> boolean includePks, ServletRequest request) throws
>>> GeneralException {
>>> + if (request instanceof HttpServletRequest) return
>>> makeValidValue(entityName, includePks, (HttpServletRequest)
>>> request);
>>> + throw new IllegalArgumentException("Not an
>>> HttpServletRequest");
>>> + }
>>> +
>>> + public static GenericValue makeValidValue(String entityName,
>>> HttpServletRequest request) throws GeneralException {
>>> + return makeValidValue(entityName, false, request);
>>> + }
>>> +
>>> + public static GenericValue makeValidValue(String entityName,
>>> boolean includePks, HttpServletRequest request) throws
>>> GeneralException {
>>> + Delegator delegator = (Delegator)
>>> request.getAttribute("delegator");
>>> + GenericValue value = delegator.makeValue(entityName);
>>> + ModelEntity model = value.getModelEntity();
>>> + Iterator<ModelField> it = includePks ?
>>> model.getFieldsIterator() : model.getNopksIterator();
>>> + Locale locale = UtilHttp.getLocale(request);
>>> + while (it.hasNext()) {
>>> + ModelField field = it.next();
>>> + String fieldName = field.getName();
>>> + String parameterValue =
>>> request.getParameter(fieldName);
>>> + Object fieldValue;
>>> + if (parameterValue == null) {
>>> + fieldValue = null;
>>> + } else {
>>> + ModelFieldType fieldType =
>>> delegator.getEntityFieldType(model, field.getType());
>>> + String wantedType = fieldType.getJavaType();
>>> + fieldValue =
>>> ObjectType.simpleTypeConvert(parameterValue, wantedType, null,
>>> locale, true);
>>> + }
>>> + value.put(fieldName, fieldValue);
>>> + }
>>> + return value;
>>> + }
>>> +}
>>> +
>>>
>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/
>>> webslinger/ StatsUpdater.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java?rev=833727&r1=833726&r2=833727&view=diff
>>> = = = = = = = =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>> StatsUpdater.java (original)
>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>> StatsUpdater.java Sat Nov 7 18:18:33 2009
>>> @@ -1,121 +1,118 @@
>>> -/
>>> *******************************************************************************
>>> - * 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.webslinger;
>>> -
>>> -import java.util.HashMap;
>>> -import java.util.Iterator;
>>> -import java.util.Map;
>>> -import java.util.concurrent.Callable;
>>> -import java.util.concurrent.ConcurrentHashMap;
>>> -import java.util.concurrent.ScheduledFuture;
>>> -import java.util.concurrent.TimeUnit;
>>> -import java.util.concurrent.atomic.AtomicReference;
>>> -
>>> -import org.ofbiz.base.util.UtilMisc;
>>> -import org.ofbiz.entity.Delegator;
>>> -import org.ofbiz.entity.GenericEntityException;
>>> -import org.ofbiz.entity.GenericPK;
>>> -import org.ofbiz.entity.GenericValue;
>>> -
>>> -import org.webslinger.cache.ConcurrentCache;
>>> -import org.webslinger.concurrent.ExecutionPool;
>>> -
>>> -public class StatsUpdater {
>>> - private static final Updater UPDATER = new Updater();
>>> -
>>> - public static void updateStats(Delegator delegator, String
>>> entityName, Map<String, ? extends Object> keyFields,
>>> Map<String, ? extends Long> updateCountFields) throws
>>> GenericEntityException {
>>> - GenericPK pk = delegator.makePK(entityName, keyFields);
>>> - Map<String, Long> value = UPDATER.getValue(pk);
>>> - synchronized (value) {
>>> - for (Map.Entry<String, ? extends Long> entry:
>>> updateCountFields.entrySet()) {
>>> - Long oldValue = value.get(entry.getKey());
>>> - if (oldValue != null) {
>>> - value.put(entry.getKey(),
>>> Long.valueOf(oldValue.longValue() + entry.getValue()));
>>> - } else {
>>> - value.put(entry.getKey(), entry.getValue());
>>> - }
>>> - }
>>> - }
>>> - }
>>> -
>>> - private static final class Updater implements Callable<Void> {
>>> - protected AtomicReference<EntityHolder> entities = new
>>> AtomicReference<EntityHolder>(new EntityHolder(Updater.class,
>>> "entities", null));
>>> - protected ScheduledFuture<Void> future;
>>> -
>>> - protected Map<String, Long> getValue(GenericPK pk)
>>> throws GenericEntityException {
>>> - synchronized (this) {
>>> - if (future == null || future.isDone()) {
>>> - future = ExecutionPool.schedule(this, 1,
>>> TimeUnit.SECONDS);
>>> - }
>>> - }
>>> - try {
>>> - return entities.get().get(pk);
>>> - } catch (RuntimeException e) {
>>> - throw e;
>>> - } catch (GenericEntityException e) {
>>> - throw e;
>>> - } catch (Exception e) {
>>> - throw UtilMisc.initCause(new
>>> GenericEntityException(e.getMessage()), e);
>>> - }
>>> - }
>>> -
>>> - public Void call() {
>>> - EntityHolder oldEntities;
>>> - EntityHolder newEntities = new
>>> EntityHolder(Updater.class, "entities", null);
>>> - do {
>>> - oldEntities = entities.get();
>>> - } while (!entities.compareAndSet(oldEntities,
>>> newEntities));
>>> - synchronized (Updater.class) {
>>> - for (GenericPK pk: oldEntities.keys()) {
>>> - try {
>>> - Map<String, Long> add =
>>> oldEntities.get(pk);
>>> - GenericValue existing =
>>> pk.getDelegator().findOne(pk.getEntityName(), pk, false);
>>> - if (existing == null) {
>>> - existing =
>>> pk.getDelegator().create(pk.getEntityName(), pk);
>>> - }
>>> - for (Map.Entry<String, Long> entry:
>>> add.entrySet()) {
>>> - Long value = entry.getValue();
>>> - Long oldValue =
>>> existing.getLong(entry.getKey());
>>> - if (oldValue != null) {
>>> - existing.put(entry.getKey(),
>>> Long.valueOf(value.longValue() + oldValue.longValue()));
>>> - } else {
>>> - existing.put(entry.getKey(),
>>> value);
>>> - }
>>> - }
>>> - existing.store();
>>> - } catch (Exception e) {
>>> - e.printStackTrace();
>>> - }
>>> - }
>>> - }
>>> - return null;
>>> - }
>>> - }
>>> -
>>> - private static final class EntityHolder extends
>>> ConcurrentCache<GenericPK, Map<String, Long>> {
>>> - protected EntityHolder(Class<?> owner, String field,
>>> String label) {
>>> - super(owner, field, label, HARD);
>>> - }
>>> -
>>> - @Override
>>> - protected Map<String, Long> createValue(GenericPK pk)
>>> throws Exception {
>>> - return new HashMap<String, Long>();
>>> - }
>>> - }
>>> -}
>>> +/
>>> *******************************************************************************
>>> + * 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.webslinger;
>>> +
>>> +import java.util.HashMap;
>>> +import java.util.Map;
>>> +import java.util.concurrent.Callable;
>>> +import java.util.concurrent.ScheduledFuture;
>>> +import java.util.concurrent.TimeUnit;
>>> +import java.util.concurrent.atomic.AtomicReference;
>>> +
>>> +import org.ofbiz.base.util.UtilMisc;
>>> +import org.ofbiz.entity.Delegator;
>>> +import org.ofbiz.entity.GenericEntityException;
>>> +import org.ofbiz.entity.GenericPK;
>>> +import org.ofbiz.entity.GenericValue;
>>> +import org.webslinger.cache.ConcurrentCache;
>>> +import org.webslinger.concurrent.ExecutionPool;
>>> +
>>> +public class StatsUpdater {
>>> + private static final Updater UPDATER = new Updater();
>>> +
>>> + public static void updateStats(Delegator delegator, String
>>> entityName, Map<String, ? extends Object> keyFields,
>>> Map<String, ? extends Long> updateCountFields) throws
>>> GenericEntityException {
>>> + GenericPK pk = delegator.makePK(entityName, keyFields);
>>> + Map<String, Long> value = UPDATER.getValue(pk);
>>> + synchronized (value) {
>>> + for (Map.Entry<String, ? extends Long> entry:
>>> updateCountFields.entrySet()) {
>>> + Long oldValue = value.get(entry.getKey());
>>> + if (oldValue != null) {
>>> + value.put(entry.getKey(),
>>> Long.valueOf(oldValue.longValue() + entry.getValue()));
>>> + } else {
>>> + value.put(entry.getKey(), entry.getValue());
>>> + }
>>> + }
>>> + }
>>> + }
>>> +
>>> + private static final class Updater implements Callable<Void> {
>>> + protected AtomicReference<EntityHolder> entities = new
>>> AtomicReference<EntityHolder>(new EntityHolder(Updater.class,
>>> "entities", null));
>>> + protected ScheduledFuture<Void> future;
>>> +
>>> + protected Map<String, Long> getValue(GenericPK pk)
>>> throws GenericEntityException {
>>> + synchronized (this) {
>>> + if (future == null || future.isDone()) {
>>> + future = ExecutionPool.schedule(this, 1,
>>> TimeUnit.SECONDS);
>>> + }
>>> + }
>>> + try {
>>> + return entities.get().get(pk);
>>> + } catch (RuntimeException e) {
>>> + throw e;
>>> + } catch (GenericEntityException e) {
>>> + throw e;
>>> + } catch (Exception e) {
>>> + throw UtilMisc.initCause(new
>>> GenericEntityException(e.getMessage()), e);
>>> + }
>>> + }
>>> +
>>> + public Void call() {
>>> + EntityHolder oldEntities;
>>> + EntityHolder newEntities = new
>>> EntityHolder(Updater.class, "entities", null);
>>> + do {
>>> + oldEntities = entities.get();
>>> + } while (!entities.compareAndSet(oldEntities,
>>> newEntities));
>>> + synchronized (Updater.class) {
>>> + for (GenericPK pk: oldEntities.keys()) {
>>> + try {
>>> + Map<String, Long> add =
>>> oldEntities.get(pk);
>>> + GenericValue existing =
>>> pk.getDelegator().findOne(pk.getEntityName(), pk, false);
>>> + if (existing == null) {
>>> + existing =
>>> pk.getDelegator().create(pk.getEntityName(), pk);
>>> + }
>>> + for (Map.Entry<String, Long> entry:
>>> add.entrySet()) {
>>> + Long value = entry.getValue();
>>> + Long oldValue =
>>> existing.getLong(entry.getKey());
>>> + if (oldValue != null) {
>>> + existing.put(entry.getKey(),
>>> Long.valueOf(value.longValue() + oldValue.longValue()));
>>> + } else {
>>> + existing.put(entry.getKey(),
>>> value);
>>> + }
>>> + }
>>> + existing.store();
>>> + } catch (Exception e) {
>>> + e.printStackTrace();
>>> + }
>>> + }
>>> + }
>>> + return null;
>>> + }
>>> + }
>>> +
>>> + private static final class EntityHolder extends
>>> ConcurrentCache<GenericPK, Map<String, Long>> {
>>> + protected EntityHolder(Class<?> owner, String field,
>>> String label) {
>>> + super(owner, field, label, HARD);
>>> + }
>>> +
>>> + @Override
>>> + protected Map<String, Long> createValue(GenericPK pk)
>>> throws Exception {
>>> + return new HashMap<String, Long>();
>>> + }
>>> + }
>>> +}
>>>
>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/
>>> webslinger/ WebslingerContextMapper.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java?rev=833727&r1=833726&r2=833727&view=diff
>>> = = = = = = = =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>> WebslingerContextMapper.java (original)
>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>> WebslingerContextMapper.java Sat Nov 7 18:18:33 2009
>>> @@ -1,218 +1,216 @@
>>> -/
>>> *******************************************************************************
>>> - * 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.webslinger;
>>> -
>>> -import java.io.IOException;
>>> -import java.net.URL;
>>> -import java.util.ArrayList;
>>> -import java.util.Arrays;
>>> -import java.util.HashSet;
>>> -import java.util.List;
>>> -import java.util.Set;
>>> -
>>> -import javax.servlet.ServletConfig;
>>> -import javax.servlet.ServletContext;
>>> -import javax.servlet.ServletException;
>>> -import javax.servlet.http.HttpServletRequest;
>>> -
>>> -import org.ofbiz.base.util.UtilMisc;
>>> -import org.ofbiz.base.util.UtilProperties;
>>> -import org.ofbiz.entity.Delegator;
>>> -import org.ofbiz.entity.DelegatorFactory;
>>> -import org.ofbiz.entity.GenericEntityException;
>>> -import org.ofbiz.entity.GenericValue;
>>> -import org.ofbiz.entity.cache.Cache;
>>> -import org.ofbiz.entity.util.EntityUtil;
>>> -import org.ofbiz.security.SecurityFactory;
>>> -import org.ofbiz.security.authz.AuthorizationFactory;
>>> -import org.ofbiz.service.GenericDispatcher;
>>> -import org.ofbiz.service.LocalDispatcher;
>>> -import org.ofbiz.service.ServiceDispatcher;
>>> -import org.ofbiz.service.DispatchContext;
>>> -
>>> -import
>>> org.webslinger.AbstractMappingWebslingerServletContextFactory;
>>> -import org.webslinger.WebslingerServletContext;
>>> -import org.webslinger.collections.CollectionUtil;
>>> -import org.webslinger.lang.ObjectUtil;
>>> -
>>> -public class WebslingerContextMapper extends
>>> AbstractMappingWebslingerServletContextFactory {
>>> - protected ServletContext servletContext;
>>> - protected Delegator delegator;
>>> - protected final ArrayList<URL> globalReaderURLs = new
>>> ArrayList<URL>();
>>> -
>>> - public void init(ServletConfig config) throws
>>> ServletException, IOException {
>>> -
>>> System
>>> .err
>>> .println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
>>> - servletContext = config.getServletContext();
>>> - String delegatorName =
>>> servletContext.getInitParameter("entityDelegatorName");
>>> - delegator = DelegatorFactory.getDelegator(delegatorName);
>>> - String readerFiles =
>>> servletContext.getInitParameter("serviceReaderUrls");
>>> - if (readerFiles != null) {
>>> - for (String reader:
>>> CollectionUtil.split(readerFiles, ";")) {
>>> - URL url =
>>> config.getServletContext().getResource(reader);
>>> - if (url != null) globalReaderURLs.add(url);
>>> - }
>>> - }
>>> - super.init(config,
>>> UtilProperties.getPropertyValue("webslinger.properties",
>>> "moduleBase"));
>>> - }
>>> -
>>> - @Override
>>> - protected Layout[] getStartLayouts() throws Exception {
>>> - ArrayList<Layout> layouts = new ArrayList<Layout>();
>>> - try {
>>> - for (GenericValue value:
>>> delegator.findByAnd("WebslingerServer",
>>> UtilMisc.toMap("loadAtStart", "Y"))) {
>>> - layouts.add(new OfbizLayout(value));
>>> - }
>>> - } catch (GenericEntityException e) {
>>> - }
>>> - return layouts.toArray(new Layout[layouts.size()]);
>>> - }
>>> -
>>> - @Override
>>> - public void initializeRequest(WebslingerServletContext
>>> context, HttpServletRequest request) {
>>> - request.setAttribute("servletContext", context);
>>> - Object delegator = context.getAttribute("delegator");
>>> - Object dispatcher = context.getAttribute("dispatcher");
>>> - Object authz = context.getAttribute("authz");
>>> - Object security = context.getAttribute("security");
>>> - request.setAttribute("delegator", delegator);
>>> - request.setAttribute("dispatcher", dispatcher);
>>> - request.setAttribute("authz", authz);
>>> - request.setAttribute("security", security);
>>> - // FIXME!!! These next two are a hack until proper fake/
>>> wrapped session support is done in webslinger
>>> - servletContext.setAttribute("delegator", delegator);
>>> - servletContext.setAttribute("dispatcher", dispatcher);
>>> - servletContext.setAttribute("authz", authz);
>>> - servletContext.setAttribute("security", security);
>>> - }
>>> -
>>> - @Override
>>> - protected void initializeContext(WebslingerServletContext
>>> context, Layout layout) throws Exception {
>>> - OfbizLayout ofbizLayout = (OfbizLayout) layout;
>>> - Delegator delegator = null;
>>> - delegator =
>>> DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
>>> - context.setAttribute("delegator", delegator);
>>> - context.setAttribute("dispatcher", new
>>> WebslingerGenericDispatcher(context, layout.getTarget(),
>>> delegator, globalReaderURLs));
>>> - context.setAttribute("authz",
>>> AuthorizationFactory.getInstance(delegator));
>>> - context.setAttribute("security",
>>> SecurityFactory.getInstance(delegator));
>>> - }
>>> -
>>> - protected static final class WebslingerGenericDispatcher
>>> extends GenericDispatcher {
>>> - protected
>>> WebslingerGenericDispatcher(WebslingerServletContext context,
>>> String name, Delegator delegator, List<URL> globalReaderURLs)
>>> throws IOException {
>>> - ArrayList<URL> readerURLs = new
>>> ArrayList<URL>(globalReaderURLs);
>>> - String readerFiles =
>>> context.getInitParameter("serviceReaderUrls");
>>> - if (readerFiles != null) {
>>> - for (String reader:
>>> CollectionUtil.split(readerFiles, ";")) {
>>> - URL url = context.getResource(reader);
>>> - if (url != null) readerURLs.add(url);
>>> - }
>>> - }
>>> - System.err.println(readerURLs);
>>> - this.dispatcher = new ServiceDispatcher(delegator,
>>> true, true, true) {
>>> - };
>>> - ClassLoader loader = null;
>>> - try {
>>> - loader =
>>> Thread.currentThread().getContextClassLoader();
>>> - } catch (SecurityException e) {
>>> - loader =
>>> WebslingerContextMapper.class.getClassLoader();
>>> - }
>>> - DispatchContext dc = new DispatchContext(name,
>>> readerURLs, loader, null);
>>> - init(name, delegator, dc);
>>> - }
>>> - }
>>> -
>>> - @Override
>>> - protected Set<String> getSuffixes() throws Exception {
>>> - Cache cache = delegator.getCache();
>>> - Set<String> suffixes;
>>> - synchronized (WebslingerContextMapper.class) {
>>> - suffixes = cache.get("WebslingerHostSuffix", null,
>>> "WebslingerContextMapper.Suffixes");
>>> - if (suffixes == null) {
>>> - suffixes = new HashSet<String>();
>>> - for (GenericValue value:
>>> delegator.findList("WebslingerHostSuffix", null, null, null,
>>> null, false)) {
>>> - suffixes.add(value.getString("hostSuffix"));
>>> - }
>>> - cache.put("WebslingerHostSuffix", null,
>>> "WebslingerContextMapper.Suffixes", suffixes);
>>> - }
>>> - }
>>> - return suffixes;
>>> - }
>>> -
>>> - @Override
>>> - protected Layout lookupLayout(String hostName, String
>>> contextPath) throws Exception {
>>> - GenericValue layout =
>>> EntityUtil.getOnly(delegator.findByAndCache("WebslingerLayout",
>>> UtilMisc.toMap("hostName", hostName, "contextPath", contextPath)));
>>> - if (layout == null) return null;
>>> - return new OfbizLayout(layout);
>>> - }
>>> -
>>> - protected class OfbizLayout implements Layout {
>>> - private final String contextPath;
>>> - private final String id;
>>> - private final String target;
>>> - private final String[] bases;
>>> - private final int hashCode;
>>> - protected final String delegatorName;
>>> - protected final String dispatcherName;
>>> -
>>> - protected OfbizLayout(GenericValue server) throws
>>> GenericEntityException {
>>> - contextPath = server.getString("contextPath");
>>> - id = server.getString("webslingerServerId");
>>> - target = server.getString("target");
>>> - List<GenericValue> baseValues =
>>> server.getRelatedCache("WebslingerServerBase",
>>> UtilMisc.toList("seqNum"));
>>> - bases = new String[baseValues.size()];
>>> - for (int i = 0; i < bases.length; i++) {
>>> - GenericValue baseValue = baseValues.get(i);
>>> - bases[i] = baseValue.getString("baseName");
>>> - }
>>> - delegatorName = server.getString("delegatorName");
>>> - dispatcherName = server.getString("dispatcherName");
>>> - hashCode = target.hashCode() ^
>>> ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
>>> - }
>>> -
>>> - public String getContextPath() {
>>> - return contextPath;
>>> - }
>>> -
>>> - public String getId() {
>>> - return id;
>>> - }
>>> -
>>> - public String getTarget() {
>>> - return target;
>>> - }
>>> -
>>> - public String[] getBases() {
>>> - return bases;
>>> - }
>>> -
>>> - @Override
>>> - public int hashCode() {
>>> - return hashCode;
>>> - }
>>> -
>>> - @Override
>>> - public boolean equals(Object o) {
>>> - if (!(o instanceof OfbizLayout)) return false;
>>> - OfbizLayout other = (OfbizLayout) o;
>>> - if (!contextPath.equals(other.contextPath)) return
>>> false;
>>> - if (!target.equals(other.target)) return false;
>>> - if (!ObjectUtil.equalsHelper(delegatorName,
>>> other.delegatorName)) return false;
>>> - return Arrays.equals(bases, other.bases);
>>> - }
>>> - }
>>> -}
>>> +/
>>> *******************************************************************************
>>> + * 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.webslinger;
>>> +
>>> +import java.io.IOException;
>>> +import java.net.URL;
>>> +import java.util.ArrayList;
>>> +import java.util.Arrays;
>>> +import java.util.HashSet;
>>> +import java.util.List;
>>> +import java.util.Set;
>>> +
>>> +import javax.servlet.ServletConfig;
>>> +import javax.servlet.ServletContext;
>>> +import javax.servlet.ServletException;
>>> +import javax.servlet.http.HttpServletRequest;
>>> +
>>> +import org.ofbiz.base.util.UtilMisc;
>>> +import org.ofbiz.base.util.UtilProperties;
>>> +import org.ofbiz.entity.Delegator;
>>> +import org.ofbiz.entity.DelegatorFactory;
>>> +import org.ofbiz.entity.GenericEntityException;
>>> +import org.ofbiz.entity.GenericValue;
>>> +import org.ofbiz.entity.cache.Cache;
>>> +import org.ofbiz.entity.util.EntityUtil;
>>> +import org.ofbiz.security.SecurityFactory;
>>> +import org.ofbiz.security.authz.AuthorizationFactory;
>>> +import org.ofbiz.service.DispatchContext;
>>> +import org.ofbiz.service.GenericDispatcher;
>>> +import org.ofbiz.service.ServiceDispatcher;
>>> +import
>>> org.webslinger.AbstractMappingWebslingerServletContextFactory;
>>> +import org.webslinger.WebslingerServletContext;
>>> +import org.webslinger.collections.CollectionUtil;
>>> +import org.webslinger.lang.ObjectUtil;
>>> +
>>> +public class WebslingerContextMapper extends
>>> AbstractMappingWebslingerServletContextFactory {
>>> + protected ServletContext servletContext;
>>> + protected Delegator delegator;
>>> + protected final ArrayList<URL> globalReaderURLs = new
>>> ArrayList<URL>();
>>> +
>>> + public void init(ServletConfig config) throws
>>> ServletException, IOException {
>>> +
>>> System
>>> .err
>>> .println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
>>> + servletContext = config.getServletContext();
>>> + String delegatorName =
>>> servletContext.getInitParameter("entityDelegatorName");
>>> + delegator = DelegatorFactory.getDelegator(delegatorName);
>>> + String readerFiles =
>>> servletContext.getInitParameter("serviceReaderUrls");
>>> + if (readerFiles != null) {
>>> + for (String reader:
>>> CollectionUtil.split(readerFiles, ";")) {
>>> + URL url =
>>> config.getServletContext().getResource(reader);
>>> + if (url != null) globalReaderURLs.add(url);
>>> + }
>>> + }
>>> + super.init(config,
>>> UtilProperties.getPropertyValue("webslinger.properties",
>>> "moduleBase"));
>>> + }
>>> +
>>> + @Override
>>> + protected Layout[] getStartLayouts() throws Exception {
>>> + ArrayList<Layout> layouts = new ArrayList<Layout>();
>>> + try {
>>> + for (GenericValue value:
>>> delegator.findByAnd("WebslingerServer",
>>> UtilMisc.toMap("loadAtStart", "Y"))) {
>>> + layouts.add(new OfbizLayout(value));
>>> + }
>>> + } catch (GenericEntityException e) {
>>> + }
>>> + return layouts.toArray(new Layout[layouts.size()]);
>>> + }
>>> +
>>> + @Override
>>> + public void initializeRequest(WebslingerServletContext
>>> context, HttpServletRequest request) {
>>> + request.setAttribute("servletContext", context);
>>> + Object delegator = context.getAttribute("delegator");
>>> + Object dispatcher = context.getAttribute("dispatcher");
>>> + Object authz = context.getAttribute("authz");
>>> + Object security = context.getAttribute("security");
>>> + request.setAttribute("delegator", delegator);
>>> + request.setAttribute("dispatcher", dispatcher);
>>> + request.setAttribute("authz", authz);
>>> + request.setAttribute("security", security);
>>> + // FIXME!!! These next two are a hack until proper fake/
>>> wrapped session support is done in webslinger
>>> + servletContext.setAttribute("delegator", delegator);
>>> + servletContext.setAttribute("dispatcher", dispatcher);
>>> + servletContext.setAttribute("authz", authz);
>>> + servletContext.setAttribute("security", security);
>>> + }
>>> +
>>> + @Override
>>> + protected void initializeContext(WebslingerServletContext
>>> context, Layout layout) throws Exception {
>>> + OfbizLayout ofbizLayout = (OfbizLayout) layout;
>>> + Delegator delegator = null;
>>> + delegator =
>>> DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
>>> + context.setAttribute("delegator", delegator);
>>> + context.setAttribute("dispatcher", new
>>> WebslingerGenericDispatcher(context, layout.getTarget(),
>>> delegator, globalReaderURLs));
>>> + context.setAttribute("authz",
>>> AuthorizationFactory.getInstance(delegator));
>>> + context.setAttribute("security",
>>> SecurityFactory.getInstance(delegator));
>>> + }
>>> +
>>> + protected static final class WebslingerGenericDispatcher
>>> extends GenericDispatcher {
>>> + protected
>>> WebslingerGenericDispatcher(WebslingerServletContext context,
>>> String name, Delegator delegator, List<URL> globalReaderURLs)
>>> throws IOException {
>>> + ArrayList<URL> readerURLs = new
>>> ArrayList<URL>(globalReaderURLs);
>>> + String readerFiles =
>>> context.getInitParameter("serviceReaderUrls");
>>> + if (readerFiles != null) {
>>> + for (String reader:
>>> CollectionUtil.split(readerFiles, ";")) {
>>> + URL url = context.getResource(reader);
>>> + if (url != null) readerURLs.add(url);
>>> + }
>>> + }
>>> + System.err.println(readerURLs);
>>> + this.dispatcher = new ServiceDispatcher(delegator,
>>> true, true, true) {
>>> + };
>>> + ClassLoader loader = null;
>>> + try {
>>> + loader =
>>> Thread.currentThread().getContextClassLoader();
>>> + } catch (SecurityException e) {
>>> + loader =
>>> WebslingerContextMapper.class.getClassLoader();
>>> + }
>>> + DispatchContext dc = new DispatchContext(name,
>>> readerURLs, loader, null);
>>> + init(name, delegator, dc);
>>> + }
>>> + }
>>> +
>>> + @Override
>>> + protected Set<String> getSuffixes() throws Exception {
>>> + Cache cache = delegator.getCache();
>>> + Set<String> suffixes;
>>> + synchronized (WebslingerContextMapper.class) {
>>> + suffixes = cache.get("WebslingerHostSuffix", null,
>>> "WebslingerContextMapper.Suffixes");
>>> + if (suffixes == null) {
>>> + suffixes = new HashSet<String>();
>>> + for (GenericValue value:
>>> delegator.findList("WebslingerHostSuffix", null, null, null,
>>> null, false)) {
>>> + suffixes.add(value.getString("hostSuffix"));
>>> + }
>>> + cache.put("WebslingerHostSuffix", null,
>>> "WebslingerContextMapper.Suffixes", suffixes);
>>> + }
>>> + }
>>> + return suffixes;
>>> + }
>>> +
>>> + @Override
>>> + protected Layout lookupLayout(String hostName, String
>>> contextPath) throws Exception {
>>> + GenericValue layout =
>>> EntityUtil.getOnly(delegator.findByAndCache("WebslingerLayout",
>>> UtilMisc.toMap("hostName", hostName, "contextPath", contextPath)));
>>> + if (layout == null) return null;
>>> + return new OfbizLayout(layout);
>>> + }
>>> +
>>> + protected class OfbizLayout implements Layout {
>>> + private final String contextPath;
>>> + private final String id;
>>> + private final String target;
>>> + private final String[] bases;
>>> + private final int hashCode;
>>> + protected final String delegatorName;
>>> + protected final String dispatcherName;
>>> +
>>> + protected OfbizLayout(GenericValue server) throws
>>> GenericEntityException {
>>> + contextPath = server.getString("contextPath");
>>> + id = server.getString("webslingerServerId");
>>> + target = server.getString("target");
>>> + List<GenericValue> baseValues =
>>> server.getRelatedCache("WebslingerServerBase",
>>> UtilMisc.toList("seqNum"));
>>> + bases = new String[baseValues.size()];
>>> + for (int i = 0; i < bases.length; i++) {
>>> + GenericValue baseValue = baseValues.get(i);
>>> + bases[i] = baseValue.getString("baseName");
>>> + }
>>> + delegatorName = server.getString("delegatorName");
>>> + dispatcherName = server.getString("dispatcherName");
>>> + hashCode = target.hashCode() ^
>>> ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
>>> + }
>>> +
>>> + public String getContextPath() {
>>> + return contextPath;
>>> + }
>>> +
>>> + public String getId() {
>>> + return id;
>>> + }
>>> +
>>> + public String getTarget() {
>>> + return target;
>>> + }
>>> +
>>> + public String[] getBases() {
>>> + return bases;
>>> + }
>>> +
>>> + @Override
>>> + public int hashCode() {
>>> + return hashCode;
>>> + }
>>> +
>>> + @Override
>>> + public boolean equals(Object o) {
>>> + if (!(o instanceof OfbizLayout)) return false;
>>> + OfbizLayout other = (OfbizLayout) o;
>>> + if (!contextPath.equals(other.contextPath)) return
>>> false;
>>> + if (!target.equals(other.target)) return false;
>>> + if (!ObjectUtil.equalsHelper(delegatorName,
>>> other.delegatorName)) return false;
>>> + return Arrays.equals(bases, other.bases);
>>> + }
>>> + }
>>> +}
>>>
>>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/
>>> webslinger/ WebslingerServerEngine.java
>>> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java?rev=833727&r1=833726&r2=833727&view=diff
>>> = = = = = = = =
>>> =
>>> =
>>> ====================================================================
>>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>> WebslingerServerEngine.java (original)
>>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/
>>> WebslingerServerEngine.java Sat Nov 7 18:18:33 2009
>>> @@ -1,64 +1,59 @@
>>> -/
>>> *******************************************************************************
>>> - * 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.webslinger;
>>> -
>>> -import java.io.IOException;
>>> -import java.io.StringReader;
>>> -import java.io.StringWriter;
>>> -import java.util.Collections;
>>> -import java.util.Map;
>>> -
>>> -import org.ofbiz.base.util.UtilGenerics;
>>> -import org.ofbiz.base.util.UtilMisc;
>>> -import org.ofbiz.entity.Delegator;
>>> -import org.ofbiz.entity.GenericValue;
>>> -import org.ofbiz.entity.util.EntityUtil;
>>> -import org.ofbiz.service.GenericServiceException;
>>> -import org.ofbiz.service.ModelService;
>>> -import org.ofbiz.service.ServiceDispatcher;
>>> -import org.ofbiz.service.engine.GenericAsyncEngine;
>>> -
>>> -import org.webslinger.WebslingerServletContext;
>>> -
>>> -public class WebslingerServerEngine extends GenericAsyncEngine {
>>> - public WebslingerServerEngine(ServiceDispatcher dispatcher) {
>>> - super(dispatcher);
>>> - }
>>> -
>>> - @Override
>>> - public void runSyncIgnore(String localName, ModelService
>>> modelService, Map<String, Object> context) throws
>>> GenericServiceException {
>>> - runSync(localName, modelService, context);
>>> - }
>>> -
>>> - @Override
>>> - public Map<String, Object> runSync(String localName,
>>> ModelService modelService, Map<String, Object> context) throws
>>> GenericServiceException {
>>> - Delegator delegator = dispatcher.getDelegator();
>>> - try {
>>> - GenericValue found =
>>> EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout",
>>> UtilMisc.toMap("webslingerServerId", modelService.location)));
>>> - if (found == null) throw new
>>> GenericServiceException("Couldn't find server mapping for(" +
>>> modelService.location + ")");
>>> - return UtilGenerics .checkMap
>>> (WebslingerServletContext.invokeInVM(found.getString("hostName"),
>>> 8080, modelService.invoke, context));
>>> - } catch (RuntimeException e) {
>>> - throw e;
>>> - } catch (GenericServiceException e) {
>>> - throw e;
>>> - } catch (Exception e) {
>>> - throw UtilMisc.initCause(new
>>> GenericServiceException(e.getMessage()), e);
>>> - }
>>> - }
>>> -}
>>> +/
>>> *******************************************************************************
>>> + * 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.webslinger;
>>> +
>>> +import java.util.Map;
>>> +
>>> +import org.ofbiz.base.util.UtilGenerics;
>>> +import org.ofbiz.base.util.UtilMisc;
>>> +import org.ofbiz.entity.Delegator;
>>> +import org.ofbiz.entity.GenericValue;
>>> +import org.ofbiz.entity.util.EntityUtil;
>>> +import org.ofbiz.service.GenericServiceException;
>>> +import org.ofbiz.service.ModelService;
>>> +import org.ofbiz.service.ServiceDispatcher;
>>> +import org.ofbiz.service.engine.GenericAsyncEngine;
>>> +import org.webslinger.WebslingerServletContext;
>>> +
>>> +public class WebslingerServerEngine extends GenericAsyncEngine {
>>> + public WebslingerServerEngine(ServiceDispatcher dispatcher) {
>>> + super(dispatcher);
>>> + }
>>> +
>>> + @Override
>>> + public void runSyncIgnore(String localName, ModelService
>>> modelService, Map<String, Object> context) throws
>>> GenericServiceException {
>>> + runSync(localName, modelService, context);
>>> + }
>>> +
>>> + @Override
>>> + public Map<String, Object> runSync(String localName,
>>> ModelService modelService, Map<String, Object> context) throws
>>> GenericServiceException {
>>> + Delegator delegator = dispatcher.getDelegator();
>>> + try {
>>> + GenericValue found =
>>> EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout",
>>> UtilMisc.toMap("webslingerServerId", modelService.location)));
>>> + if (found == null) throw new
>>> GenericServiceException("Couldn't find server mapping for(" +
>>> modelService.location + ")");
>>> + return UtilGenerics .checkMap
>>> (WebslingerServletContext.invokeInVM(found.getString("hostName"),
>>> 8080, modelService.invoke, context));
>>> + } catch (RuntimeException e) {
>>> + throw e;
>>> + } catch (GenericServiceException e) {
>>> + throw e;
>>> + } catch (Exception e) {
>>> + throw UtilMisc.initCause(new
>>> GenericServiceException(e.getMessage()), e);
>>> + }
>>> + }
>>> +}
>>>
>>>
>>
>
>
Re: svn commit: r833727 - in /ofbiz/trunk/framework/webslinger/src/org/ofbiz: commons/vfs/ commons/vfs/ofbiz/ webslinger/
Posted by Jacques Le Roux <ja...@les7arts.com>.
Sorry Scott,
I have still not got the reflex... As I have not touched the patch (ok you have to trust me) you may review the patch itself...
Jacques
From: "Scott Gray" <sc...@hotwaxmedia.com>
> Hi Jacques,
>
> This is that same problem with the patch again, please keep an eye out for these as the commits are impossible to review.
>
> Thanks
> Scott
>
> HotWax Media
> http://www.hotwaxmedia.com
>
> On 8/11/2009, at 7:18 AM, jleroux@apache.org wrote:
>
>> Author: jleroux
>> Date: Sat Nov 7 18:18:33 2009
>> New Revision: 833727
>>
>> URL: http://svn.apache.org/viewvc?rev=833727&view=rev
>> Log:
>> A patch from Marc Morin "Resolve java warnings exposed in Eclipse : framework - webslinger"
>> (https://issues.apache.org/jira/browse/OFBIZ-3121 ) - OFBIZ-3121
>>
>> Modified:
>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ CommonsVfsContainer.java
>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/ OfbizComponentProvider.java
>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/ OfbizHomeProvider.java
>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ EntityHttpUtil.java
>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ StatsUpdater.java
>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerContextMapper.java
>> ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerServerEngine.java
>>
>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ CommonsVfsContainer.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/CommonsVfsContainer.java?rev=833727&r1=833726&r2=833727&view=diff
>> = = = = = = = = ======================================================================
>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ CommonsVfsContainer.java (original)
>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ CommonsVfsContainer.java Sat Nov 7 18:18:33 2009
>> @@ -1,68 +1,66 @@
>> -/ *******************************************************************************
>> - * 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.commons.vfs;
>> -
>> -import java.io.File;
>> -import java.io.IOException;
>> -import java.net.MalformedURLException;
>> -
>> -import org.apache.commons.vfs.CacheStrategy;
>> -import org.apache.commons.vfs.FileObject;
>> -import org.apache.commons.vfs.FileSystemException;
>> -import org.apache.commons.vfs.FileSystemManager;
>> -import org.apache.commons.vfs.impl.StandardFileSystemManager;
>> -
>> -import org.ofbiz.base.container.Container;
>> -import org.ofbiz.base.container.ContainerException;
>> -import org.ofbiz.base.util.UtilMisc;
>> -import org.webslinger.commons.vfs.VFSUtil;
>> -
>> -public class CommonsVfsContainer implements Container {
>> - private static StandardFileSystemManager sfsm;
>> -
>> - public void init(String[] args, String configFile) throws ContainerException {
>> - }
>> -
>> - public boolean start() throws ContainerException {
>> - try {
>> - StandardFileSystemManager sfsm = VFSUtil.createStandardFileSystemManager();
>> - FileObject currentDir = sfsm.resolveFile(new File(".").toURI().toURL().toString());
>> - sfsm.setBaseFile(currentDir);
>> - CommonsVfsContainer.sfsm = sfsm;
>> - } catch (FileSystemException e) {
>> - throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
>> - } catch (MalformedURLException e) {
>> - throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
>> - }
>> - return true;
>> - }
>> -
>> - public void stop() throws ContainerException {
>> - sfsm.close();
>> - sfsm = null;
>> - }
>> -
>> - public static FileObject resolveFile(String uri) throws IOException {
>> - return sfsm.resolveFile(uri);
>> - }
>> -
>> - public static FileSystemManager getFileSystemManager() {
>> - return sfsm;
>> - }
>> -}
>> +/ *******************************************************************************
>> + * 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.commons.vfs;
>> +
>> +import java.io.File;
>> +import java.io.IOException;
>> +import java.net.MalformedURLException;
>> +
>> +import org.apache.commons.vfs.FileObject;
>> +import org.apache.commons.vfs.FileSystemException;
>> +import org.apache.commons.vfs.FileSystemManager;
>> +import org.apache.commons.vfs.impl.StandardFileSystemManager;
>> +import org.ofbiz.base.container.Container;
>> +import org.ofbiz.base.container.ContainerException;
>> +import org.ofbiz.base.util.UtilMisc;
>> +import org.webslinger.commons.vfs.VFSUtil;
>> +
>> +public class CommonsVfsContainer implements Container {
>> + private static StandardFileSystemManager sfsm;
>> +
>> + public void init(String[] args, String configFile) throws ContainerException {
>> + }
>> +
>> + public boolean start() throws ContainerException {
>> + try {
>> + StandardFileSystemManager sfsm = VFSUtil.createStandardFileSystemManager();
>> + FileObject currentDir = sfsm.resolveFile(new File(".").toURI().toURL().toString());
>> + sfsm.setBaseFile(currentDir);
>> + CommonsVfsContainer.sfsm = sfsm;
>> + } catch (FileSystemException e) {
>> + throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
>> + } catch (MalformedURLException e) {
>> + throw UtilMisc.initCause(new ContainerException("Initializing StandardFileSystemManager"), e);
>> + }
>> + return true;
>> + }
>> +
>> + public void stop() throws ContainerException {
>> + sfsm.close();
>> + sfsm = null;
>> + }
>> +
>> + public static FileObject resolveFile(String uri) throws IOException {
>> + return sfsm.resolveFile(uri);
>> + }
>> +
>> + public static FileSystemManager getFileSystemManager() {
>> + return sfsm;
>> + }
>> +}
>>
>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/OfbizComponentProvider.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizComponentProvider.java?rev=833727&r1=833726&r2=833727&view=diff
>> = = = = = = = = ======================================================================
>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/ OfbizComponentProvider.java (original)
>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/ OfbizComponentProvider.java Sat Nov 7 18:18:33 2009
>> @@ -1,58 +1,58 @@
>> -/ *******************************************************************************
>> - * 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.commons.vfs.ofbiz;
>> -
>> -import java.net.URL;
>> -import java.util.Collection;
>> -import org.apache.commons.vfs.FileObject;
>> -import org.apache.commons.vfs.FileSystemException;
>> -import org.apache.commons.vfs.FileSystemOptions;
>> -import org.apache.commons.vfs.provider.AbstractFileProvider;
>> -import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>> -import org.ofbiz.base.location.FlexibleLocation;
>> -import org.ofbiz.base.util.UtilMisc;
>> -import org.webslinger.commons.vfs.VFSUtil;
>> -
>> -public class OfbizComponentProvider extends AbstractFileProvider {
>> - public Collection getCapabilities() {
>> - return DefaultLocalFileProvider.capabilities;
>> - }
>> -
>> - public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
>> - try {
>> - //name = name.replaceAll("^ofbiz-component://", "");
>> - int nameLength = name.length();
>> - int componentNameStart = 16;
>> - while (componentNameStart < nameLength && name.charAt(componentNameStart) == '/') componentNameStart++;
>> - if (componentNameStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>> - int componentNameEnd = componentNameStart;
>> - while (componentNameEnd < nameLength && name.charAt(componentNameEnd) != '/') componentNameEnd++;
>> - if (componentNameEnd == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>> - int restStart = componentNameEnd;
>> - while (restStart < nameLength && name.charAt(restStart) == '/') restStart++;
>> - if (restStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>> - String componentName = name.substring(componentNameStart, componentNameEnd);
>> - URL location = FlexibleLocation.resolveLocation("component://" + componentName + "/.");
>> - FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
>> - return VFSUtil .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase
>> .resolveFile(name.substring(restStart)).getURL().toString(), properties);
>> - } catch (Exception e) {
>> - throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
>> - }
>> - }
>> -}
>> +/ *******************************************************************************
>> + * 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.commons.vfs.ofbiz;
>> +
>> +import java.net.URL;
>> +import java.util.Collection;
>> +import org.apache.commons.vfs.FileObject;
>> +import org.apache.commons.vfs.FileSystemException;
>> +import org.apache.commons.vfs.FileSystemOptions;
>> +import org.apache.commons.vfs.provider.AbstractFileProvider;
>> +import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>> +import org.ofbiz.base.location.FlexibleLocation;
>> +import org.ofbiz.base.util.UtilMisc;
>> +import org.webslinger.commons.vfs.VFSUtil;
>> +
>> +public class OfbizComponentProvider extends AbstractFileProvider {
>> + public Collection<?> getCapabilities() {
>> + return DefaultLocalFileProvider.capabilities;
>> + }
>> +
>> + public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
>> + try {
>> + //name = name.replaceAll("^ofbiz-component://", "");
>> + int nameLength = name.length();
>> + int componentNameStart = 16;
>> + while (componentNameStart < nameLength && name.charAt(componentNameStart) == '/') componentNameStart++;
>> + if (componentNameStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>> + int componentNameEnd = componentNameStart;
>> + while (componentNameEnd < nameLength && name.charAt(componentNameEnd) != '/') componentNameEnd++;
>> + if (componentNameEnd == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>> + int restStart = componentNameEnd;
>> + while (restStart < nameLength && name.charAt(restStart) == '/') restStart++;
>> + if (restStart == nameLength) throw new IllegalArgumentException("Invalid name(" + name + ")");
>> + String componentName = name.substring(componentNameStart, componentNameEnd);
>> + URL location = FlexibleLocation.resolveLocation("component://" + componentName + "/.");
>> + FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
>> + return VFSUtil .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(), ofbizBase
>> .resolveFile(name.substring(restStart)).getURL().toString(), properties);
>> + } catch (Exception e) {
>> + throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
>> + }
>> + }
>> +}
>>
>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ ofbiz/OfbizHomeProvider.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/OfbizHomeProvider.java?rev=833727&r1=833726&r2=833727&view=diff
>> = = = = = = = = ======================================================================
>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/ OfbizHomeProvider.java (original)
>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/commons/vfs/ofbiz/ OfbizHomeProvider.java Sat Nov 7 18:18:33 2009
>> @@ -1,50 +1,50 @@
>> -/ *******************************************************************************
>> - * 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.commons.vfs.ofbiz;
>> -
>> -import java.net.URL;
>> -import java.util.Collection;
>> -
>> -import org.apache.commons.vfs.FileObject;
>> -import org.apache.commons.vfs.FileSystemException;
>> -import org.apache.commons.vfs.FileSystemOptions;
>> -import org.apache.commons.vfs.provider.AbstractFileProvider;
>> -import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>> -
>> -import org.ofbiz.base.location.FlexibleLocation;
>> -import org.ofbiz.base.util.UtilMisc;
>> -
>> -import org.webslinger.commons.vfs.VFSUtil;
>> -
>> -public class OfbizHomeProvider extends AbstractFileProvider {
>> - public Collection getCapabilities() {
>> - return DefaultLocalFileProvider.capabilities;
>> - }
>> -
>> - public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
>> - //new Exception("findFile(" + base + ", " + name + ")").printStackTrace();
>> - try {
>> - URL location = FlexibleLocation.resolveLocation("ofbizhome://.");
>> - FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
>> - return VFSUtil .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
>> ofbizBase.resolveFile(name.substring(13)).getURL().toString(), properties);
>> - } catch (Exception e) {
>> - throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
>> - }
>> - }
>> -}
>> +/ *******************************************************************************
>> + * 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.commons.vfs.ofbiz;
>> +
>> +import java.net.URL;
>> +import java.util.Collection;
>> +
>> +import org.apache.commons.vfs.FileObject;
>> +import org.apache.commons.vfs.FileSystemException;
>> +import org.apache.commons.vfs.FileSystemOptions;
>> +import org.apache.commons.vfs.provider.AbstractFileProvider;
>> +import org.apache.commons.vfs.provider.local.DefaultLocalFileProvider;
>> +
>> +import org.ofbiz.base.location.FlexibleLocation;
>> +import org.ofbiz.base.util.UtilMisc;
>> +
>> +import org.webslinger.commons.vfs.VFSUtil;
>> +
>> +public class OfbizHomeProvider extends AbstractFileProvider {
>> + public Collection<?> getCapabilities() {
>> + return DefaultLocalFileProvider.capabilities;
>> + }
>> +
>> + public FileObject findFile(FileObject base, String name, FileSystemOptions properties) throws FileSystemException {
>> + //new Exception("findFile(" + base + ", " + name + ")").printStackTrace();
>> + try {
>> + URL location = FlexibleLocation.resolveLocation("ofbizhome://.");
>> + FileObject ofbizBase = getContext().resolveFile(location.toString(), properties);
>> + return VFSUtil .toFileObject(ofbizBase.getFileSystem().getFileSystemManager(),
>> ofbizBase.resolveFile(name.substring(13)).getURL().toString(), properties);
>> + } catch (Exception e) {
>> + throw UtilMisc.initCause(new FileSystemException(e.getMessage(), null, e), e);
>> + }
>> + }
>> +}
>>
>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ EntityHttpUtil.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/EntityHttpUtil.java?rev=833727&r1=833726&r2=833727&view=diff
>> = = = = = = = = ======================================================================
>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ EntityHttpUtil.java (original)
>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ EntityHttpUtil.java Sat Nov 7 18:18:33 2009
>> @@ -1,78 +1,73 @@
>> -/ *******************************************************************************
>> - * 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.webslinger;
>> -
>> -import java.util.HashMap;
>> -import java.util.Iterator;
>> -import java.util.Locale;
>> -import java.util.Map;
>> -
>> -import javax.servlet.ServletRequest;
>> -import javax.servlet.http.HttpServletRequest;
>> -
>> -import org.ofbiz.base.util.GeneralException;
>> -import org.ofbiz.base.util.ObjectType;
>> -import org.ofbiz.base.util.UtilHttp;
>> -import org.ofbiz.base.util.UtilMisc;
>> -import org.ofbiz.base.util.UtilValidate;
>> -import org.ofbiz.entity.Delegator;
>> -import org.ofbiz.entity.GenericValue;
>> -import org.ofbiz.entity.jdbc.SqlJdbcUtil;
>> -import org.ofbiz.entity.model.ModelEntity;
>> -import org.ofbiz.entity.model.ModelField;
>> -import org.ofbiz.entity.model.ModelFieldType;
>> -
>> -public class EntityHttpUtil {
>> - public static GenericValue makeValidValue(String entityName, ServletRequest request) throws GeneralException {
>> - return makeValidValue(entityName, false, request);
>> - }
>> -
>> - public static GenericValue makeValidValue(String entityName, boolean includePks, ServletRequest request) throws
>> GeneralException {
>> - if (request instanceof HttpServletRequest) return makeValidValue(entityName, includePks, (HttpServletRequest) request);
>> - throw new IllegalArgumentException("Not an HttpServletRequest");
>> - }
>> -
>> - public static GenericValue makeValidValue(String entityName, HttpServletRequest request) throws GeneralException {
>> - return makeValidValue(entityName, false, request);
>> - }
>> -
>> - public static GenericValue makeValidValue(String entityName, boolean includePks, HttpServletRequest request) throws
>> GeneralException {
>> - Delegator delegator = (Delegator) request.getAttribute("delegator");
>> - GenericValue value = delegator.makeValue(entityName);
>> - ModelEntity model = value.getModelEntity();
>> - Iterator<ModelField> it = includePks ? model.getFieldsIterator() : model.getNopksIterator();
>> - Locale locale = UtilHttp.getLocale(request);
>> - while (it.hasNext()) {
>> - ModelField field = it.next();
>> - String fieldName = field.getName();
>> - String parameterValue = request.getParameter(fieldName);
>> - Object fieldValue;
>> - if (parameterValue == null) {
>> - fieldValue = null;
>> - } else {
>> - ModelFieldType fieldType = delegator.getEntityFieldType(model, field.getType());
>> - String wantedType = fieldType.getJavaType();
>> - fieldValue = ObjectType.simpleTypeConvert(parameterValue, wantedType, null, locale, true);
>> - }
>> - value.put(fieldName, fieldValue);
>> - }
>> - return value;
>> - }
>> -}
>> -
>> +/ *******************************************************************************
>> + * 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.webslinger;
>> +
>> +import java.util.Iterator;
>> +import java.util.Locale;
>> +
>> +import javax.servlet.ServletRequest;
>> +import javax.servlet.http.HttpServletRequest;
>> +
>> +import org.ofbiz.base.util.GeneralException;
>> +import org.ofbiz.base.util.ObjectType;
>> +import org.ofbiz.base.util.UtilHttp;
>> +import org.ofbiz.entity.Delegator;
>> +import org.ofbiz.entity.GenericValue;
>> +import org.ofbiz.entity.model.ModelEntity;
>> +import org.ofbiz.entity.model.ModelField;
>> +import org.ofbiz.entity.model.ModelFieldType;
>> +
>> +public class EntityHttpUtil {
>> + public static GenericValue makeValidValue(String entityName, ServletRequest request) throws GeneralException {
>> + return makeValidValue(entityName, false, request);
>> + }
>> +
>> + public static GenericValue makeValidValue(String entityName, boolean includePks, ServletRequest request) throws
>> GeneralException {
>> + if (request instanceof HttpServletRequest) return makeValidValue(entityName, includePks, (HttpServletRequest) request);
>> + throw new IllegalArgumentException("Not an HttpServletRequest");
>> + }
>> +
>> + public static GenericValue makeValidValue(String entityName, HttpServletRequest request) throws GeneralException {
>> + return makeValidValue(entityName, false, request);
>> + }
>> +
>> + public static GenericValue makeValidValue(String entityName, boolean includePks, HttpServletRequest request) throws
>> GeneralException {
>> + Delegator delegator = (Delegator) request.getAttribute("delegator");
>> + GenericValue value = delegator.makeValue(entityName);
>> + ModelEntity model = value.getModelEntity();
>> + Iterator<ModelField> it = includePks ? model.getFieldsIterator() : model.getNopksIterator();
>> + Locale locale = UtilHttp.getLocale(request);
>> + while (it.hasNext()) {
>> + ModelField field = it.next();
>> + String fieldName = field.getName();
>> + String parameterValue = request.getParameter(fieldName);
>> + Object fieldValue;
>> + if (parameterValue == null) {
>> + fieldValue = null;
>> + } else {
>> + ModelFieldType fieldType = delegator.getEntityFieldType(model, field.getType());
>> + String wantedType = fieldType.getJavaType();
>> + fieldValue = ObjectType.simpleTypeConvert(parameterValue, wantedType, null, locale, true);
>> + }
>> + value.put(fieldName, fieldValue);
>> + }
>> + return value;
>> + }
>> +}
>> +
>>
>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ StatsUpdater.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/StatsUpdater.java?rev=833727&r1=833726&r2=833727&view=diff
>> = = = = = = = = ======================================================================
>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ StatsUpdater.java (original)
>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ StatsUpdater.java Sat Nov 7 18:18:33 2009
>> @@ -1,121 +1,118 @@
>> -/ *******************************************************************************
>> - * 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.webslinger;
>> -
>> -import java.util.HashMap;
>> -import java.util.Iterator;
>> -import java.util.Map;
>> -import java.util.concurrent.Callable;
>> -import java.util.concurrent.ConcurrentHashMap;
>> -import java.util.concurrent.ScheduledFuture;
>> -import java.util.concurrent.TimeUnit;
>> -import java.util.concurrent.atomic.AtomicReference;
>> -
>> -import org.ofbiz.base.util.UtilMisc;
>> -import org.ofbiz.entity.Delegator;
>> -import org.ofbiz.entity.GenericEntityException;
>> -import org.ofbiz.entity.GenericPK;
>> -import org.ofbiz.entity.GenericValue;
>> -
>> -import org.webslinger.cache.ConcurrentCache;
>> -import org.webslinger.concurrent.ExecutionPool;
>> -
>> -public class StatsUpdater {
>> - private static final Updater UPDATER = new Updater();
>> -
>> - public static void updateStats(Delegator delegator, String entityName, Map<String, ? extends Object> keyFields, Map<String,
>> ? extends Long> updateCountFields) throws GenericEntityException {
>> - GenericPK pk = delegator.makePK(entityName, keyFields);
>> - Map<String, Long> value = UPDATER.getValue(pk);
>> - synchronized (value) {
>> - for (Map.Entry<String, ? extends Long> entry: updateCountFields.entrySet()) {
>> - Long oldValue = value.get(entry.getKey());
>> - if (oldValue != null) {
>> - value.put(entry.getKey(), Long.valueOf(oldValue.longValue() + entry.getValue()));
>> - } else {
>> - value.put(entry.getKey(), entry.getValue());
>> - }
>> - }
>> - }
>> - }
>> -
>> - private static final class Updater implements Callable<Void> {
>> - protected AtomicReference<EntityHolder> entities = new AtomicReference<EntityHolder>(new EntityHolder(Updater.class,
>> "entities", null));
>> - protected ScheduledFuture<Void> future;
>> -
>> - protected Map<String, Long> getValue(GenericPK pk) throws GenericEntityException {
>> - synchronized (this) {
>> - if (future == null || future.isDone()) {
>> - future = ExecutionPool.schedule(this, 1, TimeUnit.SECONDS);
>> - }
>> - }
>> - try {
>> - return entities.get().get(pk);
>> - } catch (RuntimeException e) {
>> - throw e;
>> - } catch (GenericEntityException e) {
>> - throw e;
>> - } catch (Exception e) {
>> - throw UtilMisc.initCause(new GenericEntityException(e.getMessage()), e);
>> - }
>> - }
>> -
>> - public Void call() {
>> - EntityHolder oldEntities;
>> - EntityHolder newEntities = new EntityHolder(Updater.class, "entities", null);
>> - do {
>> - oldEntities = entities.get();
>> - } while (!entities.compareAndSet(oldEntities, newEntities));
>> - synchronized (Updater.class) {
>> - for (GenericPK pk: oldEntities.keys()) {
>> - try {
>> - Map<String, Long> add = oldEntities.get(pk);
>> - GenericValue existing = pk.getDelegator().findOne(pk.getEntityName(), pk, false);
>> - if (existing == null) {
>> - existing = pk.getDelegator().create(pk.getEntityName(), pk);
>> - }
>> - for (Map.Entry<String, Long> entry: add.entrySet()) {
>> - Long value = entry.getValue();
>> - Long oldValue = existing.getLong(entry.getKey());
>> - if (oldValue != null) {
>> - existing.put(entry.getKey(), Long.valueOf(value.longValue() + oldValue.longValue()));
>> - } else {
>> - existing.put(entry.getKey(), value);
>> - }
>> - }
>> - existing.store();
>> - } catch (Exception e) {
>> - e.printStackTrace();
>> - }
>> - }
>> - }
>> - return null;
>> - }
>> - }
>> -
>> - private static final class EntityHolder extends ConcurrentCache<GenericPK, Map<String, Long>> {
>> - protected EntityHolder(Class<?> owner, String field, String label) {
>> - super(owner, field, label, HARD);
>> - }
>> -
>> - @Override
>> - protected Map<String, Long> createValue(GenericPK pk) throws Exception {
>> - return new HashMap<String, Long>();
>> - }
>> - }
>> -}
>> +/ *******************************************************************************
>> + * 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.webslinger;
>> +
>> +import java.util.HashMap;
>> +import java.util.Map;
>> +import java.util.concurrent.Callable;
>> +import java.util.concurrent.ScheduledFuture;
>> +import java.util.concurrent.TimeUnit;
>> +import java.util.concurrent.atomic.AtomicReference;
>> +
>> +import org.ofbiz.base.util.UtilMisc;
>> +import org.ofbiz.entity.Delegator;
>> +import org.ofbiz.entity.GenericEntityException;
>> +import org.ofbiz.entity.GenericPK;
>> +import org.ofbiz.entity.GenericValue;
>> +import org.webslinger.cache.ConcurrentCache;
>> +import org.webslinger.concurrent.ExecutionPool;
>> +
>> +public class StatsUpdater {
>> + private static final Updater UPDATER = new Updater();
>> +
>> + public static void updateStats(Delegator delegator, String entityName, Map<String, ? extends Object> keyFields, Map<String,
>> ? extends Long> updateCountFields) throws GenericEntityException {
>> + GenericPK pk = delegator.makePK(entityName, keyFields);
>> + Map<String, Long> value = UPDATER.getValue(pk);
>> + synchronized (value) {
>> + for (Map.Entry<String, ? extends Long> entry: updateCountFields.entrySet()) {
>> + Long oldValue = value.get(entry.getKey());
>> + if (oldValue != null) {
>> + value.put(entry.getKey(), Long.valueOf(oldValue.longValue() + entry.getValue()));
>> + } else {
>> + value.put(entry.getKey(), entry.getValue());
>> + }
>> + }
>> + }
>> + }
>> +
>> + private static final class Updater implements Callable<Void> {
>> + protected AtomicReference<EntityHolder> entities = new AtomicReference<EntityHolder>(new EntityHolder(Updater.class,
>> "entities", null));
>> + protected ScheduledFuture<Void> future;
>> +
>> + protected Map<String, Long> getValue(GenericPK pk) throws GenericEntityException {
>> + synchronized (this) {
>> + if (future == null || future.isDone()) {
>> + future = ExecutionPool.schedule(this, 1, TimeUnit.SECONDS);
>> + }
>> + }
>> + try {
>> + return entities.get().get(pk);
>> + } catch (RuntimeException e) {
>> + throw e;
>> + } catch (GenericEntityException e) {
>> + throw e;
>> + } catch (Exception e) {
>> + throw UtilMisc.initCause(new GenericEntityException(e.getMessage()), e);
>> + }
>> + }
>> +
>> + public Void call() {
>> + EntityHolder oldEntities;
>> + EntityHolder newEntities = new EntityHolder(Updater.class, "entities", null);
>> + do {
>> + oldEntities = entities.get();
>> + } while (!entities.compareAndSet(oldEntities, newEntities));
>> + synchronized (Updater.class) {
>> + for (GenericPK pk: oldEntities.keys()) {
>> + try {
>> + Map<String, Long> add = oldEntities.get(pk);
>> + GenericValue existing = pk.getDelegator().findOne(pk.getEntityName(), pk, false);
>> + if (existing == null) {
>> + existing = pk.getDelegator().create(pk.getEntityName(), pk);
>> + }
>> + for (Map.Entry<String, Long> entry: add.entrySet()) {
>> + Long value = entry.getValue();
>> + Long oldValue = existing.getLong(entry.getKey());
>> + if (oldValue != null) {
>> + existing.put(entry.getKey(), Long.valueOf(value.longValue() + oldValue.longValue()));
>> + } else {
>> + existing.put(entry.getKey(), value);
>> + }
>> + }
>> + existing.store();
>> + } catch (Exception e) {
>> + e.printStackTrace();
>> + }
>> + }
>> + }
>> + return null;
>> + }
>> + }
>> +
>> + private static final class EntityHolder extends ConcurrentCache<GenericPK, Map<String, Long>> {
>> + protected EntityHolder(Class<?> owner, String field, String label) {
>> + super(owner, field, label, HARD);
>> + }
>> +
>> + @Override
>> + protected Map<String, Long> createValue(GenericPK pk) throws Exception {
>> + return new HashMap<String, Long>();
>> + }
>> + }
>> +}
>>
>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerContextMapper.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java?rev=833727&r1=833726&r2=833727&view=diff
>> = = = = = = = = ======================================================================
>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerContextMapper.java (original)
>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerContextMapper.java Sat Nov 7 18:18:33 2009
>> @@ -1,218 +1,216 @@
>> -/ *******************************************************************************
>> - * 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.webslinger;
>> -
>> -import java.io.IOException;
>> -import java.net.URL;
>> -import java.util.ArrayList;
>> -import java.util.Arrays;
>> -import java.util.HashSet;
>> -import java.util.List;
>> -import java.util.Set;
>> -
>> -import javax.servlet.ServletConfig;
>> -import javax.servlet.ServletContext;
>> -import javax.servlet.ServletException;
>> -import javax.servlet.http.HttpServletRequest;
>> -
>> -import org.ofbiz.base.util.UtilMisc;
>> -import org.ofbiz.base.util.UtilProperties;
>> -import org.ofbiz.entity.Delegator;
>> -import org.ofbiz.entity.DelegatorFactory;
>> -import org.ofbiz.entity.GenericEntityException;
>> -import org.ofbiz.entity.GenericValue;
>> -import org.ofbiz.entity.cache.Cache;
>> -import org.ofbiz.entity.util.EntityUtil;
>> -import org.ofbiz.security.SecurityFactory;
>> -import org.ofbiz.security.authz.AuthorizationFactory;
>> -import org.ofbiz.service.GenericDispatcher;
>> -import org.ofbiz.service.LocalDispatcher;
>> -import org.ofbiz.service.ServiceDispatcher;
>> -import org.ofbiz.service.DispatchContext;
>> -
>> -import org.webslinger.AbstractMappingWebslingerServletContextFactory;
>> -import org.webslinger.WebslingerServletContext;
>> -import org.webslinger.collections.CollectionUtil;
>> -import org.webslinger.lang.ObjectUtil;
>> -
>> -public class WebslingerContextMapper extends AbstractMappingWebslingerServletContextFactory {
>> - protected ServletContext servletContext;
>> - protected Delegator delegator;
>> - protected final ArrayList<URL> globalReaderURLs = new ArrayList<URL>();
>> -
>> - public void init(ServletConfig config) throws ServletException, IOException {
>> - System .err.println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
>> - servletContext = config.getServletContext();
>> - String delegatorName = servletContext.getInitParameter("entityDelegatorName");
>> - delegator = DelegatorFactory.getDelegator(delegatorName);
>> - String readerFiles = servletContext.getInitParameter("serviceReaderUrls");
>> - if (readerFiles != null) {
>> - for (String reader: CollectionUtil.split(readerFiles, ";")) {
>> - URL url = config.getServletContext().getResource(reader);
>> - if (url != null) globalReaderURLs.add(url);
>> - }
>> - }
>> - super.init(config, UtilProperties.getPropertyValue("webslinger.properties", "moduleBase"));
>> - }
>> -
>> - @Override
>> - protected Layout[] getStartLayouts() throws Exception {
>> - ArrayList<Layout> layouts = new ArrayList<Layout>();
>> - try {
>> - for (GenericValue value: delegator.findByAnd("WebslingerServer", UtilMisc.toMap("loadAtStart", "Y"))) {
>> - layouts.add(new OfbizLayout(value));
>> - }
>> - } catch (GenericEntityException e) {
>> - }
>> - return layouts.toArray(new Layout[layouts.size()]);
>> - }
>> -
>> - @Override
>> - public void initializeRequest(WebslingerServletContext context, HttpServletRequest request) {
>> - request.setAttribute("servletContext", context);
>> - Object delegator = context.getAttribute("delegator");
>> - Object dispatcher = context.getAttribute("dispatcher");
>> - Object authz = context.getAttribute("authz");
>> - Object security = context.getAttribute("security");
>> - request.setAttribute("delegator", delegator);
>> - request.setAttribute("dispatcher", dispatcher);
>> - request.setAttribute("authz", authz);
>> - request.setAttribute("security", security);
>> - // FIXME!!! These next two are a hack until proper fake/ wrapped session support is done in webslinger
>> - servletContext.setAttribute("delegator", delegator);
>> - servletContext.setAttribute("dispatcher", dispatcher);
>> - servletContext.setAttribute("authz", authz);
>> - servletContext.setAttribute("security", security);
>> - }
>> -
>> - @Override
>> - protected void initializeContext(WebslingerServletContext context, Layout layout) throws Exception {
>> - OfbizLayout ofbizLayout = (OfbizLayout) layout;
>> - Delegator delegator = null;
>> - delegator = DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
>> - context.setAttribute("delegator", delegator);
>> - context.setAttribute("dispatcher", new WebslingerGenericDispatcher(context, layout.getTarget(), delegator,
>> globalReaderURLs));
>> - context.setAttribute("authz", AuthorizationFactory.getInstance(delegator));
>> - context.setAttribute("security", SecurityFactory.getInstance(delegator));
>> - }
>> -
>> - protected static final class WebslingerGenericDispatcher extends GenericDispatcher {
>> - protected WebslingerGenericDispatcher(WebslingerServletContext context, String name, Delegator delegator, List<URL>
>> globalReaderURLs) throws IOException {
>> - ArrayList<URL> readerURLs = new ArrayList<URL>(globalReaderURLs);
>> - String readerFiles = context.getInitParameter("serviceReaderUrls");
>> - if (readerFiles != null) {
>> - for (String reader: CollectionUtil.split(readerFiles, ";")) {
>> - URL url = context.getResource(reader);
>> - if (url != null) readerURLs.add(url);
>> - }
>> - }
>> - System.err.println(readerURLs);
>> - this.dispatcher = new ServiceDispatcher(delegator, true, true, true) {
>> - };
>> - ClassLoader loader = null;
>> - try {
>> - loader = Thread.currentThread().getContextClassLoader();
>> - } catch (SecurityException e) {
>> - loader = WebslingerContextMapper.class.getClassLoader();
>> - }
>> - DispatchContext dc = new DispatchContext(name, readerURLs, loader, null);
>> - init(name, delegator, dc);
>> - }
>> - }
>> -
>> - @Override
>> - protected Set<String> getSuffixes() throws Exception {
>> - Cache cache = delegator.getCache();
>> - Set<String> suffixes;
>> - synchronized (WebslingerContextMapper.class) {
>> - suffixes = cache.get("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes");
>> - if (suffixes == null) {
>> - suffixes = new HashSet<String>();
>> - for (GenericValue value: delegator.findList("WebslingerHostSuffix", null, null, null, null, false)) {
>> - suffixes.add(value.getString("hostSuffix"));
>> - }
>> - cache.put("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes", suffixes);
>> - }
>> - }
>> - return suffixes;
>> - }
>> -
>> - @Override
>> - protected Layout lookupLayout(String hostName, String contextPath) throws Exception {
>> - GenericValue layout = EntityUtil.getOnly(delegator.findByAndCache("WebslingerLayout", UtilMisc.toMap("hostName",
>> hostName, "contextPath", contextPath)));
>> - if (layout == null) return null;
>> - return new OfbizLayout(layout);
>> - }
>> -
>> - protected class OfbizLayout implements Layout {
>> - private final String contextPath;
>> - private final String id;
>> - private final String target;
>> - private final String[] bases;
>> - private final int hashCode;
>> - protected final String delegatorName;
>> - protected final String dispatcherName;
>> -
>> - protected OfbizLayout(GenericValue server) throws GenericEntityException {
>> - contextPath = server.getString("contextPath");
>> - id = server.getString("webslingerServerId");
>> - target = server.getString("target");
>> - List<GenericValue> baseValues = server.getRelatedCache("WebslingerServerBase", UtilMisc.toList("seqNum"));
>> - bases = new String[baseValues.size()];
>> - for (int i = 0; i < bases.length; i++) {
>> - GenericValue baseValue = baseValues.get(i);
>> - bases[i] = baseValue.getString("baseName");
>> - }
>> - delegatorName = server.getString("delegatorName");
>> - dispatcherName = server.getString("dispatcherName");
>> - hashCode = target.hashCode() ^ ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
>> - }
>> -
>> - public String getContextPath() {
>> - return contextPath;
>> - }
>> -
>> - public String getId() {
>> - return id;
>> - }
>> -
>> - public String getTarget() {
>> - return target;
>> - }
>> -
>> - public String[] getBases() {
>> - return bases;
>> - }
>> -
>> - @Override
>> - public int hashCode() {
>> - return hashCode;
>> - }
>> -
>> - @Override
>> - public boolean equals(Object o) {
>> - if (!(o instanceof OfbizLayout)) return false;
>> - OfbizLayout other = (OfbizLayout) o;
>> - if (!contextPath.equals(other.contextPath)) return false;
>> - if (!target.equals(other.target)) return false;
>> - if (!ObjectUtil.equalsHelper(delegatorName, other.delegatorName)) return false;
>> - return Arrays.equals(bases, other.bases);
>> - }
>> - }
>> -}
>> +/ *******************************************************************************
>> + * 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.webslinger;
>> +
>> +import java.io.IOException;
>> +import java.net.URL;
>> +import java.util.ArrayList;
>> +import java.util.Arrays;
>> +import java.util.HashSet;
>> +import java.util.List;
>> +import java.util.Set;
>> +
>> +import javax.servlet.ServletConfig;
>> +import javax.servlet.ServletContext;
>> +import javax.servlet.ServletException;
>> +import javax.servlet.http.HttpServletRequest;
>> +
>> +import org.ofbiz.base.util.UtilMisc;
>> +import org.ofbiz.base.util.UtilProperties;
>> +import org.ofbiz.entity.Delegator;
>> +import org.ofbiz.entity.DelegatorFactory;
>> +import org.ofbiz.entity.GenericEntityException;
>> +import org.ofbiz.entity.GenericValue;
>> +import org.ofbiz.entity.cache.Cache;
>> +import org.ofbiz.entity.util.EntityUtil;
>> +import org.ofbiz.security.SecurityFactory;
>> +import org.ofbiz.security.authz.AuthorizationFactory;
>> +import org.ofbiz.service.DispatchContext;
>> +import org.ofbiz.service.GenericDispatcher;
>> +import org.ofbiz.service.ServiceDispatcher;
>> +import org.webslinger.AbstractMappingWebslingerServletContextFactory;
>> +import org.webslinger.WebslingerServletContext;
>> +import org.webslinger.collections.CollectionUtil;
>> +import org.webslinger.lang.ObjectUtil;
>> +
>> +public class WebslingerContextMapper extends AbstractMappingWebslingerServletContextFactory {
>> + protected ServletContext servletContext;
>> + protected Delegator delegator;
>> + protected final ArrayList<URL> globalReaderURLs = new ArrayList<URL>();
>> +
>> + public void init(ServletConfig config) throws ServletException, IOException {
>> + System .err.println(org.webslinger.commons.vfs.flat.FlatFileProvider.class);
>> + servletContext = config.getServletContext();
>> + String delegatorName = servletContext.getInitParameter("entityDelegatorName");
>> + delegator = DelegatorFactory.getDelegator(delegatorName);
>> + String readerFiles = servletContext.getInitParameter("serviceReaderUrls");
>> + if (readerFiles != null) {
>> + for (String reader: CollectionUtil.split(readerFiles, ";")) {
>> + URL url = config.getServletContext().getResource(reader);
>> + if (url != null) globalReaderURLs.add(url);
>> + }
>> + }
>> + super.init(config, UtilProperties.getPropertyValue("webslinger.properties", "moduleBase"));
>> + }
>> +
>> + @Override
>> + protected Layout[] getStartLayouts() throws Exception {
>> + ArrayList<Layout> layouts = new ArrayList<Layout>();
>> + try {
>> + for (GenericValue value: delegator.findByAnd("WebslingerServer", UtilMisc.toMap("loadAtStart", "Y"))) {
>> + layouts.add(new OfbizLayout(value));
>> + }
>> + } catch (GenericEntityException e) {
>> + }
>> + return layouts.toArray(new Layout[layouts.size()]);
>> + }
>> +
>> + @Override
>> + public void initializeRequest(WebslingerServletContext context, HttpServletRequest request) {
>> + request.setAttribute("servletContext", context);
>> + Object delegator = context.getAttribute("delegator");
>> + Object dispatcher = context.getAttribute("dispatcher");
>> + Object authz = context.getAttribute("authz");
>> + Object security = context.getAttribute("security");
>> + request.setAttribute("delegator", delegator);
>> + request.setAttribute("dispatcher", dispatcher);
>> + request.setAttribute("authz", authz);
>> + request.setAttribute("security", security);
>> + // FIXME!!! These next two are a hack until proper fake/ wrapped session support is done in webslinger
>> + servletContext.setAttribute("delegator", delegator);
>> + servletContext.setAttribute("dispatcher", dispatcher);
>> + servletContext.setAttribute("authz", authz);
>> + servletContext.setAttribute("security", security);
>> + }
>> +
>> + @Override
>> + protected void initializeContext(WebslingerServletContext context, Layout layout) throws Exception {
>> + OfbizLayout ofbizLayout = (OfbizLayout) layout;
>> + Delegator delegator = null;
>> + delegator = DelegatorFactory.getDelegator(ofbizLayout.delegatorName);
>> + context.setAttribute("delegator", delegator);
>> + context.setAttribute("dispatcher", new WebslingerGenericDispatcher(context, layout.getTarget(), delegator,
>> globalReaderURLs));
>> + context.setAttribute("authz", AuthorizationFactory.getInstance(delegator));
>> + context.setAttribute("security", SecurityFactory.getInstance(delegator));
>> + }
>> +
>> + protected static final class WebslingerGenericDispatcher extends GenericDispatcher {
>> + protected WebslingerGenericDispatcher(WebslingerServletContext context, String name, Delegator delegator, List<URL>
>> globalReaderURLs) throws IOException {
>> + ArrayList<URL> readerURLs = new ArrayList<URL>(globalReaderURLs);
>> + String readerFiles = context.getInitParameter("serviceReaderUrls");
>> + if (readerFiles != null) {
>> + for (String reader: CollectionUtil.split(readerFiles, ";")) {
>> + URL url = context.getResource(reader);
>> + if (url != null) readerURLs.add(url);
>> + }
>> + }
>> + System.err.println(readerURLs);
>> + this.dispatcher = new ServiceDispatcher(delegator, true, true, true) {
>> + };
>> + ClassLoader loader = null;
>> + try {
>> + loader = Thread.currentThread().getContextClassLoader();
>> + } catch (SecurityException e) {
>> + loader = WebslingerContextMapper.class.getClassLoader();
>> + }
>> + DispatchContext dc = new DispatchContext(name, readerURLs, loader, null);
>> + init(name, delegator, dc);
>> + }
>> + }
>> +
>> + @Override
>> + protected Set<String> getSuffixes() throws Exception {
>> + Cache cache = delegator.getCache();
>> + Set<String> suffixes;
>> + synchronized (WebslingerContextMapper.class) {
>> + suffixes = cache.get("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes");
>> + if (suffixes == null) {
>> + suffixes = new HashSet<String>();
>> + for (GenericValue value: delegator.findList("WebslingerHostSuffix", null, null, null, null, false)) {
>> + suffixes.add(value.getString("hostSuffix"));
>> + }
>> + cache.put("WebslingerHostSuffix", null, "WebslingerContextMapper.Suffixes", suffixes);
>> + }
>> + }
>> + return suffixes;
>> + }
>> +
>> + @Override
>> + protected Layout lookupLayout(String hostName, String contextPath) throws Exception {
>> + GenericValue layout = EntityUtil.getOnly(delegator.findByAndCache("WebslingerLayout", UtilMisc.toMap("hostName",
>> hostName, "contextPath", contextPath)));
>> + if (layout == null) return null;
>> + return new OfbizLayout(layout);
>> + }
>> +
>> + protected class OfbizLayout implements Layout {
>> + private final String contextPath;
>> + private final String id;
>> + private final String target;
>> + private final String[] bases;
>> + private final int hashCode;
>> + protected final String delegatorName;
>> + protected final String dispatcherName;
>> +
>> + protected OfbizLayout(GenericValue server) throws GenericEntityException {
>> + contextPath = server.getString("contextPath");
>> + id = server.getString("webslingerServerId");
>> + target = server.getString("target");
>> + List<GenericValue> baseValues = server.getRelatedCache("WebslingerServerBase", UtilMisc.toList("seqNum"));
>> + bases = new String[baseValues.size()];
>> + for (int i = 0; i < bases.length; i++) {
>> + GenericValue baseValue = baseValues.get(i);
>> + bases[i] = baseValue.getString("baseName");
>> + }
>> + delegatorName = server.getString("delegatorName");
>> + dispatcherName = server.getString("dispatcherName");
>> + hashCode = target.hashCode() ^ ObjectUtil.hashCodeHelper(delegatorName) ^ Arrays.hashCode(bases);
>> + }
>> +
>> + public String getContextPath() {
>> + return contextPath;
>> + }
>> +
>> + public String getId() {
>> + return id;
>> + }
>> +
>> + public String getTarget() {
>> + return target;
>> + }
>> +
>> + public String[] getBases() {
>> + return bases;
>> + }
>> +
>> + @Override
>> + public int hashCode() {
>> + return hashCode;
>> + }
>> +
>> + @Override
>> + public boolean equals(Object o) {
>> + if (!(o instanceof OfbizLayout)) return false;
>> + OfbizLayout other = (OfbizLayout) o;
>> + if (!contextPath.equals(other.contextPath)) return false;
>> + if (!target.equals(other.target)) return false;
>> + if (!ObjectUtil.equalsHelper(delegatorName, other.delegatorName)) return false;
>> + return Arrays.equals(bases, other.bases);
>> + }
>> + }
>> +}
>>
>> Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerServerEngine.java
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerServerEngine.java?rev=833727&r1=833726&r2=833727&view=diff
>> = = = = = = = = ======================================================================
>> --- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerServerEngine.java (original)
>> +++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/ WebslingerServerEngine.java Sat Nov 7 18:18:33 2009
>> @@ -1,64 +1,59 @@
>> -/ *******************************************************************************
>> - * 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.webslinger;
>> -
>> -import java.io.IOException;
>> -import java.io.StringReader;
>> -import java.io.StringWriter;
>> -import java.util.Collections;
>> -import java.util.Map;
>> -
>> -import org.ofbiz.base.util.UtilGenerics;
>> -import org.ofbiz.base.util.UtilMisc;
>> -import org.ofbiz.entity.Delegator;
>> -import org.ofbiz.entity.GenericValue;
>> -import org.ofbiz.entity.util.EntityUtil;
>> -import org.ofbiz.service.GenericServiceException;
>> -import org.ofbiz.service.ModelService;
>> -import org.ofbiz.service.ServiceDispatcher;
>> -import org.ofbiz.service.engine.GenericAsyncEngine;
>> -
>> -import org.webslinger.WebslingerServletContext;
>> -
>> -public class WebslingerServerEngine extends GenericAsyncEngine {
>> - public WebslingerServerEngine(ServiceDispatcher dispatcher) {
>> - super(dispatcher);
>> - }
>> -
>> - @Override
>> - public void runSyncIgnore(String localName, ModelService modelService, Map<String, Object> context) throws
>> GenericServiceException {
>> - runSync(localName, modelService, context);
>> - }
>> -
>> - @Override
>> - public Map<String, Object> runSync(String localName, ModelService modelService, Map<String, Object> context) throws
>> GenericServiceException {
>> - Delegator delegator = dispatcher.getDelegator();
>> - try {
>> - GenericValue found = EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout",
>> UtilMisc.toMap("webslingerServerId", modelService.location)));
>> - if (found == null) throw new GenericServiceException("Couldn't find server mapping for(" + modelService.location +
>> ")");
>> - return UtilGenerics .checkMap (WebslingerServletContext.invokeInVM(found.getString("hostName"), 8080,
>> modelService.invoke, context));
>> - } catch (RuntimeException e) {
>> - throw e;
>> - } catch (GenericServiceException e) {
>> - throw e;
>> - } catch (Exception e) {
>> - throw UtilMisc.initCause(new GenericServiceException(e.getMessage()), e);
>> - }
>> - }
>> -}
>> +/ *******************************************************************************
>> + * 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.webslinger;
>> +
>> +import java.util.Map;
>> +
>> +import org.ofbiz.base.util.UtilGenerics;
>> +import org.ofbiz.base.util.UtilMisc;
>> +import org.ofbiz.entity.Delegator;
>> +import org.ofbiz.entity.GenericValue;
>> +import org.ofbiz.entity.util.EntityUtil;
>> +import org.ofbiz.service.GenericServiceException;
>> +import org.ofbiz.service.ModelService;
>> +import org.ofbiz.service.ServiceDispatcher;
>> +import org.ofbiz.service.engine.GenericAsyncEngine;
>> +import org.webslinger.WebslingerServletContext;
>> +
>> +public class WebslingerServerEngine extends GenericAsyncEngine {
>> + public WebslingerServerEngine(ServiceDispatcher dispatcher) {
>> + super(dispatcher);
>> + }
>> +
>> + @Override
>> + public void runSyncIgnore(String localName, ModelService modelService, Map<String, Object> context) throws
>> GenericServiceException {
>> + runSync(localName, modelService, context);
>> + }
>> +
>> + @Override
>> + public Map<String, Object> runSync(String localName, ModelService modelService, Map<String, Object> context) throws
>> GenericServiceException {
>> + Delegator delegator = dispatcher.getDelegator();
>> + try {
>> + GenericValue found = EntityUtil.getFirst(delegator.findByAndCache("WebslingerLayout",
>> UtilMisc.toMap("webslingerServerId", modelService.location)));
>> + if (found == null) throw new GenericServiceException("Couldn't find server mapping for(" + modelService.location +
>> ")");
>> + return UtilGenerics .checkMap (WebslingerServletContext.invokeInVM(found.getString("hostName"), 8080,
>> modelService.invoke, context));
>> + } catch (RuntimeException e) {
>> + throw e;
>> + } catch (GenericServiceException e) {
>> + throw e;
>> + } catch (Exception e) {
>> + throw UtilMisc.initCause(new GenericServiceException(e.getMessage()), e);
>> + }
>> + }
>> +}
>>
>>
>
>