<repo_name>miguelvargas/test<file_sep>/trunk/common/java/common-test/src/com/mvwsolutions/common/test/spring/TestBeanPostProcessor.java
package com.mvwsolutions.common.test.spring;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class TestBeanPostProcessor implements BeanPostProcessor {
	private static Log logger = LogFactory.getLog(TestBeanPostProcessor.class);
    
    // integration tests may want to disable this processot in order to test "real" beans
    public static boolean ENABLED = true; 

	private Map<String, Object> classReplacementMap = new HashMap<String, Object>(); 
	private Map<String, Object> beanReplacementMap = new HashMap<String, Object>(); 
	
	public Map<String, Object> getBeanReplacementMap() {
		return beanReplacementMap;
	}

	public void setBeanReplacementMap(Map<String, Object> beanReplacementMap) {
		this.beanReplacementMap = beanReplacementMap;
	}

	public Map<String, Object> getClassReplacementMap() {
		return classReplacementMap;
	}

	public void setClassReplacementMap(Map<String, Object> classReplacementMap) {
		this.classReplacementMap = classReplacementMap;
	}

	public Object postProcessAfterInitialization(Object bean, String beanName)
			throws BeansException {
		return bean;
	}

	public Object postProcessBeforeInitialization(Object bean, String beanName)
			throws BeansException {
		Object res = getBeanImpl(bean, beanName);

		return res;
	}

	private Object getBeanImpl(Object bean, String beanName) {
        if (!ENABLED) {
            return bean;
        }
        
		Object res;
		res = classReplacementMap.get(bean.getClass().getName());
		if (res != null) {
			logger.warn("Bean (" + beanName + " - " + bean.getClass().getName()
					+ ") is replaced with class ("+res.getClass().getName()+")");
		} else {
			res = beanReplacementMap.get(beanName);
			if (res != null) {
				logger.warn("Bean (" + beanName + " - " + bean.getClass().getName()
						+ ") is replaced with class ("+res.getClass().getName()+")");
			}
		}
		return res != null ? res : bean;
	}

}
<file_sep>/trunk/common/java/common-web/src/com/mvwsolutions/common/web/controller/HostPortSecurityEnforcer.java
package com.mvwsolutions.common.web.controller;

import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

import javax.servlet.http.HttpServletRequest;

public class HostPortSecurityEnforcer implements ExtraSecurityEnforcer {

	private Set<String> _remoteHostWhiteList = new HashSet<String>();
	private Set<Integer> _localPortWhiteList = new HashSet<Integer>();
	

	public void setLocalPortWhiteList(String localPortWhiteList) {
		if (localPortWhiteList != null) {
			StringTokenizer st = new StringTokenizer(localPortWhiteList, ",");
			while (st.hasMoreTokens()) {
				String s = st.nextToken();
				_localPortWhiteList.add(new Integer(s));
			}
		}
	}

	public void setRemoteHostWhiteList(String remoteHostWhiteList) {
		if (remoteHostWhiteList != null) {
			StringTokenizer st = new StringTokenizer(remoteHostWhiteList, ",");
			while (st.hasMoreTokens()) {
				String s = st.nextToken();
				_remoteHostWhiteList.add(s);
			}
		}	
	}

	public boolean checkAccess(HttpServletRequest request) {
		String remoteIp = request.getRemoteAddr();
		if (_remoteHostWhiteList.size() != 0) {
			if (!_remoteHostWhiteList.contains(remoteIp)) {
				return false;
			}
		}
		int localPort = request.getLocalPort();
		if (_localPortWhiteList.size() != 0 && !_localPortWhiteList.contains(localPort)) {
			return false;
		}
		return true;
	}
	

}
<file_sep>/trunk/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mvwsolutions</groupId>
    <artifactId>all</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>All projects</name>

    <scm>
        <connection>scm:svn:file:///var/svn/repos</connection>
        <developerConnection>scm:svn:file:///var/svn/repos</developerConnection>
        <tag>HEAD</tag>
    </scm>    

    <modules>
        <module>common/maven/lib-installer</module>
        
        <module>common/maven/global-parent</module>
        
        <module>common/java/common</module>
        <module>common/java/common-server</module>
        <module>common/java/common-web</module>
        <module>common/java/common-test</module>

        <module>common/android/dao</module>
        <module>common/android/daogen</module>
        <module>common/android/daogen-maven-plugin</module>
        <module>common/android/DroidCommand</module>

	<module>common/maven/android-parent</module>

        <!-- module>examples/MapsAndDb</module -->


        <module>products/in-house/DroidDateServerAPI</module>
        <module>products/in-house/DroidDateServer</module>
	<module>products/in-house/DroidDateClient</module>

    </modules>

</project>
<file_sep>/trunk/common/android/DroidCommand/src/com/mvw/controller/CommandMappingException.java
package com.mvw.controller;

public class CommandMappingException extends Exception {

	private static final long serialVersionUID = 7548673498237833035L;

	public CommandMappingException(String string) {
		super(string);
	}


}
<file_sep>/trunk/common/java/common-web/src/com/mvwsolutions/common/web/controller/LocalPortSecurityEnforcer.java
package com.mvwsolutions.common.web.controller;

import java.util.HashSet;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;


public class LocalPortSecurityEnforcer implements ExtraSecurityEnforcer {

	private Set<Integer> allowedPorts = new HashSet<Integer>();

	public Set<Integer> getAllowedPorts() {
		return this.allowedPorts;
	}

	public void setAllowedPorts(Set<Integer> allowedPorts) {
		this.allowedPorts = allowedPorts;
	}

	public boolean checkAccess(HttpServletRequest request) {
		return getAllowedPorts().contains(request.getLocalPort());
	}

}
<file_sep>/trunk/common/java/common-server/src/com/mvwsolutions/common/dao/BaseDao.java
package com.mvwsolutions.common.dao;

import java.io.Serializable;
import java.util.Iterator;
import java.util.List;

import org.hibernate.LockMode;

import com.mvwsolutions.common.dao.SortingAndPagingDescriptor.SortingOption;



/**
 * This class is the Base DAO(Data Access Object)Interface. It must be
 * implemented by all data access objects (DAOs)
 * 
 * @author : smineyev with permission, altered by Marcus
 * 
 */
public interface BaseDao<T, ID extends Serializable> {

    /**
     * This method load/retrieve a domain Object for a given id from the
     * database Table
     * 
     * @param id
     *            Specifies the id of the domain Object to be retrieved.
     * @return the domain object instance
     * @throws DataAccessException
     *             in case of dataaccess execution errors.
     */
    public T findById(ID id) throws DataAccessException;

    public <C> C findById(ID id, Class<C> expectedClass)
            throws DataAccessException;

    /**
     * This method load/retrieve all the records for a domain Object from the
     * database Table
     * 
     * @return the list of domain-object instances
     * @throws DataAccessFwException
     *             in case of dataaccess execution errors.
     * 
     */
    public List<T> findAll() throws DataAccessException;

    /**
     * This method load/retrieve maximum number of records(specified by
     * maxResults parameter) for a domain Object from the database Table.
     * 
     * @param maxResults
     *            Specifies the maximum number of records to be retrieve.
     * @return the list of domain-object instances
     * @throws DataAccessFwException
     *             in case of dataaccess execution errors.
     */
    public List<T> findAll(int maxResults) throws DataAccessException;

    /**
     * This method load/retrieve maximum number of records( the index postion of
     * first record in the resultSet is specified by startIndex parameter) for a
     * domain Object from the database Table.
     * 
     * @param startIndex
     *            Specifies the start index of the record to be retrieve.
     * @param maxResults
     *            Specifies the maximum number of records to be retrieve.
     * @return the list of domain-object instances
     * @throws DataAccessFwException
     *             in case of dataaccess execution errors.
     * 
     */
    public List<T> findAll(int startIndex, int maxResults)
            throws DataAccessException;

    /**
     * This method load/retrieve all the records for a domain Object based on
     * the populated search attributes(search -parameter/values) from the
     * database Table.
     * 
     * @param exampleInstance
     *            Specifies the domainObject with search criteria
     * @return the list of domain-object instances
     * @throws DataAccessFwException
     *             in case of dataaccess execution errors.
     */
    public List<T> findByExample(T exampleInstance)
            throws DataAccessException;
    
    public List<T> findByExample(T exampleObject, int maxResults);    

    public T merge(T transObj) throws DataAccessException;

    /**
     * This method save/update a domain object's information into the Database
     * Table.
     * 
     * @param entity
     *            Specifies the domain object to be save/update.
     * @return the domainobject instance
     * @throws DataAccessFwException
     *             in case of dataaccess execution errors.
     * 
     */
    public T saveOrUpdate(T entity) throws DataAccessException;

    /**
     * This method remove a domain object's information from the Database Table.
     * 
     * @param entity
     *            Specifies the domain object to be deleted.
     * @return true if object has been deleted otherwise false
     * @throws DataAccessFwException
     *             in case of dataaccess execution errors.
     * 
     */
    public void delete(T entity) throws DataAccessException;
    
    /**
     * This method remove a domain object's information from the Database Table using object id.
     * 
     * @param id
     *            Specifies ID of domain object to be deleted.
     * @throws DataAccessFwException
     *             in case of dataaccess execution errors.
     * 
     */
    public boolean deleteById(ID id) throws DataAccessException;    

    /**
     * This method save/update a list of domain object's information into the
     * Database Table.
     * 
     * @param domainobjList
     *            Specifies the List of domain objects to be saved/updated.
     * @return the list of domain-object instances
     * @throws DataAccessFwException
     *             in case of dataaccess execution errors.
     * 
     */
    public List<T> saveOrUpdateAll(List<T> domainobjList)
            throws DataAccessException;

    /**
     * This method remove a list of domain object's information from the
     * Database Table.
     * 
     * @param domainobjList
     *            Specifies the list of domain objects to be deleted
     * @throws DataAccessFwException
     *             in case of dataaccess execution errors.
     * 
     */
    public void deleteAll(List<T> domainobjList) throws DataAccessException;

    /**
     * This method load/retrieve all the records for a domain Object based on
     * the populated search attributes(search- parameter/values) and
     * SortingAndPagingDescriptor (which contains the sorting-order, startIndex
     * and pagesize for the search result) from the database Table.
     * 
     * @param exampleObject
     *            Specifies the exampleObject with search criteria.
     * @param pagingData
     *            Specifies the sorting & paging criteria.
     * @return the list of domain-object instances
     * @throws DataAccessFwException
     *             in case of dataaccess execution errors.
     */
    public List<T> findByExample(T exampleObject,
            SortingAndPagingDescriptor pagingData) throws DataAccessException;

    public List<T> findByExample(final T exampleObject,
            final SortingAndPagingDescriptor pagingDescriptor, int maxResults);    
    
    public List<T> findByExample(final T exampleObject,
            final LockMode lockMode) throws DataAccessException;
    
    public Iterator<T> iterateByExmple(final T exampleObject);

    public Iterator<T> iterateByExmple(final T exampleObject,
            final SortingOption so);

    public Iterator<T> iterateByExmple(final T exampleObject, LockMode lockMode);

    public Iterator<T> iterateByExmple(final T exampleObject,
            final SortingOption... sos);

    public Iterator<T> iterateByExmple(final T exampleObject,
            final SortingOption so, final int internalCacheSize);

    public Iterator<T> iterateByExmple(final T exampleObject,
            final SortingOption so, LockMode lockMode);

    public Iterator<T> iterateByExmple(final T exampleObject,
            LockMode lockMode, final SortingOption... sos);

    public Iterator<T> iterateByExmple(final T exampleObject,
            final SortingOption[] sos, final LockMode lockMode,
            final int internalCacheSize);

    public void initializeLazyObject(Object obj);

//    FIXME smineyev: I didn't find the way to re-attach modified data-graph to hibernate session 
//  (neither update, locl(NONE), relicate, refresh work)    
//    public void reattachModified(T entity);
    
    public void clearCache();

    public void evict(T ri);
    
    public void flush();
}
<file_sep>/trunk/common/java/common-test/src/com/mvwsolutions/common/test/web/SpringServletTester.java
package com.mvwsolutions.common.test.web;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.LocalConnector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.servlet.DispatcherServlet;

import com.mvwsolutions.common.ComponentManager;

/**
 * 
 * @author smineyev
 * 
 */
public class SpringServletTester {
    private final static Log logger = LogFactory
            .getLog(SpringServletTester.class);


    private Server server = new Server();

    private LocalConnector localConnector = new LocalConnector();

    private int usageCounter;
    
    private List<ServletContextListener> listeners = new ArrayList<ServletContextListener>();;

    
    public SpringServletTester(ServletContextListener... extraListeners) throws IOException {
        this.listeners.add(new ContextLoaderListener());
        if (extraListeners != null) {
            this.listeners.addAll(Arrays.asList(extraListeners));
        }
        
        try {
            this.server.setSendServerVersion(false);
            this.server.addConnector(localConnector);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        final String baseDir = System.getProperty("basedir");
        String contextResourceBase = (baseDir == null ? "." : baseDir) + "/web";
        File contentResourceBaseFile = new File(contextResourceBase);
        if (contentResourceBaseFile.exists()) {
            addContext(contextResourceBase, "/");
        } else {
            throw new FileNotFoundException("Web content folder ("
                    + contentResourceBaseFile.getCanonicalPath()
                    + ") doesn't exist in current project "
                    + "so no default web context is created");
        }
    }

    public void enableRemoteConnectors(int... ports) {
        if (usageCounter > 0) {
            throw new IllegalStateException(
                    "servlet container currently is in use");
        }
        for (int port : ports) {
            if (checkIfRemoteConnectorExists(port)) {
                logger.warn("Connector on port (" + port
                        + ") has already been enabled");
                continue;
            }

            SocketConnector remoteConnector = new SocketConnector();
            // remoteConnector.setHost("localhost");
            remoteConnector.setPort(port);
            server.addConnector(remoteConnector);
            logger.debug("Connector on port (" + port + ") added");
        }
    }

    private boolean checkIfRemoteConnectorExists(int port) {
        for (Connector c : server.getConnectors()) {
            if (c instanceof SocketConnector) {
                if (((SocketConnector) c).getPort() == port) {
                    return true;
                }
            }
        }
        return false;
    }

    public void disableRemoteConnectors() {
        if (usageCounter > 0) {
            throw new IllegalStateException(
                    "servlet container currently is in use");
        }
        for (Connector c : server.getConnectors()) {
            if (c instanceof SocketConnector) {
                server.removeConnector(c);
            }
        }
    }

    public Context addContext(String contextResourceBase, String contextPath) {
        if (this.usageCounter > 0) {
            throw new IllegalStateException(
                    "servlet container currently is in use");
        }
        Context context = new Context(Context.SESSIONS | Context.SECURITY);

        this.server.addHandler(context);

        context.setContextPath(contextPath);

        context.setResourceBase(contextResourceBase);

        setInitParameter(context, "contextConfigLocation", "");
        setInitParameter(context, "parentContextKey",
                ComponentManager.ROOT_BEAN_FACTORY_NAME);
        setInitParameter(context, "locatorFactorySelector",
                ComponentManager.BEAN_REF_CONTEXT_XML);

        for (ServletContextListener listener: listeners) {
            context.addEventListener(listener);
        }

        final ServletHolder servletHolder = context.getServletHandler()
                .newServletHolder(DispatcherServlet.class);

        servletHolder.setInitOrder(1);
        servletHolder.setName("spring");

        context.addServlet(servletHolder, "/spring/*");

        return context;
    }

    public void start() throws Exception {
        if (this.usageCounter == 0) {
            this.server.start();
        }
        ++this.usageCounter;
    }

    public void stop() throws Exception {
        if (--this.usageCounter == 0) {
            this.server.stop();
        }
    }

    /* ------------------------------------------------------------ */
    /**
     * Get raw HTTP responses from raw HTTP requests. Multiple requests and
     * responses may be handled, but only if persistent connections conditions
     * apply.
     * 
     * @param rawRequests
     *            String of raw HTTP requests
     * @return String of raw HTTP responses
     * @throws Exception
     */
    public String getResponses(String rawRequests) throws Exception {
        localConnector.reopen();
        String responses = localConnector.getResponses(rawRequests);
        return responses;
    }

    @SuppressWarnings("unchecked")
    public static void setInitParameter(Context context, String name,
            Object value) {
        context.getInitParams().put(name, value);
    }
}
<file_sep>/trunk/common/android/DroidCommand/src/com/mvw/controller/CommandMapping.java
package com.mvw.controller;

import com.mvw.command.Command;
import com.mvw.event.CommandEvent;

public class CommandMapping {
	private CommandEvent event;
	private Command command;
	
	public CommandMapping(Command cmd, CommandEvent _event) {
		event = _event;
		command = cmd;
	}
	public CommandEvent getEvent() {
		return event;
	}
	public void setEvent(CommandEvent event) {
		this.event = event;
	}
	public Command getCommand() {
		return command;
	}
	public void setCommand(Command command) {
		this.command = command;
	}
}
<file_sep>/trunk/common/maven/android-parent/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.mvwsolutions</groupId>
        <artifactId>global-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.mvwsolutions</groupId>
    <artifactId>android-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Android parent pom</name>

    <scm>               
        <connection>scm:svn:file:///var/svn/repos/common/maven/global-parent</connection>
        <developerConnection>scm:svn:file:///var/svn/repos/common/maven/global-parent</developerConnection>
    </scm> 

    <build>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>maven-android-plugin</artifactId>
                <version>2.3.0</version>
                <configuration>
                    <sdk>
                        <platform>${android-sdk-version}</platform>
                    </sdk>
                    <deleteConflictingFiles>true</deleteConflictingFiles>
                </configuration>
                <extensions>true</extensions>
            </plugin>

	
	<plugin>
        	<groupId>com.mvwsolutions.common.android</groupId>
	        <artifactId>daogen-maven-plugin</artifactId>
        	<version>1.0-SNAPSHOT</version>
		<configuration>
    			<genOutput>gen2</genOutput> <!-- cannot use 'gen' as it's conflicting with Eclipse -->
		</configuration>

		<executions>
	          <execution>
        	    <phase>process-classes</phase>
	            <goals>
        	      <goal>run</goal>
	            </goals>
        	  </execution>
	        </executions>

      	</plugin>
        </plugins>
    </build>


    <dependencies>
        
        <!-- projects -->
        
        <!-- third party libs -->
        

    </dependencies>
    
</project>
<file_sep>/trunk/common/android/DroidCommand/src/com/mvw/event/EventDispatcher.java
package com.mvw.event;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class EventDispatcher {

	private Map<String, List<EventListener>> listeners = new HashMap<String, List<EventListener>>();

	public EventDispatcher() {
		super();
	}

	public void dispatchEvent(final CommandEvent event) {
		synchronized (listeners) {
			// first call all listeners
			List<EventListener> elist = listeners.get(event.getType());
			if (elist != null && elist.size() > 0) {
				for (EventListener listener : elist) {
					listener.onEvent(event);
				}
			}
		}
	}

	public void addEventListener(EventListener listner, String type) {
	
		synchronized (listeners) {
			List<EventListener> list = listeners.get(type);
			if (list == null) {
				list = new ArrayList<EventListener>();
				listeners.put(type, list);
			}
			list.add(listner);
		}
	}

	public boolean removeEventListener(EventListener listener, String type) {
		synchronized (listeners) {
			if (!listeners.containsKey(type)) {
				return false;
			}
			List<EventListener> list = listeners.get(type);
			return list.remove(listener);
		}
	}

}<file_sep>/trunk/common/java/common-server/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.mvwsolutions</groupId>
        <artifactId>global-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.mvwsolutions.common</groupId>
    <artifactId>java-common-server</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Java common server</name>

    <scm>
        <connection>scm:svn:file:///var/svn/repos/common/java/common-server</connection>
        <developerConnection>scm:svn:file:///var/svn/repos/common/java/common-server</developerConnection>
        <tag>HEAD</tag>
    </scm>    

    <dependencies>
        
        <!-- projects -->
        
        <!-- third party libs -->
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>



	<dependency>
		<groupId>org.hibernate</groupId>
		<artifactId>hibernate</artifactId>
	</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
		</dependency>
		
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aop</artifactId>
		</dependency>
		
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-orm</artifactId>
		</dependency>
		
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
		</dependency>
		
      
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl104-over-slf4j</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>
        

    </dependencies>
    
</project>
<file_sep>/trunk/common/java/common/src/com/mvwsolutions/common/exceptions/SecurityException.java
package com.mvwsolutions.common.exceptions;

@SuppressWarnings("serial")
public class SecurityException extends RuntimeException {
	
	public SecurityException() {
	}
	
	public SecurityException(String msg) {
		super(msg);
	}

}
<file_sep>/trunk/common/android/daogen-maven-plugin/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mvwsolutions.common.android</groupId>
    <artifactId>daogen-maven-plugin</artifactId>
    <packaging>maven-plugin</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Daogen maven plugin that generates DAO from annotated beans</name>

    <scm>
        <connection>scm:svn:file:///var/svn/repos/common/android/daogen-maven-plugin</connection>
        <developerConnection>scm:svn:file:///var/svn/repos/common/android/daogen-maven-plugin</developerConnection>
        <tag>HEAD</tag>
    </scm>    

    <build>
        <directory>target</directory>
        
        <outputDirectory>target/classes</outputDirectory>
        <finalName>${artifactId}-${version}</finalName>
        <testOutputDirectory>target/test-classes</testOutputDirectory>
        <sourceDirectory>src</sourceDirectory>
        <scriptSourceDirectory>scripts</scriptSourceDirectory>
        <testSourceDirectory>test</testSourceDirectory>
        <resources>
            <resource>
                <directory>src-res</directory>
                <excludes>
                    <exclude>*app.properties</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src-res</directory>
                <includes>
                    <include>*app.properties</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>test-res</directory>
                <excludes>
                    <exclude>*app.properties</exclude>
                </excludes>
            </testResource>
            <testResource>
                <directory>test-res</directory>
                <includes>
                    <include>*app.properties</include>
                </includes>
                <filtering>true</filtering>
            </testResource>
        </testResources>

	<plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
	</plugins>
    </build>    

    <dependencies>
        
        <!-- projects -->

        <dependency>
	    <groupId>com.mvwsolutions.common</groupId>
	    <artifactId>java-common</artifactId>
	    <version>1.0-SNAPSHOT</version>
        </dependency>

        <dependency>
	    <groupId>com.mvwsolutions.common.android</groupId>
	    <artifactId>daogen</artifactId>
	    <version>1.0-SNAPSHOT</version>
        </dependency>

        
        <!-- third party libs -->

 	<dependency>
      		<groupId>org.apache.maven</groupId>
      		<artifactId>maven-plugin-api</artifactId>
 		<version>2.2.1</version>
    	</dependency>

 	<dependency>
      		<groupId>org.apache.maven</groupId>
      		<artifactId>maven-project</artifactId>
 		<version>2.2.1</version>
    	</dependency>

        

    </dependencies>
    
</project>
<file_sep>/trunk/common/java/common-web/src/com/mvwsolutions/common/web/controller/BaseController.java
package com.mvwsolutions.common.web.controller;

import java.math.BigInteger;
import java.util.Collection;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;

import com.mvwsolutions.common.exceptions.AuthorizationException;
import com.mvwsolutions.common.service.CurrentUserService;
import com.mvwsolutions.common.web.util.WebUtils;
import com.mvwsolutions.common.web.view.GenericXmlView;

public abstract class BaseController<C> extends AbstractCommandController {

    public static final String SESSID_COOKIE_NAME = "MVW_DROIDADTE_SESSION_ID";

    public static final String SESSID_QUERY_NAME = SESSID_COOKIE_NAME;

    protected boolean allowQuerySession = true;

    protected CurrentUserService currentUserService;
    private String             successView = GenericXmlView.VIEW_NAME ;
    private String             failureView;
    private String             formView;

    private Collection<ExtraSecurityEnforcer> extraSecurityEnforcers;

    protected BaseController(Class<C> cmdClass) {
        super(cmdClass);
        setCommandName(GenericXmlView.OBJECT_MODEL);
    }

    @SuppressWarnings("unchecked")
    public Class<C> getCmdClass() {
        return getCommandClass();
    }

    public Collection<ExtraSecurityEnforcer> getExtraSecurityEnforcers() {
        return extraSecurityEnforcers;
    }

    public void setExtraSecurityEnforcers(
            Collection<ExtraSecurityEnforcer> extraSecurityEnforcers) {
        this.extraSecurityEnforcers = extraSecurityEnforcers;
    }

    public CurrentUserService getCurrentUserService() {
        return currentUserService;
    }

    public void setCurrentUserService(CurrentUserService currentUserService) {
        this.currentUserService = currentUserService;
    }

    public boolean isAllowQuerySession() {
        return allowQuerySession;
    }

    public void setAllowQuerySession(boolean allowQuerySession) {
        this.allowQuerySession = allowQuerySession;
    }

    @Override
    @SuppressWarnings("unchecked")
    public ModelAndView handle(HttpServletRequest httpRequest,
            HttpServletResponse httpResponse, Object command,
            BindException errors) throws Exception {

        final long startTime = System.currentTimeMillis();

        preventCaching(httpResponse);
        if (extraSecurityEnforcers != null) {
            for (ExtraSecurityEnforcer extraSecurityEnforcer : extraSecurityEnforcers) {
                if (!extraSecurityEnforcer.checkAccess(httpRequest)) {
                    logger.warn("Access denied (remoteHost"
                            + httpRequest.getRemoteAddr() + ":"
                            + httpRequest.getRemotePort() + ", enforced by: '"
                            + extraSecurityEnforcer.toString() + "')");
                    throw new AuthorizationException("Access denied");
                }
            }
        }

        if (errors.getErrorCount() > 0) {
            throw new BindException(errors);
        }

        final C cmd = getCmdClass().cast(command);
        boolean requestAuthenticated;
        boolean authenticationFailed = false;
        ModelAndView res;

        if (!authenticationRequired()) {
            requestAuthenticated = false;
            res = handleAuthenticatedRequest(httpRequest, httpResponse, cmd,
                    errors);
        } else if (currentUserService == null) {
            logger
                    .warn("currentUserService is not set for the controller. Request is considered unauthenticated.");
            requestAuthenticated = false;
            res = handleNotAuthenticatedRequest(httpRequest, httpResponse, cmd,
                    errors);
        } else {
            String sessionId = extractSessionId(httpRequest);

            Long userId = null;
            if( sessionId != null && !sessionId.equals("") )
                userId = currentUserService.setCurrentSsoSession(new BigInteger(sessionId));

            if (userId == null) {
                requestAuthenticated = false;
                res = handleNotAuthenticatedRequest(httpRequest, httpResponse,
                        cmd, errors);
            } else {
                requestAuthenticated = true;
                res = handleAuthenticatedRequest(httpRequest, httpResponse,
                        cmd, errors);
            }
        }

        if (res != null) {
	        final Map model = res.getModel();
	
	        model.put(GenericXmlView.REQUEST_DURATION_MODEL,
	                new Long(System.currentTimeMillis() - startTime));
	        model.put(GenericXmlView.REQUEST_AUTHENTICATED_MODEL,
	                requestAuthenticated);
	        model.put(GenericXmlView.AUTHENTICATION_FAILED_MODEL,
	                authenticationFailed);
        }
        
        return res;
    }

	protected String extractSessionId(HttpServletRequest httpRequest) {
		// attempt to get from cookie
		String sessionId = WebUtils.getCookieValue(httpRequest, SESSID_COOKIE_NAME);
		// if, null check query string as a last resort
		if (sessionId == null && allowQuerySession) {
		    sessionId = httpRequest.getParameter(SESSID_QUERY_NAME);
		}
		return sessionId;
	}

    @Override
    protected C getCommand(HttpServletRequest request) throws Exception {
        return getCmdClass().cast(super.getCommand(request));
    }

    protected boolean authenticationRequired() {
        return true;
    }

    protected ModelAndView handleNotAuthenticatedRequest(
            HttpServletRequest httpRequest, HttpServletResponse httpResponse,
            C command, BindException errors) throws Exception {
    	
        throw new AuthorizationException(
                "Permission denied (user not-authenticated)");
    }

    protected abstract ModelAndView handleAuthenticatedRequest(
            HttpServletRequest httpRequest, HttpServletResponse httpResponse,
            C command, BindException errors) throws Exception;


      
    
    public static String getRemoteIP(HttpServletRequest httpRequest) {
        String remoteAddr = httpRequest.getHeader("SS_CLIENT_IP");
        if (remoteAddr == null) {
            remoteAddr = httpRequest.getRemoteAddr();
        }
        return remoteAddr;
    }    
    public String getFormView() {
        return formView;
    }

    public void setFormView(String formView) {
        this.formView = formView;
    }
    
    public String getSuccessView() {
        return successView;
    }

    public void setSuccessView(String successView) {
        this.successView = successView;
    }
    public String getFailureView() {
        return failureView;
    }

    public void setFailureView(String failureView) {
        this.failureView = failureView;
    }


}
<file_sep>/trunk/common/maven/lib-installer/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mvwsolutions</groupId>
    <artifactId>lib-installer</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Third party lib installer</name>
    
    <scm>
        <connection>scm:svn:file:///var/svn/repos/common/maven/lib-installer</connection>
        <developerConnection>scm:svn:file:///var/svn/repos/common/maven/lib-installer</developerConnection>
        <tag>HEAD</tag>
    </scm>

    <profiles>
        <profile>
            <id>db-profile</id>
            <activation>
                <property>
                    <name>!fast</name>
                </property>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            
                            <execution>
                                <id>install-local-dependencies</id>
                                <phase>compile</phase>
                                <configuration>
                                    <tasks>
                                        <echo>Installing dependencies that do not exist in global repository ...</echo>
                                        
                                        <exec failonerror="true" failifexecutionfails="false" executable="${basedir}/install-dependencies.sh"/>
                                        <exec failonerror="true" failifexecutionfails="false" executable="${basedir}/install-dependencies.bat"/>
                                    </tasks>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
<file_sep>/trunk/common/java/common-server/src/com/mvwsolutions/common/dao/hibernate/NulOneToManyPersister.java
package com.mvwsolutions.common.dao.hibernate;

import java.io.Serializable;

import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.cache.CacheConcurrencyStrategy;
import org.hibernate.cache.CacheException;
import org.hibernate.cfg.Configuration;
import org.hibernate.collection.PersistentCollection;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.mapping.Collection;
import org.hibernate.persister.collection.OneToManyPersister;

/**
 * Persister that do not persist collection to DB. Needed by PlayerDataAccessService
 * @author smineyev
 *
 */
public class NulOneToManyPersister extends OneToManyPersister {

    public NulOneToManyPersister(Collection collection,
            CacheConcurrencyStrategy cache, Configuration cfg,
            SessionFactoryImplementor factory) throws MappingException,
            CacheException {
        super(collection, cache, cfg, factory);
    }

    @Override
    protected int doUpdateRows(Serializable id, PersistentCollection collection, SessionImplementor session) throws HibernateException {
        return 0;
    }
    
    

}
<file_sep>/trunk/common/java/common-server/src/com/mvwsolutions/common/dao/hibernate/BugFixDeleteEventListener.java
package com.mvwsolutions.common.dao.hibernate;

import java.util.HashSet;
import java.util.Set;

import org.hibernate.event.EventSource;
import org.hibernate.event.def.DefaultDeleteEventListener;
import org.hibernate.persister.entity.EntityPersister;

/**
 * 
 * bug description:
 * http://opensource.atlassian.com/projects/hibernate/browse/HHH-2146
 * http://lists.jboss.org/pipermail/hibernate-issues/2007-January/003099.html
 * 
 * @author smineyev
 * 
 */
public class BugFixDeleteEventListener extends DefaultDeleteEventListener {

    private static final long serialVersionUID = 2885464529422013461L;

    @SuppressWarnings("unchecked")
	protected void deleteTransientEntity(EventSource session, Object entity,
            boolean cascadeDeleteEnabled, EntityPersister persister,
            Set transientEntities) {
        super.deleteTransientEntity(session, entity, cascadeDeleteEnabled,
                persister, transientEntities == null ? new HashSet()
                        : transientEntities);
    }
}
<file_sep>/trunk/common/java/common-web/src/com/mvwsolutions/common/web/util/WebUtils.java
package com.mvwsolutions.common.web.util;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 
 * @author SMineyev
 *
 */
public class WebUtils {

	public static String getCookieValue(HttpServletRequest httpRequest,
			String cookieName) {

		Cookie cookie = getCookie(httpRequest, cookieName);
		if (cookie != null)
			return cookie.getValue();
		return null;
	}

	public static Cookie getCookie(HttpServletRequest httpRequest,
			String cookieName) {

		final Cookie[] cookies = httpRequest.getCookies();

		if (cookies == null) {
			return null;
		}
		for (Cookie cookie : cookies) {
			if (cookieName.equals(cookie.getName())) {
				return cookie;
			}
		}

		return null;
	}

	public static Cookie setCookie(String name, String value,
			HttpServletRequest request, HttpServletResponse response,
			int expiration) {
		Cookie cookie = new Cookie(name, value);
		cookie.setPath("/");
		cookie.setMaxAge(expiration);
		cookie.setDomain(getDomain(request));
		response.addCookie(cookie);
		return cookie;
	}

	public static String getDomain(HttpServletRequest httpRequest) {
		String domain = httpRequest.getServerName();
		String[] parts = domain.split("\\.");
		if (parts.length < 2) {
			return domain;
		} else {
			domain = '.' + parts[parts.length - 2] + '.'
					+ parts[parts.length - 1];
			return domain;
		}

	}

}
<file_sep>/trunk/common/android/daogen-maven-plugin/src/com/mvwsolutions/common/android/maven/DaoGenMojo.java
package com.mvwsolutions.common.android.maven;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;

import com.mvwsolutions.android.daogen.FileSourceInterface;
import com.mvwsolutions.android.daogen.SourceFileGenerator;
import com.mvwsolutions.android.daogen.SourceInterface.SIException;
import com.mvwsolutions.classwriter.ClassWriter;
import com.mvwsolutions.classwriter.CodeCheckException;
import com.mvwsolutions.common.Utils;

/**
 * 
 * @author SMineyev
 * @goal run
 */
public class DaoGenMojo extends AbstractMojo {

	/** @parameter default-value="${project}" */
	private MavenProject mavenProject;

//	/** @parameter default-value="gen" */
//	private String genOutput;

	public void execute() throws MojoExecutionException {

		getLog().info(
				"Project output: "
						+ mavenProject.getBuild().getOutputDirectory());
		
		final File genOutputDir = new File(mavenProject.getBuild().getSourceDirectory());
		
		getLog().info("Generated files will be placed into: " + genOutputDir.getAbsolutePath());

		Utils.traverseFileTree(new File(mavenProject.getBuild()
				.getOutputDirectory()), new Utils.FileVisitor() {

			@Override
			public void visit(File file) {
				if (!file.isDirectory() && file.getName().endsWith(".class")) {
					try {
						processClassFile(file, genOutputDir);
					} catch (Exception e) {
						getLog().error(
								"Unable to process class file: "
										+ file.getAbsolutePath(), e);
					}
				}

			}

		});

	}

	private void processClassFile(File classFile, File outputDir)
			throws FileNotFoundException, IOException, CodeCheckException,
			SIException {
getLog().info(outputDir.getAbsolutePath() +" , " + classFile.getAbsolutePath());		
		ClassWriter cw = new ClassWriter();
		cw.readClass(new FileInputStream(classFile));
		boolean generated = new SourceFileGenerator(new FileSourceInterface(
				outputDir)).generate(cw);
		if (generated) {
			getLog().info(
					"DAO class (" + outputDir.getAbsolutePath() + ") was generated for "
							+ classFile.getAbsolutePath());
		}
	}
}
<file_sep>/trunk/common/maven/global-parent/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">


    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mvwsolutions</groupId>
    <artifactId>global-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Maven global parent project</name>
    
    <scm>               
        <connection>scm:svn:file:///var/svn/repos/common/maven/global-parent</connection>
        <developerConnection>scm:svn:file:///var/svn/repos/common/maven/global-parent</developerConnection>
    </scm> 

    <!-- repositories>

        <repository>
            <id>mvn2</id>
            <name>Maven2 central repository</name>
            <url>http://repo2.maven.org/maven2</url>
        </repository>

        <repository>
            <id>sun-java</id>
            <name>sun-java</name>
            <url>http://download.java.net/maven/2/</url>
        </repository>

        <repository>
            <id>jboss</id>
            <name>jboss</name>
            <url>http://repository.jboss.org/maven2/</url>
        </repository>

    </repositories>
    
    <pluginRepositories>
        
        <pluginRepository>
            <id>tlc</id>
            <name>Maven codehouse</name>
            <url>http://snapshots.repository.codehaus.org</url>
        </pluginRepository>
        
        <pluginRepository>
            <id>tlc</id>
            <name>Maven codehouse</name>
            <url>http://cropwiki.irri.org/m2repo/</url>
        </pluginRepository>
        
        <pluginRepository>
            <id>mvn2</id>
            <name>Maven2 central repository</name>
            <url>http://repo2.maven.org/maven2</url>
        </pluginRepository>
        
    </pluginRepositories -->
    
    <profiles>
      <profile>
		<id>dev-test-profile</id>
		<activation>
		  <activeByDefault>true</activeByDefault>
		</activation>
		<build>
		  <plugins>
		    <plugin>
	                <groupId>org.apache.maven.plugins</groupId>
	                <artifactId>maven-surefire-plugin</artifactId>
	                <configuration>
	                    <failIfNoTests>false</failIfNoTests>
	                    
	                    <forkMode>once</forkMode>
	                    
	                    <!--  -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y -->
	                    <argLine>-Xmx512M -server -da</argLine>
	                    <disableXmlReport>false</disableXmlReport>
					    <excludes>
					      <exclude>**/*ExtendedTest.java</exclude>
					    </excludes>
					    <includes>
					      <include>**/*Test.java</include>
					    </includes>
	                </configuration>
		    </plugin>
		  </plugins>
		</build>
      </profile>
      <profile>
	<id>extended-test-profile</id>
		<activation>
		  <property>
		    <name>extendedTest</name>
		  </property>
		</activation>
		<build>
		  <plugins>
		    <plugin>
	                <groupId>org.apache.maven.plugins</groupId>
	                <artifactId>maven-surefire-plugin</artifactId>
	                <configuration>
	                    <failIfNoTests>false</failIfNoTests>
	                    
	                    <forkMode>once</forkMode>
	                    
	                    <!--  -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y -->
	                    <argLine>-DextendedTest -Xmx512M -server -da</argLine>
	                    <disableXmlReport>true</disableXmlReport>
			    <includes>
			      <include>**/*Test.java</include>
			    </includes>
	                </configuration>
		    </plugin>
		  </plugins>
		</build>
      </profile>
    </profiles>

    <build>
        <directory>target</directory>
        
        <outputDirectory>target/classes</outputDirectory>
        <finalName>${artifactId}-${version}</finalName>
        <testOutputDirectory>target/test-classes</testOutputDirectory>
        <sourceDirectory>src</sourceDirectory>
        <scriptSourceDirectory>scripts</scriptSourceDirectory>
        <testSourceDirectory>test</testSourceDirectory>
        <resources>
            <resource>
                <directory>src-res</directory>
                <!-- excludes>
                    <exclude>*app.properties</exclude>
                </excludes -->
            </resource>
            <!-- resource>
                <directory>src-res</directory>
                <includes>
                    <include>*app.properties</include>
                </includes>
                <filtering>true</filtering>
            </resource -->
        </resources>
        <testResources>
            <testResource>
                <directory>test-res</directory>
                <!-- excludes>
                    <exclude>*app.properties</exclude>
                </excludes -->
            </testResource>
            <!-- testResource>
                <directory>test-res-f</directory>
                <includes>
                    <include>*app.properties</include>
                </includes>
                <filtering>true</filtering>
            </testResource -->
        </testResources>
        
        <plugins>
		<plugin>
        		<groupId>org.codehaus.mojo</groupId>
		        <artifactId>build-helper-maven-plugin</artifactId>
		        <version>1.5</version>
		        <executions>
		          <execution>
		            <id>add-source</id>
		            <phase>generate-sources</phase>
		            <goals>
		              <goal>add-source</goal>
		            </goals>
		            <configuration>
		              	<sources>
                			<source>gen2</source> <!-- can not use 'gen' as it's conflicting with eclipse -->
              			</sources>
            		    </configuration>
		          </execution>
		        </executions>
		</plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.0-beta-4</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <doCheck>false</doCheck>
                    <doUpdate>false</doUpdate>
                </configuration>
            </plugin>
            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>${basedir}/web</directory>
                        </resource>
                    </webResources>
                    <archive>
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <manifestEntries>
                            <SVN-revision>${buildNumber}</SVN-revision>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <!-- manifest>
                         <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                         </manifest -->
                    <archive>
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <manifestEntries>
                            <SVN-revision>${buildNumber}</SVN-revision>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

        </plugins>
    </build>
    
    <dependencyManagement>
        <dependencies>

          <dependency>
              <groupId>android</groupId>
              <artifactId>android</artifactId>
              <version>1.1</version>
              <scope>provided</scope>
          </dependency>

          <dependency>
              <groupId>android</groupId>
              <artifactId>android</artifactId>
              <version>1.5</version>
              <scope>provided</scope>
          </dependency>

          <dependency>
              <groupId>android</groupId>
              <artifactId>android</artifactId>
              <version>1.6</version>
              <scope>provided</scope>
          </dependency>

          <dependency>
              <groupId>android</groupId>
              <artifactId>android</artifactId>
              <version>2.0</version>
              <scope>provided</scope>
          </dependency>

          <dependency>
              <groupId>android</groupId>
              <artifactId>android</artifactId>
              <version>2.0.1</version>
              <scope>provided</scope>
          </dependency>

          <dependency>
              <groupId>android</groupId>
              <artifactId>android</artifactId>
              <version>2.1</version>
              <scope>provided</scope>
          </dependency>

          <dependency>
              <groupId>com.google.android</groupId>
              <artifactId>maps</artifactId>
              <version>3</version>
              <scope>provided</scope>
          </dependency>

          <dependency>
              <groupId>com.google.android</groupId>
              <artifactId>maps</artifactId>
              <version>4</version>
              <scope>provided</scope>
          </dependency>

          <dependency>
              <groupId>com.google.android</groupId>
              <artifactId>maps</artifactId>
              <version>5</version>
              <scope>provided</scope>
          </dependency>

          <dependency>
              <groupId>com.google.android</groupId>
              <artifactId>maps</artifactId>
              <version>6</version>
              <scope>provided</scope>
          </dependency>

          <dependency>
              <groupId>com.google.android</groupId>
              <artifactId>maps</artifactId>
              <version>7</version>
              <scope>provided</scope>
          </dependency>


		<!-- Exclusions in dependencies bellow are becuase of wrong version format f eclipse artefacts.
			See http://jira.codehaus.org/browse/MNG-3518  -->
          <dependency>
			<groupId>org.eclipse.equinox</groupId>
			<artifactId>common</artifactId>
			<version>3.3.0-v20070426</version>
          </dependency>

          <dependency>
			<groupId>org.eclipse</groupId>
			<artifactId>jface</artifactId>
			<version>3.3.0-I20070606-0010</version>

			<exclusions>
			        <exclusion>
			          <groupId>org.eclipse.equinox</groupId>
			          <artifactId>app</artifactId>
			        </exclusion>

			        <exclusion>
			          <groupId>org.eclipse</groupId>
			          <artifactId>swt</artifactId>
			        </exclusion>

			        <exclusion>
			          <groupId>org.eclipse.core</groupId>
			          <artifactId>commands</artifactId>
			        </exclusion>

		     	</exclusions>

          </dependency>

          <dependency>
			<groupId>org.eclipse</groupId>
			<artifactId>osgi</artifactId>
			<version>3.3.0-v20070530</version>
          </dependency>

          <dependency>
			<groupId>org.eclipse.ui</groupId>
			<artifactId>workbench</artifactId>
			<version>3.3.0-I20070608-1100</version>

		        <exclusions>
			        <exclusion>
					<groupId>org.eclipse</groupId>
					<artifactId>jface</artifactId>
			        </exclusion>


			        <exclusion>
			          <groupId>org.eclipse.core</groupId>
			          <artifactId>expressions</artifactId>
			        </exclusion>

			        <exclusion>
			          <groupId>org.eclipse</groupId>
			          <artifactId>swt</artifactId>
			        </exclusion>

			        <exclusion>
			          <groupId>org.eclipse.jface</groupId>
			          <artifactId>databinding</artifactId>
			        </exclusion>

			        <exclusion>
			          <groupId>org.eclipse.core</groupId>
			          <artifactId>databinding</artifactId>
			        </exclusion>

		        </exclusions>

          </dependency>

          <dependency>
			<groupId>org.eclipse.core</groupId>
			<artifactId>runtime</artifactId>
			<version>3.3.100-v20070530</version>
			<exclusions>
			        <exclusion>
			          <groupId>org.eclipse.equinox</groupId>
			          <artifactId>app</artifactId>
			        </exclusion>
			</exclusions>
          </dependency>

          <dependency>
			<groupId>org.eclipse.core</groupId>
			<artifactId>resources</artifactId>
			<version>3.3.0-v20070604</version>
			<exclusions>
			        <exclusion>
			          <groupId>org.eclipse.equinox</groupId>
			          <artifactId>app</artifactId>
			        </exclusion>
		    	</exclusions>

          </dependency>

          <dependency>
			<groupId>org.eclipse.equinox</groupId>
			<artifactId>registry</artifactId>
			<version>3.3.0-v20070522</version>
          </dependency>

          <dependency>
			<groupId>org.eclipse.core</groupId>
			<artifactId>jobs</artifactId>
			<version>3.3.0-v20070423</version>
          </dependency>

          <dependency>
			<groupId>org.eclipse.swt.win32.win32</groupId>
			<artifactId>x86</artifactId>
			<version>3.3.0-v3346</version>
          </dependency>

            <dependency>
		<groupId>org.eclipse.jdt</groupId>
		<artifactId>core</artifactId>
		<version>3.3.0-v_771</version>

		<exclusions>
			<exclusion>
				<groupId>org.eclipse.equinox</groupId> 
				<artifactId>common</artifactId>
			</exclusion>
		</exclusions>
            </dependency>

            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.4</version>
		<scope>test</scope>
            </dependency>

		<dependency>
		    <groupId>org.simpleframework</groupId>
		    <artifactId>simple-xml</artifactId>
		    <version>2.3.2</version>

			<exclusions>
				<exclusion>
				  <groupId>stax</groupId>
				  <artifactId>stax</artifactId>
				</exclusion>

				<exclusion>
				  <groupId>stax</groupId>
				  <artifactId>stax-api</artifactId>
				</exclusion>

			</exclusions>

		</dependency>

            <dependency>
                <groupId>commons-dbcp</groupId>
                <artifactId>commons-dbcp</artifactId>
                <version>1.4</version>
                <scope>compile</scope>
            </dependency>


            
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate</artifactId>
                <version>3.2.7.ga</version>
            </dependency>

            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-annotations</artifactId>
                <version>3.4.0.GA</version>
            </dependency>
            
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-commons-annotations</artifactId>
                <version>3.3.0.ga</version>
            </dependency>
            
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.5.8</version>
            </dependency>
            
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl104-over-slf4j</artifactId>
                <version>1.5.8</version>
            </dependency>
            
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>1.5.8</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-beans</artifactId>
                <version>3.0.1.RELEASE</version>
            </dependency>


        <dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-support</artifactId>
                <version>2.0.8</version>
        </dependency>


            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>3.0.1.RELEASE</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context-support</artifactId>
                <version>3.0.1.RELEASE</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>3.0.1.RELEASE</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>3.0.1.RELEASE</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>3.0.1.RELEASE</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aop</artifactId>
                <version>3.0.1.RELEASE</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-tx</artifactId>
                <version>3.0.1.RELEASE</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-jdbc</artifactId>
                <version>3.0.1.RELEASE</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-context</artifactId>
                <version>3.0.1.RELEASE</version>
            </dependency>
            
            <dependency>
                <groupId>quartz</groupId>
                <artifactId>quartz</artifactId>
                <version>1.5.2</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework.ws</groupId>
                <artifactId>spring-oxm</artifactId>
                <version>1.5.9</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework.ws</groupId>
                <artifactId>spring-oxm-tiger</artifactId>
                <version>1.5.9</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework.ws</groupId>
                <artifactId>spring-oxm-tiger</artifactId>
                <version>1.5.9</version>
            </dependency>
            
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>2.5</version>
            </dependency>
            
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
                <version>3.0.1.RELEASE</version>
            </dependency>

            <dependency>
                <groupId>commons-httpclient</groupId>
                <artifactId>commons-httpclient</artifactId>
                <version>3.1</version>
            </dependency>

            <dependency>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-servlet-tester</artifactId>
                <version>6.1.5</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
                <scope>provided</scope>
                <version>1.1.2</version>
            </dependency>

            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jsp-api</artifactId>
                <scope>provided</scope>
	        <version>2.0</version>
            </dependency>
        
            <dependency>
                <groupId>taglibs</groupId>
                <artifactId>standard</artifactId>
                <scope>provided</scope>
                <version>1.1.2</version>
            </dependency>            

            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>5.1.12</version>
            </dependency>

        </dependencies>
        
    </dependencyManagement>
    
</project>
<file_sep>/trunk/common/java/common-web/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.mvwsolutions</groupId>
        <artifactId>global-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.mvwsolutions.common</groupId>
    <artifactId>java-common-web</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Java common web</name>

    <scm>
        <connection>scm:svn:file:///var/svn/repos/common/java/common-web</connection>
        <developerConnection>scm:svn:file:///var/svn/repos/common/java/common-web</developerConnection>
        <tag>HEAD</tag>
    </scm>    

    <dependencies>
        
        <!-- projects -->

        <dependency>
            <groupId>com.mvwsolutions.common</groupId>
            <artifactId>java-common</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

        
        <!-- third party libs -->
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>


        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-oxm</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-oxm-tiger</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
        </dependency>
        
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>


            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
            </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl104-over-slf4j</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>
        


    </dependencies>
    
</project>
<file_sep>/trunk/common/java/common-test/src/com/mvwsolutions/common/test/web/SpringServletTestCase.java
package com.mvwsolutions.common.test.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.mortbay.jetty.testing.HttpTester;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.mvwsolutions.common.Utils;
import com.mvwsolutions.common.web.xml.Response;

/**
 * 
 * @author smineyev
 * 
 */
public class SpringServletTestCase {
    private static final Logger logger = LoggerFactory
            .getLogger(SpringServletTestCase.class);

    protected static SpringServletTester tester;

    protected HttpTester httpRequest;

    protected HttpTester httpResponse;

    @BeforeClass
    public static void startServletTester() throws Exception {
        tester = new SpringServletTester();
        tester.start();
    }

    @Before
    public final void beforeRequest() {
        this.httpRequest = new HttpTester();
        this.httpResponse = new HttpTester();
    }

    protected final HttpTester sendRequest(String uri) throws Exception {

        final boolean post = this.httpRequest.getContent() != null;

        this.httpRequest.setMethod(post ? "POST" : "GET");
        this.httpRequest.setURI(uri);
        this.httpRequest.setVersion("HTTP/1.1");
        this.httpRequest.addHeader("Host", "tester");
        if (post) {
            this.httpRequest.setHeader("Content-Type",
                    "application/x-www-form-urlencoded;charset=UTF-8");
        }

        final String request = this.httpRequest.generate();

        logger.debug("(!) request: " + request);
        String rawHttpResponse = tester.getResponses(request);
        logger.debug("(!) response: " + rawHttpResponse);
        this.httpResponse.parse(rawHttpResponse);

        return this.httpResponse;
    }

    public void postViaRemoteConnector(String url, String body, String cookies) {
        try {
            HttpClient httpClient = new HttpClient();
            PostMethod postMethod = new PostMethod(url);
            try {
                if (body != null) {
                    StringRequestEntity sre = new StringRequestEntity(body, "",
                            "UTF-8");
                    postMethod.setRequestEntity(sre);
                }
                // for (Map.Entry<String, String> entry : cookies.entrySet()) {
                // postMethod.addRequestHeader("Cookie", entry.getKey() + "="
                // + entry.getValue());
                // }
                if (cookies != null && cookies.length() > 0) {
                    postMethod.addRequestHeader("Cookie", cookies);
                }
                httpResponse.setStatus(httpClient.executeMethod(postMethod));
                httpResponse.setContent(new String(
                        postMethod.getResponseBody(), "UTF-8"));
            } finally {
                postMethod.releaseConnection();
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    protected String getResponseCookie(String cName) {
        Map<String, String> cookieMap = getCockies();
        return cookieMap.get(cName);
    }

    protected Map<String, String> getCockies() {
        Map<String, String> cookieMap = new HashMap<String, String>();
        String cookiesStr = httpResponse.getHeader("Set-Cookie");
        List<String> cookies = Utils.tokenize(cookiesStr, ";");
        for (String cockie : cookies) {
            int p = cockie.indexOf('=');
            if (p != -1) {
                String name = cockie.substring(0, p);
                String value = cockie.substring(p + 1);
                cookieMap.put(name, value);
            }
        }
        return cookieMap;
    }

    protected final <T> T getResponse(Class<T> expectedResponseClass,
            Class... classesToBeBound) {
    	Assert.assertEquals("Bad HTTP response code: " + this.httpResponse.getStatus()
                + ", content: " + this.httpResponse.getReason(), 200,
                this.httpResponse.getStatus());

    	Assert.assertNotNull("Response is empty: " + this.httpResponse.getStatus()
                + " " + this.httpResponse.getReason(), this.httpResponse
                .getContent());

        final Class[] classes = new Class[classesToBeBound.length + 2];

        classes[0] = Response.class;
        classes[1] = expectedResponseClass;
        System.arraycopy(classesToBeBound, 0, classes, 2,
                classesToBeBound.length);

        final String content = this.httpResponse.getContent();

        Object responseObject;
        try {
            final Serializer unmarshaller = new Persister();
            responseObject = unmarshaller.read(Response.class, content);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if (responseObject.getClass() == expectedResponseClass) {
            return expectedResponseClass.cast(responseObject);
        } else {
            if (responseObject.getClass() != Response.class) {
                Assert.fail("Actual response is neither instance of "
                        + Response.class.getName() + " nor "
                        + expectedResponseClass.getName());
            }
        }

        Response response = (Response) responseObject;

        if (expectedResponseClass == Response.class) {
            return expectedResponseClass.cast(responseObject);
        }

        // to move on and extract result object we need to make sure that
        // request is successful
        Assert.assertNotNull("Result object is null", response);
        Assert.assertTrue("HTTP request failed, the cause: " + response.getError(),
                response.isSuccess());

        Assert.assertTrue("Response is " + response.getResultObject() + ", but "
                + expectedResponseClass.getName() + " expected",
                expectedResponseClass.isInstance(response.getResultObject()));

        return expectedResponseClass.cast(response.getResultObject());
    }

    @After
    public final void afterResponse() {
        this.httpRequest = null;
        this.httpResponse = null;
    }

    @AfterClass
    public static void stopServletTester() throws Exception {
        if (tester != null) {
            tester.stop();
            tester = null;
        }
    }

}
<file_sep>/trunk/common/android/DroidCommand/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.mvwsolutions</groupId>
        <artifactId>global-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <groupId>com.mvwsolutions.common.android</groupId>
    <artifactId>DroidCommand</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Andriod common Command Framework</name>

    <scm>
        <connection>scm:svn:file:///var/svn/repos/common/android/DroidCommand</connection>
        <developerConnection>scm:svn:file:///var/svn/repos/common/android/DroidCommand</developerConnection>
        <tag>HEAD</tag>
    </scm>    

    <dependencies>
        
        <!-- projects -->

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        

    </dependencies>
    
</project>
<file_sep>/trunk/common/android/DroidCommand/src/com/mvw/event/CommandEvent.java
package com.mvw.event;


public abstract class CommandEvent {
	public abstract String getType();

	// default to async
	private SYNC_TYPE syncType = SYNC_TYPE.Async;

	public boolean isAsync() {
		if (syncType == SYNC_TYPE.Async) {
			return true;
		} else {
			return false;
		}
	}

	public CommandEvent() {
	}

	public CommandEvent(SYNC_TYPE syncType) {
		super();
		this.syncType = syncType;
	}

	public enum SYNC_TYPE {
		Async, Sync
	}

}
<file_sep>/trunk/common/android/DroidCommand/test/com/mvw/command/TestCommand.java
package com.mvw.command;

import com.mvw.controller.CommandControllerTest;
import com.mvw.event.CommandEvent;

public class TestCommand extends Command {

	
	@Override
	public void execute(CommandEvent event) {
		synchronized (CommandControllerTest.lock) {
				
			CommandControllerTest.commandRan = true;
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			CommandControllerTest.threadCount.decrementAndGet();
			CommandControllerTest.lock.notify();
		}
		return;
	}

}
