diff --git a/exo.core.component.database/pom.xml b/exo.core.component.database/pom.xml deleted file mode 100644 index 73ad6860d..000000000 --- a/exo.core.component.database/pom.xml +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - 4.0.0 - - - io.meeds.core - core-parent - 7.0.x-exo-SNAPSHOT - - - exo.core.component.database - - Meeds:: PLF Core :: Component :: Database Service - Implementation of Database Service of Exoplatform SAS eXo Core' project. - - - 0.18 - - - - - io.meeds.kernel - exo.kernel.component.common - - - io.meeds.kernel - exo.kernel.commons - - - io.meeds.kernel - exo.kernel.container - - - io.meeds.kernel - exo.kernel.component.cache - - - io.meeds.kernel - exo.kernel.commons.test - test - - - javax.resource - javax.resource-api - test - - - org.hsqldb - hsqldb - test - - - com.experlog - xapool - true - - - org.jboss.logging - jboss-logging - - - org.hibernate.orm - hibernate-core - - - org.slf4j - slf4j-api - - - org.jboss.spec.javax.transaction - jboss-transaction-api_1.1_spec - - - org.jboss.logging - jboss-logging - - - org.javassist - javassist - - - - - commons-dbcp - commons-dbcp - runtime - - - xerces - xercesImpl - - - commons-pool - commons-pool - - - - - commons-pool - commons-pool - runtime - - - com.atomikos - transactions-jta - provided - - - org.mockito - mockito-all - - - - - - - - - maven-antrun-plugin - - - prepare-test-policy - process-test-resources - - - Creating Access Policy for tests - - - - - - - - - - - - - - - - - run - - - - - - - diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DAO.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/DAO.java deleted file mode 100644 index f45a459f9..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DAO.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.exoplatform.commons.utils.PageList; -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.Statement; -import java.util.List; - -/** - * Created by The eXo Platform SAS Author : Tuan Nguyen - * tuan08@users.sourceforge.net Apr 4, 2006 - */ -public abstract class DAO -{ - - /** - * Logger. - */ - private static final Log LOG = ExoLogger.getLogger("exo.core.component.database.DAO"); - - protected ExoDatasource eXoDS_; - - protected DBObjectMapper mapper_; - - static int totalQueryTime = 0; - - static int totalBathTime = 0; - - static int totalCloseConnect = 0; - - public DAO(ExoDatasource datasource) - { - eXoDS_ = datasource; - mapper_ = new ReflectionMapper(); - } - - public DAO(ExoDatasource datasource, DBObjectMapper mapper) - { - eXoDS_ = datasource; - mapper_ = mapper; - } - - public ExoDatasource getExoDatasource() - { - return eXoDS_; - } - - abstract public T load(long id) throws Exception; - - abstract public PageList loadAll() throws Exception; - - abstract public void update(T bean) throws Exception; - - abstract public void update(List beans) throws Exception; - - abstract public void save(T bean) throws Exception; - - abstract public void save(List beans) throws Exception; - - abstract public void remove(T bean) throws Exception; - - abstract public T remove(long id) throws Exception; - - abstract public T createInstance() throws Exception; - - protected T loadUnique(String query) throws Exception - { - Connection connection = eXoDS_.getConnection(); - try - { - return loadUnique(connection, query); - } - finally - { - eXoDS_.closeConnection(connection); - } - } - - protected T loadUnique(Connection connection, String query) throws Exception - { - Statement statement = null; - try - { - statement = connection.createStatement(); - ResultSet resultSet = statement.executeQuery(query); - if (!resultSet.next()) - { - return null; - } - T bean = createInstance(); - mapper_.mapResultSet(resultSet, bean); - resultSet.close(); - return bean; - } - finally - { - if (statement != null) - statement.close(); - } - } - - protected void loadInstances(String loadQuery, List list) throws Exception - { - Connection connection = eXoDS_.getConnection(); - try - { - loadInstances(connection, loadQuery, list); - } - finally - { - eXoDS_.closeConnection(connection); - } - } - - protected void loadInstances(Connection connection, String loadQuery, List list) throws Exception - { - Statement statement = connection.createStatement(); - ResultSet resultSet = null; - try - { - resultSet = statement.executeQuery(loadQuery); - while (resultSet.next()) - { - T bean = createInstance(); - mapper_.mapResultSet(resultSet, bean); - list.add(bean); - } - } - finally - { - if (resultSet != null) - { - try - { - resultSet.close(); - } - catch (Exception e) - { - LOG.debug("Could not close the result set"); - } - } - try - { - statement.close(); - } - catch (Exception e) - { - LOG.debug("Could not close the statement"); - } - } - } - - protected void execute(String query, T bean) throws Exception - { - Connection connection = eXoDS_.getConnection(); - try - { - execute(connection, query, bean); - } - finally - { - eXoDS_.closeConnection(connection); - } - } - - protected void execute(Connection connection, String query, T bean) throws Exception - { - PreparedStatement statement = connection.prepareStatement(query); - if (bean != null) - mapper_.mapUpdate(bean, statement); - statement.executeUpdate(); - eXoDS_.commit(connection); - statement.close(); - } - - public E loadDBField(String query) throws Exception - { - Connection connection = eXoDS_.getConnection(); - try - { - return this. loadDBField(connection, query); - } - finally - { - eXoDS_.closeConnection(connection); - } - } - - @SuppressWarnings("unchecked") - protected E loadDBField(Connection connection, String query) throws Exception - { - Statement statement = connection.createStatement(); - long startGet = System.currentTimeMillis(); - ResultSet resultSet = statement.executeQuery(query); - totalQueryTime += System.currentTimeMillis() - startGet; - if (!resultSet.next()) - return null; - E value = (E)resultSet.getObject(1); - resultSet.close(); - statement.close(); - return value; - } - - protected void execute(String template, List beans) throws Exception - { - Connection connection = eXoDS_.getConnection(); - try - { - execute(connection, template, beans); - } - finally - { - eXoDS_.closeConnection(connection); - } - } - - protected void execute(Connection connection, String template, List beans) throws Exception - { - PreparedStatement statement = connection.prepareStatement(template); - QueryBuilder builder = eXoDS_.getQueryBuilder(); - for (T bean : beans) - { - String query = builder.mapDataToSql(template, mapper_.toParameters(bean)); - statement.addBatch(query); - LOG.info(" addBatch " + query); - } - statement.executeBatch(); - statement.close(); - eXoDS_.commit(connection); - } - - public DBObjectMapper getDBObjectMapper() - { - return mapper_; - } - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObject.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObject.java deleted file mode 100644 index cbda6af95..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObject.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -/** - * Created by The eXo Platform SAS - * Author : Tuan Nguyen tuan.nguyen@exoplatform.com Mar 15, 2007 - */ -abstract public class DBObject -{ - - protected long dbObjectId_ = -1; - - public long getDBObjectId() - { - return dbObjectId_; - } - - public void setDBObjectId(long id) - { - dbObjectId_ = id; - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObjectEvent.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObjectEvent.java deleted file mode 100644 index 0a4a6a140..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObjectEvent.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.exoplatform.services.listener.Event; - -/** - * Created by The eXo Platform SAS - * Author : Nhu Dinh Thuan nhudinhthuan@exoplatform.com Apr 6, 2007 - */ -public class DBObjectEvent, T extends DBObject> extends Event -{ - - public DBObjectEvent(String name, E e, T t) - { - super(name, e, t); - } - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObjectMapper.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObjectMapper.java deleted file mode 100644 index f371fa9fd..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObjectMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import java.sql.PreparedStatement; -import java.sql.ResultSet; - -/** - * Created by The eXo Platform SAS - * Author : Nhu Dinh Thuan nhudinhthuan@exoplatform.com Mar 29, 2007 - */ -public interface DBObjectMapper -{ - - public void mapUpdate(T bean, PreparedStatement statement) throws Exception; - - public String[][] toParameters(T bean) throws Exception; - - public void mapResultSet(ResultSet res, T bean) throws Exception; - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObjectPageList.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObjectPageList.java deleted file mode 100644 index 90ed43c57..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObjectPageList.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.hibernate.Session; -import org.hibernate.query.Query; - -import org.exoplatform.commons.utils.PageList; - -/** - * @author Tuan Nguyen (tuan08@users.sourceforge.net) - * @since Oct 21, 2004 - * @version $Id: DBObjectPageList.java 5332 2006-04-29 18:32:44Z geaz $ - */ -public class DBObjectPageList extends PageList -{ - - private String findQuery_; - - private String countQuery_; - - private HibernateService service_; - - private Map binding = new HashMap(); - - public DBObjectPageList(HibernateService service, Class objectType) throws Exception - { - super(20); - service_ = service; - findQuery_ = "from o in class " + objectType.getName(); - countQuery_ = "select count(o) from " + objectType.getName() + " o"; - Session session = service_.openSession(); - List l = session.createQuery(countQuery_).list(); - Number count = (Number)l.get(0); - setAvailablePage(count.intValue()); - } - - public DBObjectPageList(HibernateService service, ObjectQuery oq) throws Exception - { - super(20); - service_ = service; - findQuery_ = oq.getHibernateQueryWithBinding(); - countQuery_ = oq.getHibernateCountQueryWithBinding(); - binding = oq.getBindingFields(); - - Session session = service_.openSession(); - - Query countQuery = session.createQuery(countQuery_); - bindFields(countQuery); - - List l = countQuery.list(); - - Number count = (Number)l.get(0); - setAvailablePage(count.intValue()); - } - - public DBObjectPageList(HibernateService service, int pageSize, String query, String countQuery) throws Exception - { - super(pageSize); - service_ = service; - findQuery_ = query; - countQuery_ = countQuery; - Session session = service_.openSession(); - List l = session.createQuery(countQuery_).list(); - Number count = (Number)l.get(0); - setAvailablePage(count.intValue()); - } - - @Override - protected void populateCurrentPage(int page) throws Exception - { - Session session = service_.openSession(); - Query query = session.createQuery(findQuery_); - bindFields(query); - - int from = getFrom(); - query.setFirstResult(from); - query.setMaxResults(getTo() - from); - currentListPage_ = query.list(); - } - - @Override - public List getAll() throws Exception - { - Session session = service_.openSession(); - - Query query = session.createQuery(findQuery_); - bindFields(query); - - return query.list(); - } - - /** - * Bind a value to a named query parameter. - * - * @param query - */ - private void bindFields(Query query) - { - for (Entry entry : binding.entrySet()) - { - query.setParameter(entry.getKey(), entry.getValue()); - } - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObjectQuery.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObjectQuery.java deleted file mode 100644 index 9c33c5eed..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBObjectQuery.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.exoplatform.services.database.annotation.Table; - -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * @author Tuan Nguyen (tuan08@users.sourceforge.net) - * @since Nov 25, 2004 - * @version $Id: ObjectQuery.java 6006 2006-06-06 10:01:27Z thangvn $ - */ -public class DBObjectQuery -{ - - private static DateTimeFormatter ft_ = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); - - private Class type_; - - private String orderBy_; - - private String groupBy_; - - private List parameters_; - - private List selectParameter_; - - public DBObjectQuery(Class type) - { - type_ = type; - parameters_ = new ArrayList(3); - selectParameter_ = new ArrayList(10); - } - - public DBObjectQuery addEQ(String field, Object value) - { - if (value == null) - return this; - parameters_.add(new Parameter(field, " = ", value)); - return this; - } - - public DBObjectQuery addGT(String field, Object value) - { - if (value == null) - return this; - parameters_.add(new Parameter(field, " > ", value)); - return this; - } - - public DBObjectQuery addLT(String field, Object value) - { - if (value == null) - return this; - parameters_.add(new Parameter(field, " < ", value)); - return this; - } - - public DBObjectQuery addLIKE(String field, String value) - { - if (value == null || value.length() < 1) - return this; - parameters_.add(new Parameter(field, " LIKE ", optimizeInputString(value))); - return this; - } - - public DBObjectQuery addSUM(String field) - { - selectParameter_.add(new Parameter("SUM", field)); - return this; - } - - public DBObjectQuery addSelect(String field, String value) - { - selectParameter_.add(new Parameter(field, " AS ", value)); - return this; - } - - public DBObjectQuery addSelect(String... fields) - { - for (String field : fields) - { - selectParameter_.add(new Parameter(field, null, null)); - } - return this; - } - - public DBObjectQuery addSelect(String field) - { - selectParameter_.add(new Parameter(field, null, null)); - return this; - } - - public DBObjectQuery addSelectCount(String type) - { - selectParameter_.add(new Parameter("countselect", type)); - return this; - } - - public DBObjectQuery addSelectMaxMin(String op, String field) - { - selectParameter_.add(new Parameter(op, field)); - return this; - } - - public DBObjectQuery setAscOrderBy(String field) - { - orderBy_ = " ORDER BY " + field + " ASC"; - return this; - } - - public DBObjectQuery setDescOrderBy(String field) - { - orderBy_ = " ORDER BY " + field + " DESC"; - return this; - } - - public DBObjectQuery setGroupBy(String field) - { - groupBy_ = " GROUP BY " + field; - return this; - } - - public String toQuery() - { - return constuctQuery(false); - } - - public String toQueryUseOR() - { - return constuctQuery(true); - } - - private String constuctQuery(boolean useOR) - { - StringBuilder builder = new StringBuilder("SELECT "); - if (selectParameter_.size() > 0) - { - for (int i = 0; i < selectParameter_.size(); i++) - { - if (i > 0) - builder.append(", "); - parameters_.get(i).build(builder); - } - } - else - { - builder.append(" * "); - } - - Table table = type_.getAnnotation(Table.class); - builder.append(" FROM ").append(table.name()); - if (parameters_.size() > 0) - { - builder.append(" WHERE "); - for (int i = 0; i < parameters_.size(); i++) - { - if (i > 0) - builder.append(useOR ? " OR " : " AND "); - parameters_.get(i).build(builder); - } - } - if (orderBy_ != null) - builder.append(orderBy_); - return builder.toString(); - } - - public String toCountQuery() - { - return consturctCountQuery(false); - } - - public String toCountQueryUseOR() - { - return consturctCountQuery(true); - } - - private String consturctCountQuery(boolean useOR) - { - StringBuilder builder = new StringBuilder(); - Table table = type_.getAnnotation(Table.class); - builder.append("SELECT COUNT(*) FROM ").append(table.name()); - if (parameters_.size() > 0) - { - builder.append(" WHERE "); - for (int i = 0; i < parameters_.size(); i++) - { - if (i > 0) - builder.append(useOR ? " OR " : " AND "); - parameters_.get(i).build(builder); - } - } - return builder.toString(); - } - - /* - * public String getHibernateGroupByQuery() { StringBuilder b = new - * StringBuilder("SELECT ") ; if(selectParameter_.size() > 0){ for(int i = 0; - * i < selectParameter_.size(); i++){ Parameter p = selectParameter_.get(i) ; - * if(p.op_.equals("fieldselect")){ b.append(p.field_) ; }else - * if(p.op_.equals("countselect")){ b.append("COUNT"); if (p.field_ != "" || - * p.field_.length() > 0){ b.append("(").append(p.field_).append(" )"); }else{ - * b.append("(*)"); } }else { - * b.append(p.op_).append("(").append(p.field_).append(") "); } if(i < - * selectParameter_.size() - 1 ) b.append(" , ") ; } } Table table = - * type_.getAnnotation(Table.class) ; b.append(" FROM ").append(table.name()) - * ; if(parameters_.size() > 0) { b.append(" WHERE ") ; for(int i = 0; i < - * parameters_.size(); i ++) { if(i > 0) b.append(" AND ") ; Parameter p = - * parameters_.get(i) ; if(p.value_ instanceof String) { - * b.append(p.field_).append(p.op_).append("'").append(p.value_).append("'") ; - * } else if(p.value_ instanceof Date) { String value = ft_.format((Date) - * p.value_) ; - * b.append(' ').append(p.field_).append(p.op_).append("'").append( - * value).append("'") ; } else if(p.op_.equals("max") || p.op_.equals("min")){ - * b.append(p.op_).append("(").append(p.field_).append(") "); } else{ - * b.append(' ').append(p.field_).append(p.op_).append(p.value_); } } } - * if(groupBy_ != null ) b.append(groupBy_ ); if(orderBy_ != null ) - * b.append(orderBy_ ); return b.toString() ; } - */ - - public String optimizeInputString(String value) - { - value = value.replace('*', '%'); - value = value.replaceAll("'", "'"); - value = value.replaceAll("<", "<"); - value = value.replaceAll(">", ">"); - return value; - } - - public List getParameters() - { - return parameters_; - } - - static public class Parameter - { - - String op_; - - String field_; - - String label_; - - Object value_; - - public Parameter(String field, String op, Object value) - { - op_ = op; - field_ = field; - value_ = value; - } - - public Parameter(String op, String field) - { - op_ = op; - field_ = field; - } - - void build(StringBuilder builder) - { - builder.append(' ').append(field_).append(op_); - if (op_ == null || op_.trim().length() < 1 || value_ == null) - return; - builder.append(' '); - if (CharSequence.class.isInstance(value_)) - { - builder.append('\'').append(value_).append('\''); - } - else if (value_ instanceof Date) - { - LocalDateTime ldt = LocalDateTime.ofInstant(((Date)value_).toInstant(), ZoneId.systemDefault()); - String value = ldt.format(ft_); - builder.append("'").append(value).append("'"); - } - else - { - builder.append(value_); - } - } - } - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBQueryParameter.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBQueryParameter.java deleted file mode 100644 index 2ac81b6f9..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBQueryParameter.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import java.util.Comparator; - -/** - * Created by The eXo Platform SAS - * Author : Nhu Dinh Thuan nhudinhthuan@exoplatform.com Apr 2, 2007 - */ -public class DBQueryParameter -{ - - protected String name; - - protected String value; - - protected Operator operator; - - protected int order = WHERE; - - public final static int SELECT = 1, WHERE = 3, GROUP = 4, HAVING = 5, ORDER = 6; - - protected DBQueryParameter() - { - } - - public DBQueryParameter(String value) - { - this.value = value; - } - - public DBQueryParameter(String name, String value) - { - this.name = name; - this.value = value; - } - - public DBQueryParameter(String name, String value, Operator operator) - { - this.name = name; - this.value = value; - this.operator = operator; - } - - public void build(StringBuilder builder) - { - if (order == WHERE && builder.indexOf(" WHERE ") < 0) - builder.append(" WHERE "); - builder.append(' ').append(name).append(operator.toString()).append(value); - } - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - public Operator getOperator() - { - return operator; - } - - public void setOperator(Operator operator) - { - this.operator = operator; - } - - public String getValue() - { - return value; - } - - public void setValue(String value) - { - this.value = value; - } - - public final static Comparator PARAMETER_SORT = new Comparator() - { - public int compare(DBQueryParameter param1, DBQueryParameter param2) - { - return param1.order - param2.order; - } - }; - - public static class Operator - { - - public final static Operator AND = new Operator(" AND "); - - public final static Operator OR = new Operator(" OR "); - - public final static Operator LESS_THAN = new Operator(" < "); - - public final static Operator LESS_THAN_AND_EQUALS = new Operator(" <= "); - - public final static Operator GREATER_THAN = new Operator(" > "); - - public final static Operator GREATER_THAN_AND_EQUALS = new Operator(" >= "); - - public final static Operator LIKE = new Operator(" LIKE "); - - public final static Operator IN = new Operator(" IN "); - - public final static Operator IS = new Operator(" IS "); - - public final static Operator EQUALS = new Operator(" = "); - - private String value; - - public Operator(String value) - { - this.value = value; - } - - public String toString() - { - return value; - } - - public String getValue() - { - return value; - } - - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBTableManager.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBTableManager.java deleted file mode 100644 index 53e2f3bef..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DBTableManager.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -/** - * Created by The eXo Platform SAS - * Author : Tuan Nguyen tuan08@users.sourceforge.net Apr 4, 2006 - * The DBTableManager is an interface - * to help the developer to check if a table is existed or not and create/drop a - * table. We can implement more one more DBTableManager according to the - * database type and version. - */ -abstract public class DBTableManager -{ - /** - * This method should: 1. Extract the table information such table name and - * table fields from the class T, the information are annotated in the class T - * 2. Generate the SQL statement and create the table - * - * @param - * @param type - * @param dropIfExist - * @throws Exception - */ - abstract public void createTable(Class type, boolean dropIfExist) throws Exception; - - /** - * This method should: 1. Extract the table information from the class T, the - * information are annotated in the class T 2. Generate the SQL statement and - * drop the table - * - * @param - * @param type - * @throws Exception - */ - abstract public void dropTable(Class type) throws Exception; - - /** - * This method should: 1. Extract the table information from the class T, the - * information are annotated in the class T 2. Check to see if the table is - * existed in the database system - * - * @param - * @param type - * @return - * @throws Exception - */ - abstract public boolean hasTable(Class type) throws Exception; - - /** - * This method should check the database type and version and create a - * corresponded DBTableManager - * - * @param datasource - * @return - */ - final static public DBTableManager createDBTableManager(ExoDatasource datasource) - { - if (datasource.getDatabaseType() == ExoDatasource.HSQL_DB_TYPE) - { - return new StandardSQLTableManager(datasource); - } - else if (ExoDatasource.ORACLE_DB_TYPE == datasource.getDatabaseType()) - { - return new OracleTableManager(datasource); - } - else if (ExoDatasource.SQL_SERVER_TYPE == datasource.getDatabaseType()) - { - return new MSSQLServerTableManager(datasource); - } - return new StandardSQLTableManager(datasource); - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DatabaseService.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/DatabaseService.java deleted file mode 100644 index cae0c27cd..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/DatabaseService.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.exoplatform.services.transaction.TransactionService; - -import java.sql.Connection; - -/** - * Created by The eXo Platform SAS - * Author : Tuan Nguyen tuan08@users.sourceforge.net Apr 4, 2006 - * This service should provide a single - * interface to access the different datasource. - */ -public interface DatabaseService -{ - - /** - * This method should return the default datasource of the application - * - * @return - * @throws Exception - */ - public ExoDatasource getDatasource() throws Exception; - - /** - * This method should look up the datasouce by the datasource name and return. - * If the datasource is not found then the method should return null - * - * @param dsname - * @return - * @throws Exception - */ - public ExoDatasource getDatasource(String dsname) throws Exception; - - public Connection getConnection() throws Exception; - - public Connection getConnection(String dsName) throws Exception; - - public void closeConnection(Connection conn) throws Exception; - - /** - * This method should return the transaction service - * - * @return - * @throws Exception - */ - public TransactionService getTransactionService() throws Exception; - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/ExoDatasource.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/ExoDatasource.java deleted file mode 100644 index 36e60ed85..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/ExoDatasource.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.exoplatform.services.database.table.IDGenerator; -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; - -import java.sql.Connection; -import java.sql.DatabaseMetaData; - -import javax.sql.DataSource; - -/** - * Created by The eXo Platform SAS - * Author : Tuan Nguyen tuan08@users.sourceforge.net Apr 4, 2006 - * This class is a wrapper class for the java.sql.Datasource class. - * In additional to the java.sql.Datasourcemethod such getConnection(). - * The ExoDatasource provides 2 other methods: - * DBTableManager getDBTableManager and IDGenerator getIDGenerator() - */ -public class ExoDatasource -{ - - /** - * Logger. - */ - private static final Log LOG = ExoLogger.getLogger("exo.core.component.organization.database.ExoDatasource"); - - final public static int STANDARD_DB_TYPE = 0; - - final public static int HSQL_DB_TYPE = 1; - - final public static int MYSQL_DB_TYPE = 2; - - final public static int DB2_DB_TYPE = 3; - - final public static int DERBY_DB_TYPE = 4; - - final public static int ORACLE_DB_TYPE = 5; - - final public static int SQL_SERVER_TYPE = 6; - - static int totalGetConnect = 0; - - final public static int MSSQL_DB_TYPE = 6; - - final public static int SYSBASE_DB_TYPE = 7; - - final public static int POSTGRES_DB_TYPE = 8; - - private DataSource xaDatasource_; - - private DBTableManager tableManager_; - - private IDGenerator idGenerator_; - - private QueryBuilder queryManager_; - - private String databaseName_; - - private String databaseVersion_; - - private int dbType_ = STANDARD_DB_TYPE; - - Connection conn; - - /** - * The constructor should: - * 1. Keep track of the datasource object - * 2. Create the DBTableManager object base on the datasource information such database type, version - * 3. Create an IDGenerator for the datasource - * - * @param ds - * @throws Exception - */ - public ExoDatasource(final DataSource ds) throws Exception - { - xaDatasource_ = ds; - DatabaseMetaData metaData = ds.getConnection().getMetaData(); - - databaseName_ = metaData.getDatabaseProductName(); - databaseVersion_ = metaData.getDatabaseProductVersion(); - - String dbname = databaseName_.toLowerCase(); - LOG.debug("DB Name: " + dbname); - if (dbname.indexOf("oracle") >= 0) - { - dbType_ = ORACLE_DB_TYPE; - } - else if (dbname.indexOf("hsql") >= 0) - { - dbType_ = HSQL_DB_TYPE; - } - else if (dbname.indexOf("mysql") >= 0) - { - dbType_ = MYSQL_DB_TYPE; - } - else if (dbname.indexOf("derby") >= 0) - { - dbType_ = DERBY_DB_TYPE; - } - else if (dbname.indexOf("db2") >= 0) - { - dbType_ = DB2_DB_TYPE; - } - else if (dbname.indexOf("server") >= 0) - { - dbType_ = SQL_SERVER_TYPE; - } - else - { - dbType_ = STANDARD_DB_TYPE; - } - - tableManager_ = DBTableManager.createDBTableManager(this); - idGenerator_ = new IDGenerator(this); - queryManager_ = new QueryBuilder(dbType_); - } - - /** - * This method should return the real Datasource object - * - * @return - */ - public DataSource getDatasource() - { - return xaDatasource_; - } - - /** - * This method should call the datasource getConnection method and return the - * Connection object. The developer can add some debug code or broadcast an - * event here. - * - * @return - * @throws Exception - */ - public Connection getConnection() throws Exception - { - return xaDatasource_.getConnection(); - } - - /** - * This method should delegate to the method close of the Connection object. - * The developer can add debug or broadcast an event here. - * - * @param conn - * @throws Exception - */ - public void closeConnection(Connection conn) throws Exception - { - conn.close(); - } - - /** - * This method should delegate to the commit() method of the Connection - * object. The developer can add the debug code here - * - * @param conn - * @throws Exception - */ - public void commit(Connection conn) throws Exception - { - conn.setAutoCommit(false); - conn.commit(); - } - - /** - * This method should return the DBTableManager object. The DBTableManager - * object should be initialized in the constructor according to the database - * type and version - * - * @return - */ - public DBTableManager getDBTableManager() - { - return tableManager_; - } - - /** - * This method should return the IDGenerator object, the developer can use the - * id generator to generate an unique long id for an db object - * - * @return - */ - public IDGenerator getIDGenerator() - { - return idGenerator_; - } - - public int getDatabaseType() - { - return dbType_; - } - - public String getDatabaseName() - { - return databaseName_; - } - - public String getDatabaseVersion() - { - return databaseVersion_; - } - - public QueryBuilder getQueryBuilder() - { - return queryManager_; - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/HibernateService.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/HibernateService.java deleted file mode 100644 index bd188a59c..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/HibernateService.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; - -import java.io.Serializable; -import java.util.Collection; - -/** - * Created by The eXo Platform SAS - * Author : Tuan Nguyen tuan08@users.sourceforge.net - * Date: Jun 14, 2003 Time: 1:12:22 PM - */ -public interface HibernateService -{ - public Configuration getHibernateConfiguration(); - - public Session openSession(); - - public Session openNewSession(); - - public void closeSession(Session session); - - /** Close the session that assign to the current thread */ - public void closeSession(); - - SessionFactory getSessionFactory(); - - public Object findOne(Session session, String query, String id) throws Exception; - - public Collection findAll(Session session, String query) throws Exception; - - public Object findExactOne(Session session, String query, String id) throws Exception; - - public Object findOne(Class clazz, java.io.Serializable id) throws Exception; - - public Object findOne(ObjectQuery q) throws Exception; - - public Object create(Object obj) throws Exception; - - public Object update(Object obj) throws Exception; - - public Object save(Object obj) throws Exception; - - public Object remove(Object obj) throws Exception; - - public Object remove(Class clazz, Serializable id) throws Exception; - - public Object remove(Session session, Class clazz, Serializable id) throws Exception; -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/MSSQLServerTableManager.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/MSSQLServerTableManager.java deleted file mode 100644 index 9862b984a..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/MSSQLServerTableManager.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.exoplatform.services.database.annotation.TableField; - -/** - * Created by The eXo Platform SAS - * Author : Le Bien Thuy lebienthuy@exoplatform.com Apr 4, 2006 - */ -public class MSSQLServerTableManager extends StandardSQLTableManager -{ - - public MSSQLServerTableManager(ExoDatasource datasource) - { - super(datasource); - } - - protected void appendDateField(TableField field, StringBuilder builder) - { - builder.append(field.name()).append(" DATETIME"); - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/ObjectQuery.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/ObjectQuery.java deleted file mode 100644 index c2f6bbd4c..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/ObjectQuery.java +++ /dev/null @@ -1,429 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Tuan Nguyen (tuan08@users.sourceforge.net) - * @since Nov 25, 2004 - * @version $Id: ObjectQuery.java 6006 2006-06-06 10:01:27Z thangvn $ - */ -public class ObjectQuery -{ - - private Class type_; - - private String orderBy_; - - private String groupBy_; - - private List parameters_; - - private List selectParameter_; - - public ObjectQuery(Class type) - { - type_ = type; - parameters_ = new ArrayList(3); - selectParameter_ = new ArrayList(10); - } - - public ObjectQuery addEQ(String field, Object value) - { - if (value != null) - { - parameters_.add(new Parameter(" = ", field, value)); - } - return this; - } - - public ObjectQuery addGT(String field, Object value) - { - if (value != null) - { - parameters_.add(new Parameter(" > ", field, value)); - } - return this; - } - - public ObjectQuery addLT(String field, Object value) - { - if (value != null) - { - parameters_.add(new Parameter(" < ", field, value)); - } - return this; - } - - public ObjectQuery addLIKE(String field, String value) - { - if (value != null && value.length() > 0) - { - parameters_.add(new Parameter(" LIKE ", field, optimizeInputString(value))); - } - return this; - } - - public String optimizeInputString(String value) - { - value = value.replace('*', '%'); - return value; - } - - public ObjectQuery addSUM(String field) - { - selectParameter_.add(new Parameter("SUM", field)); - return this; - } - - public ObjectQuery addSelect(String field) - { - selectParameter_.add(new Parameter("FIELDSELECT", field)); - return this; - } - - public ObjectQuery addSelectCount(String type) - { - selectParameter_.add(new Parameter("COUNTSELECT", type)); - return this; - } - - public ObjectQuery addSelectMaxMin(String op, String field) - { - selectParameter_.add(new Parameter(op, field)); - return this; - } - - public ObjectQuery setGroupBy(String field) - { - groupBy_ = " GROUP BY o." + field; - return this; - } - - public ObjectQuery setAscOrderBy(String field) - { - orderBy_ = " ORDER BY o." + field + " asc"; - return this; - } - - public ObjectQuery setDescOrderBy(String field) - { - orderBy_ = " ORDER BY o." + field + " desc"; - return this; - } - - public String getHibernateQuery() - { - StringBuffer b = new StringBuffer(); - b.append("from o in class ").append(type_.getName()); - if (parameters_.size() > 0) - { - b.append(" WHERE "); - for (int i = 0; i < parameters_.size(); i++) - { - if (i > 0) - b.append(" AND "); - Parameter p = parameters_.get(i); - if (p.value_ instanceof String) - { - if (p.field_.startsWith("UPPER") || p.field_.startsWith("LOWER")) - { - b.append(p.field_).append(p.op_).append("'").append(p.value_).append("'"); - } - else - { - b.append(" o.").append(p.field_).append(p.op_).append("'").append(p.value_).append("'"); - } - } - else if (p.value_ instanceof Date) - { - SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - String value = ft.format((Date)p.value_); - b.append(" o.").append(p.field_).append(p.op_).append("'").append(value).append("'"); - } - else - { - b.append(" o.").append(p.field_).append(p.op_).append(p.value_); - } - } - } - if (orderBy_ != null) - b.append(orderBy_); - return b.toString(); - } - - /** - * - * @return - */ - public String getHibernateQueryWithBinding() - { - StringBuffer b = new StringBuffer(); - b.append("from o in class ").append(type_.getName()); - if (parameters_.size() > 0) - { - b.append(" WHERE "); - for (int i = 0; i < parameters_.size(); i++) - { - if (i > 0) - b.append(" AND "); - Parameter p = parameters_.get(i); - if (p.value_ instanceof String) - { - if (p.field_.startsWith("UPPER") || p.field_.startsWith("LOWER")) - { - b.append(p.field_).append(p.op_).append(":").append(p.field_.substring(6, p.field_.length() - 1)) - .append(i); - } - else - { - b.append(" o.").append(p.field_).append(p.op_).append(":").append(p.field_).append(i); - } - } - else if (p.value_ instanceof Date) - { - b.append(" o.").append(p.field_).append(p.op_).append(":").append(p.field_).append(i); - } - else - { - b.append(" o.").append(p.field_).append(p.op_).append(p.value_); - } - } - } - - if (orderBy_ != null) - { - b.append(orderBy_); - } - - return b.toString(); - } - - /** - * - * @return - */ - public Map getBindingFields() - { - Map binding = new HashMap(); - - if (parameters_.size() > 0) - { - for (int i = 0; i < parameters_.size(); i++) - { - Parameter p = parameters_.get(i); - if (p.value_ instanceof String) - { - if (p.field_.startsWith("UPPER") || p.field_.startsWith("LOWER")) - { - binding.put(p.field_.substring(6, p.field_.length() - 1) + i, p.value_); - } - else - { - binding.put(p.field_ + i, p.value_); - } - } - else if (p.value_ instanceof Date) - { - binding.put(p.field_ + i, p.value_); - } - } - } - - return binding; - } - - public String getHibernateGroupByQuery() - { - StringBuffer b = new StringBuffer(); - b.append("select "); - if (selectParameter_.size() > 0) - { - for (int i = 0; i < selectParameter_.size(); i++) - { - Parameter p = selectParameter_.get(i); - if (p.op_.equals("fieldselect")) - { - b.append("o.").append(p.field_); - } - else if (p.op_.equals("countselect")) - { - b.append("COUNT"); - if (!(p.field_.equals("")) || p.field_.length() > 0) - { - b.append("(").append(p.field_).append(" o)"); - } - else - { - b.append("(o)"); - } - } - else - { - b.append(p.op_).append("(").append("o.").append(p.field_).append(") "); - } - if (i < selectParameter_.size() - 1) - b.append(" , "); - } - } - b.append(" from o in class ").append(type_.getName()); - if (parameters_.size() > 0) - { - b.append(" where "); - for (int i = 0; i < parameters_.size(); i++) - { - if (i > 0) - b.append(" and "); - Parameter p = parameters_.get(i); - if (p.value_ instanceof String) - { - b.append(" o.").append(p.field_).append(p.op_).append("'").append(p.value_).append("'"); - } - else if (p.value_ instanceof Date) - { - SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - String value = ft.format((Date)p.value_); - b.append(" o.").append(p.field_).append(p.op_).append("'").append(value).append("'"); - } - else if (p.op_.equals("MAX") || p.op_.equals("MIN")) - { - b.append(p.op_).append("(").append("o.").append(p.field_).append(") "); - } - else - { - b.append(" o.").append(p.field_).append(p.op_).append(p.value_); - } - } - } - if (groupBy_ != null) - b.append(groupBy_); - if (orderBy_ != null) - b.append(orderBy_); - return b.toString(); - } - - public String getHibernateCountQuery() - { - StringBuffer b = new StringBuffer(); - b.append("SELECT COUNT(o) FROM o IN CLASS ").append(type_.getName()); - if (parameters_.size() > 0) - { - b.append(" WHERE "); - for (int i = 0; i < parameters_.size(); i++) - { - if (i > 0) - b.append(" AND "); - Parameter p = parameters_.get(i); - if (p.value_ instanceof String) - { - if (p.field_.startsWith("UPPER") || p.field_.startsWith("LOWER")) - { - b.append(p.field_).append(p.op_).append("'").append(p.value_).append("'"); - } - else - { - b.append(" o.").append(p.field_).append(p.op_).append("'").append(p.value_).append("'"); - } - } - else if (p.value_ instanceof Date) - { - SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - String value = ft.format((Date)p.value_); - b.append(" o.").append(p.field_).append(p.op_).append("'").append(value).append("'"); - } - else - { - b.append(" o.").append(p.field_).append(p.op_).append(p.value_); - } - } - } - return b.toString(); - } - - /** - * - * @return - */ - public String getHibernateCountQueryWithBinding() - { - StringBuffer b = new StringBuffer(); - b.append("SELECT COUNT(o) FROM o IN CLASS ").append(type_.getName()); - if (parameters_.size() > 0) - { - b.append(" WHERE "); - for (int i = 0; i < parameters_.size(); i++) - { - if (i > 0) - b.append(" AND "); - Parameter p = parameters_.get(i); - if (p.value_ instanceof String) - { - if (p.field_.startsWith("UPPER") || p.field_.startsWith("LOWER")) - { - b.append(p.field_).append(p.op_).append(":").append(p.field_.substring(6, p.field_.length() - 1)) - .append(i); - } - else - { - b.append(" o.").append(p.field_).append(p.op_).append(":").append(p.field_).append(i); - } - } - else if (p.value_ instanceof Date) - { - b.append(" o.").append(p.field_).append(p.op_).append(":").append(p.field_).append(i); - } - else - { - b.append(" o.").append(p.field_).append(p.op_).append(p.value_); - } - } - } - return b.toString(); - } - - static class Parameter - { - String op_; - - String field_; - - String label_; - - Object value_; - - Parameter(String op, String field, Object value) - { - op_ = op; - field_ = field; - value_ = value; - } - - Parameter(String op, String field) - { - op_ = op; - field_ = field; - } - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/OracleTableManager.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/OracleTableManager.java deleted file mode 100644 index 8c62a940e..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/OracleTableManager.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.exoplatform.services.database.annotation.TableField; - -/** - * Created by The eXo Platform SAS - * Author : Le Bien Thuy lebienthuy@exoplatform.com Apr 4, 2006 - */ -public class OracleTableManager extends StandardSQLTableManager -{ - - public OracleTableManager(ExoDatasource datasource) - { - super(datasource); - } - - @Override - protected void appendId(StringBuilder builder) - { - builder.append("ID INT NOT NULL PRIMARY KEY, "); - } - - @Override - protected void appendLongField(TableField field, StringBuilder builder) - { - builder.append(field.name()).append(" NUMBER"); - } - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/QueryBuilder.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/QueryBuilder.java deleted file mode 100644 index f527d1e13..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/QueryBuilder.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.exoplatform.services.database.annotation.Query; -import org.exoplatform.services.database.annotation.Table; -import org.exoplatform.services.database.annotation.TableField; - -import java.lang.reflect.Method; -import java.util.List; - -/** - * Created by The eXo Platform SAS - * Author : Nhu Dinh Thuan nhudinhthuan@exoplatform.com Mar 30, 2007 - */ -public class QueryBuilder -{ - - private int databaseType = ExoDatasource.STANDARD_DB_TYPE; - - public QueryBuilder() - { - } - - public QueryBuilder(int dbType) - { - databaseType = dbType; - } - - public String createSelectQuery(Class type, long id) throws Exception - { - Table table = type.getAnnotation(Table.class); - TableField[] fields = table.field(); - - StringBuilder query = new StringBuilder("SELECT "); - for (int i = 0; i < fields.length; i++) - { - TableField field = fields[i]; - query.append(field.name()); - if (i != fields.length - 1) - query.append(", "); - } - query.append(" FROM ").append(table.name()); - if (id > -1) - query.append(" WHERE ID = ").append(id); - return query.toString(); - } - - public String createUpdateQuery(Class type) throws Exception - { - Table table = type.getAnnotation(Table.class); - TableField[] fields = table.field(); - - StringBuilder query = new StringBuilder("UPDATE ").append(table.name()).append(" SET "); - for (int i = 0; i < fields.length; i++) - { - TableField field = fields[i]; - query.append(field.name()).append(" = '$").append(field.name()).append('\''); - if (i != fields.length - 1) - query.append(", "); - else - query.append(" WHERE ID = $id"); - } - return query.toString(); - } - - public String createInsertQuery(Class type) throws Exception - { - Table table = type.getAnnotation(Table.class); - TableField[] fields = table.field(); - - StringBuilder query = new StringBuilder("INSERT INTO ").append(table.name()).append("(ID, "); - for (int i = 0; i < fields.length; i++) - { - TableField field = fields[i]; - query.append(field.name()); - if (i != fields.length - 1) - query.append(", "); - else - query.append(") VALUES($id, "); - } - - for (int i = 0; i < fields.length; i++) - { - query.append("'$").append(fields[i].name()).append('\''); - if (i != fields.length - 1) - query.append(", "); - else - query.append(")"); - } - return query.toString(); - } - - public String createUpdateQuery(Class type, long id) throws Exception - { - Table table = type.getAnnotation(Table.class); - TableField[] fields = table.field(); - - StringBuilder query = new StringBuilder("UPDATE ").append(table.name()).append(" SET "); - for (int i = 0; i < fields.length; i++) - { - TableField field = fields[i]; - query.append(field.name()).append(" = ?"); - if (i != fields.length - 1) - query.append(", "); - else - query.append(" WHERE ID = ").append(id); - } - - return query.toString(); - } - - public String createInsertQuery(Class clazz, long id) throws Exception - { - Table table = clazz.getAnnotation(Table.class); - TableField[] fields = table.field(); - - StringBuilder query = new StringBuilder("INSERT INTO ").append(table.name()).append("(ID, "); - for (int i = 0; i < fields.length; i++) - { - TableField field = fields[i]; - query.append(field.name()); - if (i != fields.length - 1) - query.append(", "); - } - query.append(") VALUES(").append(id).append(", "); - - for (int i = 0; i < fields.length; i++) - { - query.append("?"); - if (i != fields.length - 1) - query.append(", "); - else - query.append(")"); - } - return query.toString(); - } - - public String createRemoveQuery(Class type, long id) throws Exception - { - Table table = type.getAnnotation(Table.class); - StringBuilder builder = new StringBuilder("DELETE FROM "); - builder.append(table.name()).append(" WHERE ID = ").append(id).toString(); - return builder.toString(); - } - - public > String getQuery(Class clazz, String name) throws Exception - { - Query query = clazz.getAnnotation(Query.class); - String value = null; - if (query != null && query.name().equals(name)) - value = getQuery(query); - if (value != null) - return value; - List list = ReflectionUtil.getMethod(clazz, name); - for (Method method : list) - { - query = method.getAnnotation(Query.class); - if (query != null && query.name().equals(name)) - value = getQuery(query); - if (value != null) - return value; - } - return null; - } - - private String getQuery(Query query) - { - switch (databaseType) - { - case ExoDatasource.STANDARD_DB_TYPE : - return query.standardSQL(); - case ExoDatasource.HSQL_DB_TYPE : - if (query.hsqlSQL().length() > 0) - return query.hsqlSQL(); - case ExoDatasource.MYSQL_DB_TYPE : - if (query.mysqlSQL().length() > 0) - return query.mysqlSQL(); - case ExoDatasource.MSSQL_DB_TYPE : - if (query.mssqlSQL().length() > 0) - return query.mssqlSQL(); - case ExoDatasource.ORACLE_DB_TYPE : - if (query.oracleSQL().length() > 0) - return query.oracleSQL(); - case ExoDatasource.DB2_DB_TYPE : - if (query.db2SQL().length() > 0) - return query.db2SQL(); - case ExoDatasource.DERBY_DB_TYPE : - if (query.derbySQL().length() > 0) - return query.derbySQL(); - case ExoDatasource.POSTGRES_DB_TYPE : - if (query.postgresSQL().length() > 0) - return query.postgresSQL(); - case ExoDatasource.SYSBASE_DB_TYPE : - if (query.sysbaseSQL().length() > 0) - return query.sysbaseSQL(); - default : - return query.standardSQL(); - } - } - - public String mapDataToSql(String template, String[][] parameters) throws Exception - { - StringBuilder builder = new StringBuilder(); - int i = 0; - int start = 0; - while (i < template.length()) - { - if (template.charAt(i) != '$') - { - i++; - continue; - } - - if (i > 0 && template.charAt(i - 1) == '\\') - { - builder.append(template.subSequence(start, i - 1)); - start = i; - i++; - continue; - } - - if (i == template.length() - 1) - break; - - int j = i + 1; - while (j < template.length()) - { - if (Character.isWhitespace(template.charAt(j))) - break; - if (template.charAt(j) == '\'' && template.charAt(j - 1) != '\\') - break; - if (template.charAt(j) == ',' && template.charAt(j - 1) != '\\') - break; - j++; - } - String name = template.substring(i + 1, j); - start = replace(template, builder, parameters, name, start, i); - i++; - } - if (start > 0 && start < template.length()) - { - builder.append(template.subSequence(start, template.length())); - } - if (builder.length() < 1) - return template.toString(); - return builder.toString(); - } - - private int replace(String template, StringBuilder builder, String[][] parameters, String name, int start, - int current) throws Exception - { - for (int k = 0; k < parameters.length; k++) - { - if (!parameters[k][0].equals(name)) - continue; - builder.append(template.subSequence(start, current)).append(parameters[k][1]); - return current + 1 + name.length(); - } - return start; - } - - public String encode(CharSequence seq) - { - if (seq.length() < 1) - return seq.toString(); - StringBuilder builder = new StringBuilder(); - int i = 0; - int start = 0; - while (i < seq.length()) - { - if (seq.charAt(i) == '\'') - { - builder.append(seq.subSequence(start, i)).append("''"); - start = i + 1; - } - i++; - } - if (start > 0 && start < seq.length()) - { - builder.append(seq.subSequence(start, seq.length())); - } - if (builder.length() < 1) - return seq.toString(); - return builder.toString(); - } - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/ReflectionMapper.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/ReflectionMapper.java deleted file mode 100644 index f78517efa..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/ReflectionMapper.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.exoplatform.services.database.annotation.Table; -import org.exoplatform.services.database.annotation.TableField; - -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.LineNumberReader; -import java.io.Reader; -import java.lang.reflect.Field; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.Types; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -/** - * Created by The eXo Platform SAS - * Author: Nhu Dinh Thuan nhudinhthuan@exoplatform.com Apr 2, 2007 - */ -public class ReflectionMapper implements DBObjectMapper -{ - - public String[][] toParameters(T bean) throws Exception - { - Map map = new HashMap(); - getParameters(bean, bean.getClass(), map); - - String[][] parameters = new String[map.size()][2]; - Iterator iter = map.keySet().iterator(); - int i = 0; - while (iter.hasNext()) - { - parameters[i][0] = iter.next(); - parameters[i][1] = map.get(parameters[i][0]); - i++; - } - return parameters; - } - - private void getParameters(Object bean, Class clazz, Map map) throws Exception - { - Field[] fields = clazz.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) - { - Object value = ReflectionUtil.getValue(bean, fields[i]); - if (value == null) - value = new String(); - if (value instanceof Calendar) - { - value = new java.sql.Date(((Calendar)value).getTimeInMillis()); - } - else if (value instanceof Date) - { - value = new java.sql.Date(((Date)value).getTime()); - } - map.put(fields[i].getName(), value.toString()); - } - if (clazz == DBObject.class) - return; - Class superClazz = clazz.getSuperclass(); - getParameters(superClazz.cast(bean), superClazz, map); - } - - public void mapResultSet(ResultSet resultSet, T bean) throws Exception - { - Class clazz = bean.getClass(); - Table table = clazz.getAnnotation(Table.class); - TableField[] tableFields = table.field(); - - ResultSetMetaData rsmd = resultSet.getMetaData(); - int numberOfColumns = rsmd.getColumnCount(); - for (int i = 1; i <= numberOfColumns; i++) - { - String name = rsmd.getColumnName(i); - TableField tableField = searchTableField(tableFields, name); - if (tableField == null) - continue; - String fieldName = tableField.field().length() == 0 ? tableField.name() : tableField.field(); - Field field = getField(clazz, fieldName); - if (field == null) - continue; - ReflectionUtil.setValue(bean, field, getValue(rsmd.getColumnType(i), resultSet, name)); - } - } - - public void mapUpdate(T bean, PreparedStatement statement) throws Exception - { - Class clazz = bean.getClass(); - Table table = clazz.getAnnotation(Table.class); - TableField[] tableFields = table.field(); - - int i = 1; - for (TableField tableField : tableFields) - { - String fieldName = tableField.field().length() == 0 ? tableField.name() : tableField.field(); - Field field = getField(clazz, fieldName); - if (field == null) - continue; - statement.setObject(i, ReflectionUtil.getValue(bean, field)); - i++; - } - } - - private Field getField(Class clazz, String name) throws Exception - { - Field field = clazz.getDeclaredField(name); - if (field != null) - return field; - if (clazz == DBObject.class) - return null; - return getField(clazz.getSuperclass(), name); - } - - private Object getValue(int type, ResultSet resultSet, String name) throws Exception - { - switch (type) - { - case Types.CLOB : - return loadClob(resultSet, name); - case Types.BLOB : - return loadBlob(resultSet, name); - case Types.BINARY : - return loadBinary(resultSet, name); - default : - return resultSet.getObject(name.toUpperCase()); - } - } - - private synchronized byte[] loadBinary(ResultSet resultSet, String name) throws Exception - { - InputStream input = resultSet.getBinaryStream(name); - if (input == null) - return null; - ByteArrayOutputStream output = loadInputStream(input); - return output.toByteArray(); - } - - private synchronized byte[] loadBlob(ResultSet resultSet, String name) throws Exception - { - Blob clob = resultSet.getBlob(name); - if (clob == null) - return null; - ByteArrayOutputStream output = loadInputStream(clob.getBinaryStream()); - return output.toByteArray(); - } - - private synchronized String loadClob(ResultSet resultSet, String name) throws Exception - { - Clob clob = resultSet.getClob(name); - if (clob == null) - return null; - Reader input = clob.getCharacterStream(); - if (input == null) - return null; - LineNumberReader lineReader = new LineNumberReader(input); - StringBuilder builder = new StringBuilder(); - String line; - while ((line = lineReader.readLine()) != null) - { - builder.append(line); - } - return builder.toString(); - } - - private ByteArrayOutputStream loadInputStream(InputStream input) throws Exception - { - ByteArrayOutputStream output = new ByteArrayOutputStream(); - byte[] data = new byte[1024]; - int available = -1; - while ((available = input.read(data)) > -1) - { - output.write(data, 0, available); - } - return output; - } - - private TableField searchTableField(TableField[] tableFields, String name) - { - for (TableField tableField : tableFields) - { - if (tableField.name().equals(name) && tableField.field().length() > 0) - return tableField; - } - for (TableField field : tableFields) - { - if (field.name().equals(name) && field.field().length() < 1) - return field; - } - return null; - } - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/ReflectionUtil.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/ReflectionUtil.java deleted file mode 100644 index 5b4c8a44c..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/ReflectionUtil.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by The eXo Platform SAS - * Author : Nhu Dinh Thuan nhudinhthuan@exoplatform.com Mar 29, 2007 - */ -public class ReflectionUtil -{ - - private static final Log LOG = ExoLogger.getLogger("exo.core.component.database.ReflectionUtil"); - - public final static void setValue(Object bean, Field field, Object value) throws Exception - { - Class clazz = bean.getClass(); - Method method = getMethod("set", field, clazz); - if (method != null) - method.invoke(bean, new Object[]{value}); - method = getMethod("put", field, clazz); - if (method != null) - method.invoke(bean, new Object[]{value}); - field.setAccessible(true); - field.set(bean, value); - } - - public final static Object getValue(Object bean, Field field) throws Exception - { - Class clazz = bean.getClass(); - Method method = getMethod("get", field, clazz); - if (method != null) - return method.invoke(bean, new Object[]{}); - method = getMethod("is", field, clazz); - if (method != null) - return method.invoke(bean, new Object[]{}); - field.setAccessible(true); - return field.get(bean); - } - - public final static Method getMethod(String prefix, Field field, Class clazz) throws Exception - { - StringBuilder name = new StringBuilder(field.getName()); - name.setCharAt(0, Character.toUpperCase(name.charAt(0))); - name.insert(0, prefix); - try - { - Method method = clazz.getDeclaredMethod(name.toString(), new Class[]{}); - return method; - } - catch (Exception e) - { - if (LOG.isTraceEnabled()) - { - LOG.trace("An exception occurred: " + e.getMessage()); - } - } - return null; - } - - public final static List getMethod(Class clazz, String name) throws Exception - { - Method[] methods = clazz.getDeclaredMethods(); - List list = new ArrayList(); - for (Method method : methods) - { - if (method.getName().equals(name)) - list.add(method); - } - return list; - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/StandardSQLTableManager.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/StandardSQLTableManager.java deleted file mode 100644 index 1f4360ce7..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/StandardSQLTableManager.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.exoplatform.services.database.annotation.Table; -import org.exoplatform.services.database.annotation.TableField; -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; - -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Statement; - -/** - * Created by The eXo Platform SAS - * Author : Tuan Nguyen tuan08@users.sourceforge.net Apr 4, 2006 - */ -public class StandardSQLTableManager extends DBTableManager -{ - - /** - * Logger. - */ - private static final Log LOG = ExoLogger - .getLogger("exo.core.component.organization.database.StandardSQLTableManager"); - - private ExoDatasource exoDatasource; - - public StandardSQLTableManager(ExoDatasource datasource) - { - exoDatasource = datasource; - } - - public void createTable(Class type, boolean dropIfExist) throws Exception - { - Table table = type.getAnnotation(Table.class); - if (table == null) - { - throw new Exception("Cannot find the annotation for class " + type.getClass().getName()); - } - StringBuilder builder = new StringBuilder(1000); - builder.append("CREATE TABLE ").append(table.name()).append(" ("); - appendId(builder); - TableField[] fields = table.field(); - for (int i = 0; i < fields.length; i++) - { - TableField field = fields[i]; - String fieldType = field.type(); - if ("string".equals(fieldType)) - { - appendStringField(field, builder); - } - else if ("int".equals(fieldType)) - { - appendIntegerField(field, builder); - } - else if ("long".equals(fieldType)) - { - appendLongField(field, builder); - } - else if ("float".equals(fieldType)) - { - appendFloatField(field, builder); - } - else if ("double".equals(fieldType)) - { - appendDoubleField(field, builder); - } - else if ("boolean".equals(fieldType)) - { - appendBooleanField(field, builder); - } - else if ("date".equals(fieldType)) - { - appendDateField(field, builder); - } - else if ("binary".equals(fieldType)) - { - appendBinaryField(field, builder); - } - if (i != fields.length - 1) - builder.append(", "); - } - builder.append(")"); - - // print out the sql string - Connection conn = exoDatasource.getConnection(); - conn.setAutoCommit(false); - Statement statement = conn.createStatement(); - LOG.debug("QUERY: \n " + builder + "\n"); - if (dropIfExist && hasTable(type)) - statement.execute("DROP TABLE IF EXISTS " + table.name()); - statement.execute(builder.toString()); - statement.close(); - conn.commit(); - exoDatasource.closeConnection(conn); - } - - public void dropTable(Class type) throws Exception - { - Table table = type.getAnnotation(Table.class); - if (table == null) - { - throw new Exception("Can not find the annotation for class " + type.getClass().getName()); - } - Connection conn = exoDatasource.getConnection(); - Statement s = conn.createStatement(); - s.execute("DROP TABLE " + table.name()); - s.close(); - conn.commit(); - exoDatasource.closeConnection(conn); - } - - public boolean hasTable(Class type) throws Exception - { - Table table = type.getAnnotation(Table.class); - if (table == null) - { - throw new Exception("Can not find the annotation for class " + type.getClass().getName()); - } - Connection connection = exoDatasource.getConnection(); - Statement statement = connection.createStatement(); - try - { - if (statement.execute("SELECT 1 FROM " + table.name()) == true) - return true; - } - catch (SQLException ex) - { - return false; - } - finally - { - statement.close(); - exoDatasource.closeConnection(connection); - } - return false; - } - - protected void appendId(StringBuilder builder) - { - builder.append("ID BIGINT NOT NULL PRIMARY KEY, "); - } - - protected void appendStringField(TableField field, StringBuilder builder) throws Exception - { - if (field.length() < 1) - { - throw new Exception("You forget to specify the length for field " + field.name() + " , type " + field.type()); - } - builder.append(field.name()).append(" ").append("VARCHAR(" + field.length() + ")"); - if (!field.nullable()) - builder.append(" NOT NULL "); - } - - protected void appendIntegerField(TableField field, StringBuilder builder) - { - builder.append(field.name()).append(" INTEGER"); - } - - protected void appendLongField(TableField field, StringBuilder builder) - { - builder.append(field.name()).append(" BIGINT"); - } - - protected void appendFloatField(TableField field, StringBuilder builder) - { - builder.append(field.name()).append(" REAL"); - } - - protected void appendDoubleField(TableField field, StringBuilder builder) - { - builder.append(field.name()).append(" DOUBLE"); - } - - protected void appendBooleanField(TableField field, StringBuilder builder) - { - builder.append(field.name()).append(" BIT"); - } - - protected void appendDateField(TableField field, StringBuilder builder) - { - builder.append(field.name()).append(" DATE"); - } - - protected void appendDateTimeField(TableField field, StringBuilder builder) - { - builder.append(field.name()).append(" DATETIME"); - } - - protected void appendBinaryField(TableField field, StringBuilder builder) - { - builder.append(field.name()).append(" VARBINARY"); - } - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/XResources.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/XResources.java deleted file mode 100644 index 5c5da9588..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/XResources.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import java.util.HashMap; - -/** - * @author Tuan Nguyen (tuan08@users.sourceforge.net) - * @since Oct 22, 2004 - * @version $Id: XResources.java 5332 2006-04-29 18:32:44Z geaz $ - */ -public class XResources extends HashMap -{ - - public Object getResource(Class cl) - { - return get(cl); - } - - public XResources addResource(Class cl, Object resource) - { - put(cl, resource); - return this; - } - - public Object removeResource(Class cl) - { - return remove(cl); - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/annotation/Query.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/annotation/Query.java deleted file mode 100644 index c5ff23c44..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/annotation/Query.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Created by The eXo Platform SAS Author : Nhu Dinh Thuan - * nhudinhthuan@exoplatform.com Mar 30, 2007 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.METHOD}) -public @interface Query { - String name(); - - String standardSQL(); - - String mysqlSQL() default ""; - - String mssqlSQL() default ""; - - String oracleSQL() default ""; - - String postgresSQL() default ""; - - String hsqlSQL() default ""; - - String derbySQL() default ""; - - String sysbaseSQL() default ""; - - String db2SQL() default ""; -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/annotation/Table.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/annotation/Table.java deleted file mode 100644 index 667164041..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/annotation/Table.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Author : Nhu Dinh Thuan nhudinhthuan@exoplatform.com Jul 5, 2006 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface Table { - String name(); - - TableField[] field(); -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/annotation/TableField.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/annotation/TableField.java deleted file mode 100644 index ab0ae931f..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/annotation/TableField.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Author : Nhu Dinh Thuan nhudinhthuan@exoplatform.com Jul 5, 2006 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface TableField { - String name(); - - String field() default ""; - - String type(); - - int length() default -1; - - boolean unique() default false; - - boolean nullable() default true; - - String defaultValue() default ""; -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java deleted file mode 100644 index b7fb814f0..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBConnectionInfo.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2010 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.creator; - -import java.util.Map; - -/** - * Class contains needed database connection information. - * - * @author Anatoliy Bazko - * @version $Id$ - */ -public class DBConnectionInfo -{ - private final Map connectionProperties; - - private final String dbName; - - /** - * DBConnectionInfo constructor. - * @param connectionProperties - * connection properties - */ - public DBConnectionInfo(String dbName, Map connectionProperties) - { - this.dbName = dbName; - this.connectionProperties = connectionProperties; - } - - public Map getProperties() - { - return connectionProperties; - } - - public String getDBName() - { - return dbName; - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java deleted file mode 100644 index d6c3aaf42..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreator.java +++ /dev/null @@ -1,461 +0,0 @@ -/* - * Copyright (C) 2010 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.creator; - -import org.exoplatform.commons.utils.ClassLoading; -import org.exoplatform.commons.utils.IOUtil; -import org.exoplatform.container.configuration.ConfigurationException; -import org.exoplatform.container.configuration.ConfigurationManager; -import org.exoplatform.container.xml.InitParams; -import org.exoplatform.container.xml.PropertiesParam; -import org.exoplatform.container.xml.Property; -import org.exoplatform.services.database.utils.DialectConstants; -import org.exoplatform.services.database.utils.DialectDetecter; -import org.exoplatform.services.database.utils.JDBCUtils; - -import java.io.IOException; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -/** - * @author Anatoliy Bazko - * @version $Id$ - */ -public class DBCreator -{ - - private final static String CONNECTION_PROPERTIES = "db-connection"; - - private final static String DRIVER_NAME = "driverClassName"; - - private final static String SERVER_URL = "url"; - - private final static String USERNAME = "username"; - - private final static String PASSWORD = "password"; - - private final static String DB_CREATION_PROPERTIES = "db-creation"; - - private final static String DB_SCRIPT_PATH = "scriptPath"; - - private final static String DB_USERNAME = "username"; - - private final static String DB_PASSWORD = "password"; - - /** - * Database template. - */ - public static final String DATABASE_TEMPLATE = "${database}"; - - /** - * User name template. - */ - public static final String USERNAME_TEMPLATE = "${username}"; - - /** - * Password template. - */ - public static final String PASSWORD_TEMPLATE = "${password}"; - - /** - * Server url. - */ - protected final String serverUrl; - - /** - * Connection properties. - */ - protected final Map connectionProperties; - - /** - * DDL script database creation. - */ - protected final String dbScript; - - /** - * User name for new database. - */ - protected final String dbUserName; - - /** - * User's password. - */ - protected final String dbPassword; - - /** - * DBCreator constructor. - * - * @param serverUrl Server URL - * @param connectionProperties Connection properties - * @param scriptPath Script path - * @param dbUserName DB username - * @param dbPassword DB password - * @param cm configuration manager instance - */ - public DBCreator(String serverUrl, Map connectionProperties, String scriptPath, String dbUserName, - String dbPassword, ConfigurationManager cm) throws ConfigurationException - { - this.serverUrl = serverUrl; - this.connectionProperties = connectionProperties; - this.dbUserName = dbUserName; - this.dbPassword = dbPassword; - this.dbScript = readScript(scriptPath, cm); - } - - /** - * DBCreator constructor. - * - * @param params - * Initializations parameters - * @param cm - * configuration manager instance - */ - public DBCreator(InitParams params, ConfigurationManager cm) throws ConfigurationException - { - if (params == null) - { - throw new ConfigurationException("Initializations parameters expected"); - } - - PropertiesParam prop = params.getPropertiesParam(CONNECTION_PROPERTIES); - - if (prop != null) - { - if (prop.getProperty(DRIVER_NAME) == null) - { - throw new ConfigurationException("driverClassName expected in db-connection properties section"); - } - - serverUrl = prop.getProperty(SERVER_URL); - if (serverUrl == null) - { - throw new ConfigurationException("url expected in db-connection properties section"); - } - - if (prop.getProperty(USERNAME) == null) - { - throw new ConfigurationException("username expected in db-connection properties section"); - } - - if (prop.getProperty(PASSWORD) == null) - { - throw new ConfigurationException("password expected in db-connection properties section"); - } - - // Store all connection properties into single map - Iterator pit = prop.getPropertyIterator(); - connectionProperties = new HashMap(); - while (pit.hasNext()) - { - Property p = pit.next(); - if (!p.getName().equalsIgnoreCase(SERVER_URL)) - { - connectionProperties.put(p.getName(), p.getValue()); - } - } - } - else - { - throw new ConfigurationException("db-connection properties expected in initializations parameters"); - } - - prop = params.getPropertiesParam(DB_CREATION_PROPERTIES); - if (prop != null) - { - String scriptPath = prop.getProperty(DB_SCRIPT_PATH); - if (scriptPath != null) - { - this.dbScript = readScript(scriptPath, cm); - } - else - { - throw new ConfigurationException("scriptPath expected in db-creation properties section"); - } - - this.dbUserName = prop.getProperty(DB_USERNAME); - if (dbUserName == null) - { - throw new ConfigurationException("username expected in db-creation properties section"); - } - - this.dbPassword = prop.getProperty(DB_PASSWORD); - if (dbPassword == null) - { - throw new ConfigurationException("password expected in db-creation properties section"); - } - } - else - { - throw new ConfigurationException("db-creation properties expected in initializations parameters"); - } - } - - /** - * Execute DDL script for new database creation. Database name are passed as parameter, - * user name and password are passed via configuration. In script database name, user name - * and password defined via templates as ${database}, ${username} and ${password} respectively. - * At execution time method replaces templates by real values. - * - * @param dbName - * new database name - * @throws DBCreatorException - * if any error occurs - */ - public DBConnectionInfo createDatabase(final String dbName) throws DBCreatorException - { - Connection conn = openConnection(); - try - { - String dialect = DialectDetecter.detect(conn.getMetaData()); - - if (dialect.equalsIgnoreCase(DialectConstants.DB_DIALECT_MSSQL) - || dialect.equalsIgnoreCase(DialectConstants.DB_DIALECT_SYBASE)) - { - executeInAutoCommitMode(conn, dbName); - } - else - { - executeInBatchMode(conn, dbName); - } - - return constructDBConnectionInfo(dbName, dialect); - } - catch (SQLException e) - { - throw new DBCreatorException("Can't execute SQL script : " + JDBCUtils.getFullMessage(e), e); - } - finally - { - try - { - conn.close(); - } - catch (SQLException e) - { - throw new DBCreatorException("Can't close connection", e); - } - } - } - - /** - * Get database connection info. - * - * @param dbName - * new database name - * @throws DBCreatorException - * if any error occurs or database is not available - */ - public DBConnectionInfo getDBConnectionInfo(String dbName) throws DBCreatorException - { - Connection conn = openConnection(); - try - { - return constructDBConnectionInfo(dbName, DialectDetecter.detect(conn.getMetaData())); - } - catch (SQLException e) - { - throw new DBCreatorException("Can not get database connection information", e); - } - finally - { - try - { - conn.close(); - } - catch (SQLException e) - { - throw new DBCreatorException("Can't close connection", e); - } - } - } - - /** - * Executes DDL script in generic batch mode. - * - * @param conn - * connection to server - * @param dbName - * database name - * @throws SQLException - * if any errors occurs - */ - private void executeInBatchMode(Connection conn, String dbName) throws SQLException - { - Statement statement = conn.createStatement(); - for (String scr : dbScript.split(";")) - { - scr = scr.replace(DATABASE_TEMPLATE, dbName); - scr = scr.replace(USERNAME_TEMPLATE, dbUserName); - scr = scr.replace(PASSWORD_TEMPLATE, dbPassword); - - String s = JDBCUtils.cleanWhitespaces(scr.trim()); - if (s.length() > 0) - { - statement.addBatch(s); - } - } - statement.executeBatch(); - } - - /** - * Construct database url connection depending on specific database. - * - * @param dbName - * database name - * @param dialect - * dialect - * @param serverUrl - * url to DB server - * @param connectionProperties - * connection properties - * @return DBConnectionInfo - */ - private DBConnectionInfo constructDBConnectionInfo(String dbName, String dialect) - { - StringBuilder dbUrl = new StringBuilder(serverUrl); - - if (dialect.equalsIgnoreCase(DialectConstants.DB_DIALECT_MSSQL)) - { - dbUrl.append(serverUrl.endsWith(";") ? "" : ";"); - dbUrl.append("databaseName="); - dbUrl.append(dbName); - dbUrl.append(";"); - } - else if (dialect.equalsIgnoreCase(DialectConstants.DB_DIALECT_ORACLE) - || dialect.equalsIgnoreCase(DialectConstants.DB_DIALECT_ORACLEOCI)) - { - // do nothing - } - else - { - dbUrl.append(serverUrl.endsWith("/") ? "" : "/"); - dbUrl.append(dbName); - } - - // clone connection properties - Map connProperties = new HashMap(); - - for (Entry entry : connectionProperties.entrySet()) - { - connProperties.put(entry.getKey(), entry.getValue()); - } - - // add url to database - connProperties.put(SERVER_URL, dbUrl.toString()); - - return new DBConnectionInfo(dbName, connProperties); - } - - /** - * Executes DDL script with autocommit mode set true. Actually need for MSSQL and Sybase database servers. - * After execution "create database" command newly created database not available for "use" command and - * therefore you can't create user inside. - * - * @param conn - * connection to server - * @param dbName - * database name - * @throws SQLException - * if any errors occurs - */ - private void executeInAutoCommitMode(Connection conn, String dbName) throws SQLException - { - conn.setAutoCommit(true); - for (String scr : dbScript.split(";")) - { - scr = scr.replace(DATABASE_TEMPLATE, dbName); - scr = scr.replace(USERNAME_TEMPLATE, dbUserName); - scr = scr.replace(PASSWORD_TEMPLATE, dbPassword); - - String s = JDBCUtils.cleanWhitespaces(scr.trim()); - if (s.length() > 0) - { - conn.createStatement().executeUpdate(s); - } - } - } - - /** - * Read script resource. - * - * @param scriptPath - * path to the script - * @param cm - * the configuration manager will help to find script in jars - * @return - * script content - * @throws ConfigurationException - * if script not found - */ - private String readScript(String scriptPath, ConfigurationManager cm) throws ConfigurationException - { - try - { - return IOUtil.getStreamContentAsString(cm.getInputStream(scriptPath)); - } - catch (Exception e) - { - try - { - return IOUtil.getFileContentAsString(scriptPath); - } - catch (IOException ioe) - { - throw new ConfigurationException("Can't read script at " + scriptPath, e); - } - } - } - - /** - * Open connection to the DB. - * - * @param connectionProperties - * connection properties - * @return connection - * @throws DBCreatorException - * if can't establish connection to DB - */ - private Connection openConnection() throws DBCreatorException - { - Connection conn = null; - try - { - ClassLoading.forName(connectionProperties.get(DRIVER_NAME), this); - - conn = DriverManager.getConnection(serverUrl, connectionProperties.get(USERNAME), - connectionProperties.get(PASSWORD)); - - return conn; - } - catch (SQLException e) - { - throw new DBCreatorException("Can't establish the JDBC connection to database " + serverUrl, e); - } - catch (ClassNotFoundException e) - { - throw new DBCreatorException("Can't load the JDBC driver " + connectionProperties.get(DRIVER_NAME), e); - } - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreatorException.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreatorException.java deleted file mode 100644 index ab4484ed3..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/creator/DBCreatorException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2010 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.creator; - -/** - * @author Anatoliy Bazko - * @version $Id$ - */ -public class DBCreatorException extends Exception -{ - - /** - * DBCreationException constructor. - */ - public DBCreatorException(Throwable e) - { - super(e); - } - - /** - * DBCreationException constructor. - */ - public DBCreatorException(String message, Throwable e) - { - super(message, e); - } - - /** - * DBCreationException constructor. - */ - public DBCreatorException(String message) - { - super(message); - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/HibernateConfigurationImpl.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/HibernateConfigurationImpl.java deleted file mode 100644 index c1a8284b3..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/HibernateConfigurationImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.impl; - -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; -import org.hibernate.service.ServiceRegistry; - -/** - * Created by The eXo Platform SAS . - * - * @author Gennady Azarenkov - * @version $Id: HibernateConfigurationImpl.java 5332 2006-04-29 18:32:44Z geaz - * $ Hibernate's Configuration. One per 'properties-param' entry in - * container configuration - */ -public class HibernateConfigurationImpl extends Configuration { - public SessionFactory buildSessionFactory() { - ServiceRegistry servReg = getStandardServiceRegistryBuilder().applySettings(getProperties()) - .build(); - return super.buildSessionFactory(servReg); - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/HibernateServiceImpl.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/HibernateServiceImpl.java deleted file mode 100644 index 073f7b8e9..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/HibernateServiceImpl.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.impl; - -import java.io.Serializable; -import java.security.PrivilegedAction; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.hibernate.HibernateException; -import org.hibernate.Session; -import org.hibernate.SessionFactory; -import org.hibernate.cfg.Configuration; - -import org.exoplatform.commons.exception.ObjectNotFoundException; -import org.exoplatform.container.ExoContainer; -import org.exoplatform.container.component.ComponentRequestLifecycle; -import org.exoplatform.container.xml.InitParams; -import org.exoplatform.container.xml.PropertiesParam; -import org.exoplatform.container.xml.Property; -import org.exoplatform.services.database.HibernateService; -import org.exoplatform.services.database.ObjectQuery; -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; - -/** - * Created by The eXo Platform SAS . - * - * @author Tuan Nguyen tuan08@users.sourceforge.net Date: Jun 14, 2003 - * @author dhodnett $Id: HibernateServiceImpl.java,v 1.3 2004/10/30 02:27:52 - * tuan08 Exp $ - */ -public class HibernateServiceImpl implements HibernateService, ComponentRequestLifecycle { - - public static final String AUTO_DIALECT = "AUTO"; - - private ThreadLocal threadLocal_; - - private static final Log LOG = ExoLogger.getLogger("exo.core.component.database.HibernateServiceImpl"); - - private HibernateConfigurationImpl conf_; - - private SessionFactory sessionFactory_; - - public HibernateServiceImpl(InitParams initParams) { - threadLocal_ = new ThreadLocal(); - PropertiesParam param = initParams.getPropertiesParam("hibernate.properties"); - conf_ = new HibernateConfigurationImpl(); - Iterator properties = param.getPropertyIterator(); - while (properties.hasNext()) { - Property p = (Property) properties.next(); - conf_.setProperty(p.getName(), p.getValue()); - } - - // Replace the potential "java.io.tmpdir" variable in the connection URL - String connectionURL = conf_.getProperty("hibernate.connection.url"); - if (connectionURL != null) { - connectionURL = - connectionURL.replace("${java.io.tmpdir}", System.getProperty("java.io.tmpdir")); - conf_.setProperty("hibernate.connection.url", connectionURL); - } - } - - public Configuration getHibernateConfiguration() { - return conf_; - } - - /** - * @return the SessionFactory - */ - public SessionFactory getSessionFactory() { - if (sessionFactory_ == null) { - sessionFactory_ = conf_.buildSessionFactory(); - } - - return sessionFactory_; - } - - public Session openSession() { - Session currentSession = threadLocal_.get(); - if (currentSession == null) { - if (LOG.isDebugEnabled()) { - LOG.debug("open new hibernate session in openSession()"); - } - currentSession = getSessionFactory().openSession(); - threadLocal_.set(currentSession); - } - return currentSession; - } - - public Session openNewSession() { - Session currentSession = threadLocal_.get(); - if (currentSession != null) { - closeSession(currentSession); - } - currentSession = getSessionFactory().openSession(); - threadLocal_.set(currentSession); - return currentSession; - } - - public void closeSession(Session session) { - if (session == null) { - return; - } - try { - session.close(); - if (LOG.isDebugEnabled()) { - LOG.debug("close hibernate session in openSession(Session session)"); - } - } catch (HibernateException t) { - LOG.error("Error closing hibernate session : " + t.getMessage(), t); - } - threadLocal_.set(null); - } - - final public void closeSession() { - Session s = threadLocal_.get(); - if (s != null) { - s.close(); - } - threadLocal_.set(null); - } - - public Object findExactOne(Session session, String query, String id) throws Exception { - Object res = session.createQuery(query).setParameter("id", id).uniqueResult(); - if (res == null) { - throw new ObjectNotFoundException("Cannot find the object with id: " + id); - } - return res; - } - - public Object findOne(Session session, String query, String id) throws Exception { - List l = session.createQuery(query).setParameter("id", id).list(); - if (l.size() == 0) { - return null; - } else if (l.size() > 1) { - throw new Exception("Expect only one object but found" + l.size()); - } else { - return l.get(0); - } - } - - public Collection findAll(Session session, String query) throws Exception { - List l = session.createQuery(query).list(); - if (l.size() == 0) { - return null; - } else { - return l; - } - } - - @SuppressWarnings("rawtypes") - public Object findOne(Class clazz, Serializable id) throws Exception { - Session session = openSession(); - Object obj = session.get(clazz, id); - return obj; - } - - public Object findOne(ObjectQuery q) throws Exception { - Session session = openSession(); - List l = session.createQuery(q.getHibernateQuery()).list(); - if (l.size() == 0) { - return null; - } else if (l.size() > 1) { - throw new Exception("Expect only one object but found" + l.size()); - } else { - return l.get(0); - } - } - - public Object create(Object obj) throws Exception { - Session session = openSession(); - session.save(obj); - session.flush(); - return obj; - } - - public Object update(Object obj) throws Exception { - Session session = openSession(); - session.update(obj); - session.flush(); - return obj; - } - - public Object save(Object obj) throws Exception { - Session session = openSession(); - session.merge(obj); - session.flush(); - return obj; - } - - public Object remove(Object obj) throws Exception { - Session session = openSession(); - session.delete(obj); - session.flush(); - return obj; - } - - @SuppressWarnings("rawtypes") - public Object remove(Class clazz, Serializable id) throws Exception { - Session session = openSession(); - Object obj = session.get(clazz, id); - session.delete(obj); - session.flush(); - return obj; - } - - @SuppressWarnings("rawtypes") - public Object remove(Session session, Class clazz, Serializable id) throws Exception { - Object obj = session.get(clazz, id); - session.delete(obj); - return obj; - } - - public void startRequest(ExoContainer container) { - - } - - public void endRequest(ExoContainer container) { - closeSession(); - } - - @Override - public boolean isStarted(ExoContainer container) { - Session s = threadLocal_.get(); - return s != null && s.isOpen(); - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/XAPoolTxSupportDatabaseService.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/XAPoolTxSupportDatabaseService.java deleted file mode 100644 index 9be06cf3e..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/impl/XAPoolTxSupportDatabaseService.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.impl; - -import org.enhydra.jdbc.pool.StandardXAPoolDataSource; -import org.enhydra.jdbc.standard.StandardXADataSource; -import org.exoplatform.container.xml.InitParams; -import org.exoplatform.container.xml.PropertiesParam; -import org.exoplatform.services.database.DatabaseService; -import org.exoplatform.services.database.ExoDatasource; -import org.exoplatform.services.transaction.TransactionService; - -import java.sql.Connection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import javax.sql.DataSource; - -/** - * Created by The eXo Platform SAS - * Author : Tuan Nguyen tuan08@users.sourceforge.net Apr 4, 2006 - */ -public class XAPoolTxSupportDatabaseService implements DatabaseService -{ - private HashMap datasources_; - - private ExoDatasource defaultDS_; - - private TransactionService txService_; - - public XAPoolTxSupportDatabaseService(InitParams params, TransactionService txService) throws Exception - { - datasources_ = new HashMap(5); - txService_ = txService; - Iterator i = params.getPropertiesParamIterator(); - while (i.hasNext()) - { - PropertiesParam param = (PropertiesParam)i.next(); - String name = param.getName(); - ExoDatasource ds = new ExoDatasource(createDatasource(param.getProperties())); - datasources_.put(name, ds); - if (defaultDS_ == null) - defaultDS_ = ds; - } - } - - public ExoDatasource getDatasource() throws Exception - { - return defaultDS_; - } - - public ExoDatasource getDatasource(String dsName) throws Exception - { - return datasources_.get(dsName); - } - - public Connection getConnection() throws Exception - { - return defaultDS_.getConnection(); - } - - public Connection getConnection(String dsName) throws Exception - { - ExoDatasource ds = datasources_.get(dsName); - return ds.getConnection(); - } - - public void closeConnection(Connection conn) throws Exception - { - defaultDS_.closeConnection(conn); - } - - public TransactionService getTransactionService() throws Exception - { - return txService_; - } - - private DataSource createDatasource(Map props) throws Exception - { - StandardXADataSource ds = new StandardXADataSource(); - - ds.setDriverName(props.get("connection.driver")); - ds.setUrl(props.get("connection.url")); - ds.setUser(props.get("connection.login")); - ds.setPassword(props.get("connection.password")); - ds.setTransactionManager(txService_.getTransactionManager()); - - StandardXAPoolDataSource pool = new StandardXAPoolDataSource(3); - pool.setMinSize(Integer.parseInt(props.get("connection.min-size"))); - pool.setMaxSize(Integer.parseInt(props.get("connection.max-size"))); - pool.setUser(props.get("connection.login")); - pool.setPassword(props.get("connection.password")); - pool.setDataSource(ds); - return pool; - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/jdbc/CreateDBSchemaPlugin.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/jdbc/CreateDBSchemaPlugin.java deleted file mode 100644 index 2e0de838c..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/jdbc/CreateDBSchemaPlugin.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.jdbc; - -import org.exoplatform.container.component.BaseComponentPlugin; -import org.exoplatform.container.configuration.ConfigurationException; -import org.exoplatform.container.xml.InitParams; -import org.exoplatform.container.xml.ValueParam; -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -/** - * Created by The eXo Platform SAS . - * - * @author Gennady - * Azarenkov - * @version $Id: CreateDBSchemaPlugin.java 8017 2006-08-16 15:12:00Z peterit $ - */ -public class CreateDBSchemaPlugin extends BaseComponentPlugin -{ - - protected static final Log LOG = ExoLogger.getLogger("exo.core.component.database.CreateDBSchemaPlugin"); - - private String dataSource; - - private String script; - - public CreateDBSchemaPlugin(InitParams params) throws ConfigurationException - { - ValueParam dsParam = params.getValueParam("data-source"); - ValueParam scriptFileParam = params.getValueParam("script-file"); - ValueParam scriptParam = params.getValueParam("script"); - - if (dsParam == null) - return; - dataSource = dsParam.getValue(); - if (scriptParam != null) - { - script = scriptParam.getValue(); - return; - } - // ClassLoader cl = this.getClass().getClassLoader(); - // //Thread.currentThread().getContextClassLoader(); - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - InputStream is = cl.getResourceAsStream(scriptFileParam.getValue()); - - if (is == null) - is = ClassLoader.getSystemResourceAsStream(scriptFileParam.getValue()); - - if (is == null) - { - try - { - LOG.warn("Db script not found as system resource... Trying to search as file by path: " - + scriptFileParam.getValue()); - is = new FileInputStream(scriptFileParam.getValue()); - LOG.info("Db script found as file by path: " + scriptFileParam.getValue()); - } - catch (IOException e) - { - LOG.warn("Db script not found as file by path: " + scriptFileParam.getValue() + ". " + e.getMessage()); - } - } - - if (is == null) - { - try - { - LOG.warn("Db script not found as system resource... Trying to search as file by url: " - + scriptFileParam.getValue()); - is = new URL(scriptFileParam.getValue()).openStream(); - LOG.info("Db script found as file by url: " + scriptFileParam.getValue()); - } - catch (IOException e) - { - LOG.warn("Db script not found as file by url: " + scriptFileParam.getValue() + ". " + e.getMessage()); - } - } - - if (is == null) - { - throw new ConfigurationException("Could not open input stream for db script " - + cl.getResource(scriptFileParam.getValue())); - } - - try - { - byte[] buf = new byte[is.available()]; - is.read(buf); - script = new String(buf); - } - catch (IOException e) - { - LOG.error(e.getLocalizedMessage(), e); - } - finally - { - try - { - is.close(); - } - catch (IOException e) - { - if (LOG.isTraceEnabled()) - { - LOG.trace("An exception occurred: " + e.getMessage()); - } - } - } - } - - public String getDataSource() - { - return dataSource; - } - - public String getScript() - { - return script; - } - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/jdbc/DBSchemaCreator.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/jdbc/DBSchemaCreator.java deleted file mode 100644 index 811106058..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/jdbc/DBSchemaCreator.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.jdbc; - -import org.exoplatform.container.component.ComponentPlugin; -import org.exoplatform.services.database.utils.JDBCUtils; -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; -import org.exoplatform.services.naming.InitialContextInitializer; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.naming.InitialContext; -import javax.naming.NamingException; -import javax.sql.DataSource; - -/** - * Created by The eXo Platform SAS . - * - * @author Gennady Azarenkov - * @version $Id: DBSchemaCreator.java 13053 2007-03-01 06:44:00Z tuan08 $ - */ - -public class DBSchemaCreator -{ - static private String SQL_ALREADYEXISTS = ".*((already exist)|(duplicate key)| (already used)|(ORA-00955))+.*"; - - private final Pattern pattern; - - private static final Log LOG = ExoLogger.getLogger("exo.core.component.database.DBSchemaCreator"); - - private List createDBSchemaPlugins = new ArrayList(); - - public DBSchemaCreator(InitialContextInitializer contextInit) - { - pattern = Pattern.compile(SQL_ALREADYEXISTS, Pattern.CASE_INSENSITIVE); - } - - // for testing only - private DBSchemaCreator(String dsName, String script) throws SQLException, NamingException - { - pattern = Pattern.compile(SQL_ALREADYEXISTS, Pattern.CASE_INSENSITIVE); - createTables(dsName, script); - } - - public void createTables(String dsName, String script) throws NamingException, SQLException - { - InitialContext context = new InitialContext(); - DataSource ds = (DataSource)context.lookup(dsName); - Connection conn = ds.getConnection(); - String sql = ""; - try - { - String[] scripts = JDBCUtils.splitWithSQLDelimiter(script); - - for (String scr : scripts) - { - String s = JDBCUtils.cleanWhitespaces(scr.trim()); - - if (s.length() < 1) - continue; - sql = s; - if (LOG.isDebugEnabled()) - LOG.debug("Execute script: \n[" + sql + "]"); - - try - { - conn.setAutoCommit(false); - conn.createStatement().executeUpdate(sql); - conn.commit(); - } - catch (SQLException e) - { - conn.rollback(); - // already exists check - Matcher aeMatcher = pattern.matcher(e.getMessage().trim()); - if (!aeMatcher.matches()) - throw e; - if (LOG.isDebugEnabled()) - LOG.debug(e.getMessage()); - } - - } - LOG.info("DB schema of DataSource: '" + dsName + "' created succesfully. context " + context); - } - catch (SQLException e) - { - LOG.error("Could not create db schema of DataSource: '" + dsName + "'. Reason: " + e.getMessage() + "; " - + JDBCUtils.getFullMessage(e) + ". Last command: " + sql, e); - } - finally - { - conn.close(); - } - - } - - public void addPlugin(ComponentPlugin plugin) - { - if (plugin instanceof CreateDBSchemaPlugin) - { - CreateDBSchemaPlugin csplugin = (CreateDBSchemaPlugin)plugin; - try - { - createTables(csplugin.getDataSource(), csplugin.getScript()); - createDBSchemaPlugins.add(csplugin); - } - catch (NamingException e) - { - LOG.error(e.getLocalizedMessage(), e); - } - catch (SQLException e) - { - LOG.error(e.getLocalizedMessage(), e); - } - } - } - - public ComponentPlugin removePlugin(String name) - { - return null; - } - - public Collection getPlugins() - { - return createDBSchemaPlugins; - } - - // for testing - public static DBSchemaCreator initialize(String dsName, String script) throws SQLException, NamingException - { - return new DBSchemaCreator(dsName, script); - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/table/ExoLongID.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/table/ExoLongID.java deleted file mode 100644 index ee6a8b1a6..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/table/ExoLongID.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.table; - -import org.exoplatform.services.database.DBObject; -import org.exoplatform.services.database.annotation.Table; -import org.exoplatform.services.database.annotation.TableField; - -/** - * Created by The eXo Platform SAS Mar 16, 2007 - */ -@Table(name = "EXO_LONG_ID", field = { - @TableField(name = "EXO_NAME", type = "string", length = 500, unique = true, nullable = false), - @TableField(name = "EXO_START", type = "long")}) -public class ExoLongID extends DBObject -{ - - final static public long BLOCK_SIZE = 3; - - private String name; - - private long currentBlockId; - - public ExoLongID() - { - } - - public ExoLongID(String name, long start) - { - this.name = name; - this.currentBlockId = start; - } - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - public long getCurrentBlockId() - { - return currentBlockId; - } - - public void setCurrentBlockId(long start) - { - this.currentBlockId = start; - } - - public void setNextBlock() - { - this.currentBlockId = this.currentBlockId + BLOCK_SIZE; - } - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/table/IDGenerator.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/table/IDGenerator.java deleted file mode 100644 index 9aabfcdce..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/table/IDGenerator.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.table; - -import org.exoplatform.commons.utils.PageList; -import org.exoplatform.services.database.DAO; -import org.exoplatform.services.database.DBObject; -import org.exoplatform.services.database.DBObjectMapper; -import org.exoplatform.services.database.DBTableManager; -import org.exoplatform.services.database.ExoDatasource; -import org.exoplatform.services.database.annotation.Table; - -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.HashMap; -import java.util.List; - -/** - * Created by The eXo Platform SAS - * Author : Tuan Nguyen tuan08@users.sourceforge.net Apr 4, 2006 - */ -public class IDGenerator extends DAO -{ - - private HashMap idTrackers_; - - public IDGenerator(ExoDatasource datasource) throws Exception - { - super(datasource, new ExoLongIDMapper()); - idTrackers_ = new HashMap(); - - DBTableManager tableManager = datasource.getDBTableManager(); - if (tableManager.hasTable(ExoLongID.class)) - return; - tableManager.createTable(ExoLongID.class, true); - } - - public ExoLongID loadObjectByName(String name) throws Exception - { - Table table = ExoLongID.class.getAnnotation(Table.class); - StringBuilder builder = new StringBuilder("SELECT EXO_NAME, EXO_START FROM "); - builder.append(table.name()).append(" WHERE EXO_NAME = '").append(name).append('\''); - return loadUnique(builder.toString()); - } - - public long generateLongId(T bean) throws Exception - { - return generateLongId(bean.getClass()); - } - - // Lazy loading - synchronized public long generateLongId(Class type) throws Exception - { - IDTracker idTracker = idTrackers_.get(type); - - if (idTracker == null) - { - ExoLongID instanceID = loadObjectByName(type.getName()); - long currentId = 0; - - if (instanceID == null) - { - instanceID = new ExoLongID(type.getName(), ExoLongID.BLOCK_SIZE); - save(instanceID); - } - else - { - currentId = instanceID.getCurrentBlockId(); - instanceID.setNextBlock(); - update(instanceID); - } - idTracker = new IDTracker(instanceID, currentId); - idTrackers_.put(type, idTracker); - } - - // System.out.println("+++>>" + load(1)) ; - - long generatedId = ++idTracker.currentId; - if (generatedId > idTracker.blockTracker.getCurrentBlockId() + ExoLongID.BLOCK_SIZE) - { - idTracker.blockTracker.setNextBlock(); - update(idTracker.blockTracker); - } - return generatedId; - } - - public void restartTracker() - { - idTrackers_.clear(); - } // for testing - - static private class IDTracker - { - - private ExoLongID blockTracker; - - private long currentId; - - private IDTracker(ExoLongID dbobject, long id) - { - blockTracker = dbobject; - currentId = id; - } - } - - static public class ExoLongIDMapper implements DBObjectMapper - { - - public String[][] toParameters(ExoLongID bean) throws Exception - { - return null; - } - - public void mapUpdate(ExoLongID bean, PreparedStatement pstm) throws Exception - { - pstm.setString(1, bean.getName()); - pstm.setLong(2, bean.getCurrentBlockId()); - } - - public void mapResultSet(ResultSet res, ExoLongID bean) throws Exception - { - bean.setName(res.getString(1)); - bean.setCurrentBlockId(res.getLong(2)); - } - } - - public ExoLongID createInstance() throws Exception - { - return new ExoLongID(); - } - - public ExoLongID load(long id) throws Exception - { - return null; - } - - public PageList loadAll() throws Exception - { - return null; - } - - public ExoLongID remove(long id) throws Exception - { - return null; - } - - public void remove(ExoLongID bean) throws Exception - { - } - - public void save(ExoLongID bean) throws Exception - { - } - - public void save(List beans) throws Exception - { - } - - public void update(ExoLongID bean) throws Exception - { - } - - public void update(List beans) throws Exception - { - } -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/utils/DialectConstants.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/utils/DialectConstants.java deleted file mode 100644 index 4340d9728..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/utils/DialectConstants.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2012 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.utils; - -/** - * @author Anatoliy Bazko - * @version $Id: DialectConstants.java 34360 2009-07-22 23:58:59Z tolusha $ - */ -public class DialectConstants -{ - /** - * DB_DIALECT_AUTO. - */ - public final static String DB_DIALECT_AUTO = "AUTO"; - - /** - * DB_DIALECT_GENERIC. - */ - public final static String DB_DIALECT_GENERIC = "GENERIC"; - - /** - * DB_DIALECT_ORACLE. - */ - public final static String DB_DIALECT_ORACLE = "ORACLE"; - - /** - * DB_DIALECT_ORACLEOCI. - */ - public final static String DB_DIALECT_ORACLEOCI = "ORACLE-OCI"; - - /** - * DB_DIALECT_PGSQL. - */ - public final static String DB_DIALECT_PGSQL = "PGSQL"; - - /** - * DB_DIALECT_PGSQL_SCS. - */ - public final static String DB_DIALECT_PGSQL_SCS = "PGSQL-SCS"; - - /** - * DB_DIALECT_MYSQL. - */ - public final static String DB_DIALECT_MYSQL = "MYSQL"; - - /** - * DB_DIALECT_MYSQL_UTF8. - */ - public final static String DB_DIALECT_MYSQL_UTF8 = "MYSQL-UTF8"; - - /** - * DB_DIALECT_MYSQL_NDB. - */ - public final static String DB_DIALECT_MYSQL_NDB = "MYSQL-NDB"; - - /** - * DB_DIALECT_MYSQL_NDB_UTF8. - */ - public final static String DB_DIALECT_MYSQL_NDB_UTF8 = "MYSQL-NDB-UTF8"; - - /** - * DB_DIALECT_MYSQL_MYISAM. - */ - public final static String DB_DIALECT_MYSQL_MYISAM = "MYSQL-MyISAM"; - - /** - * DB_DIALECT_MYSQL_MYISAM_UTF8. - */ - public final static String DB_DIALECT_MYSQL_MYISAM_UTF8 = "MYSQL-MyISAM-UTF8"; - - /** - * DB_DIALECT_HSQLDB. - */ - public final static String DB_DIALECT_HSQLDB = "HSQLDB"; - - /** - * DB_DIALECT_DB2. - */ - public final static String DB_DIALECT_DB2 = "DB2"; - - - /** - * DB_DIALECT_DB2V8. - */ - public final static String DB_DIALECT_DB2V8 = "DB2V8"; - - /** - * DB_DIALECT_MSSQL. - */ - public final static String DB_DIALECT_MSSQL = "MSSQL"; - - /** - * DB_DIALECT_SYBASE. - */ - public final static String DB_DIALECT_SYBASE = "SYBASE"; - - /** - * DB_DIALECT_DERBY. - */ - public final static String DB_DIALECT_DERBY = "DERBY"; - - /** - * DB_DIALECT_INGRES. - */ - public final static String DB_DIALECT_INGRES = "INGRES"; - - /** - * DB_DIALECT_H2. - */ - public final static String DB_DIALECT_H2 = "H2"; - - /** - * DB_DIALECTS. - */ - public final static String[] DB_DIALECTS = {DB_DIALECT_GENERIC, DB_DIALECT_ORACLE, DB_DIALECT_ORACLEOCI, - DB_DIALECT_PGSQL, DB_DIALECT_PGSQL_SCS, DB_DIALECT_MYSQL, DB_DIALECT_MYSQL_NDB, DB_DIALECT_MYSQL_NDB_UTF8, - DB_DIALECT_HSQLDB, DB_DIALECT_DB2, DB_DIALECT_DB2V8, DB_DIALECT_MSSQL, DB_DIALECT_SYBASE, - DB_DIALECT_DERBY, DB_DIALECT_MYSQL_UTF8, DB_DIALECT_INGRES, DB_DIALECT_H2, DB_DIALECT_MYSQL_MYISAM, - DB_DIALECT_MYSQL_MYISAM_UTF8}; - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/utils/DialectDetecter.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/utils/DialectDetecter.java deleted file mode 100644 index d005fc642..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/utils/DialectDetecter.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2010 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.utils; - -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; - -import java.sql.DatabaseMetaData; -import java.sql.SQLException; - -/** - * JDBC dialect detecter based on database metadata and vendor product name. - * - * @author Peter Nedonosko - * @version $Id:DialectDetecter.java 1111 2010-01-01 00:00:01Z pnedonosko $ - */ -public class DialectDetecter -{ - - /** - * Logger. - */ - private final static Log LOG = ExoLogger.getLogger("exo.core.component.database.DialectDetecter"); - - /** - * Detect databse dialect using JDBC metadata. Based on code of - * http://svn.jboss.org/repos/hibernate/core/trunk/core/src/main/java/org/hibernate/ - * dialect/resolver/StandardDialectResolver.java - * - * @param metaData {@link DatabaseMetaData} - * @return String - * @throws SQLException if error occurs - */ - public static String detect(final DatabaseMetaData metaData) throws SQLException - { - final String databaseName = metaData.getDatabaseProductName(); - - if ("HSQL Database Engine".equals(databaseName)) - { - return DialectConstants.DB_DIALECT_HSQLDB; - } - - if ("H2".equals(databaseName)) - { - return DialectConstants.DB_DIALECT_H2; - } - - if ("MySQL".equals(databaseName)) - { - return DialectConstants.DB_DIALECT_MYSQL; - } - - if ("PostgreSQL".equals(databaseName)) - { - int majorVersion = metaData.getDatabaseMajorVersion(); - int minorVersion = metaData.getDatabaseMinorVersion(); - - return (majorVersion > 9 || (majorVersion == 9 && minorVersion >= 1)) ? DialectConstants.DB_DIALECT_PGSQL_SCS - : DialectConstants.DB_DIALECT_PGSQL; - } - - if ("EnterpriseDB".equals(databaseName)) - { - return DialectConstants.DB_DIALECT_PGSQL_SCS; - } - - if ("Apache Derby".equals(databaseName)) - { - return DialectConstants.DB_DIALECT_DERBY; - } - - if ("ingres".equalsIgnoreCase(databaseName)) - { - return DialectConstants.DB_DIALECT_INGRES; - } - - if (databaseName.startsWith("Microsoft SQL Server")) - { - return DialectConstants.DB_DIALECT_MSSQL; - } - - if ("Sybase SQL Server".equals(databaseName) || "Adaptive Server Enterprise".equals(databaseName)) - { - return DialectConstants.DB_DIALECT_SYBASE; - } - - if (databaseName.startsWith("Adaptive Server Anywhere")) - { - return DialectConstants.DB_DIALECT_SYBASE; - } - - if (databaseName.startsWith("DB2/")) - { - return detectDB2Dialect(metaData); - } - - if ("Oracle".equals(databaseName)) - { - return DialectConstants.DB_DIALECT_ORACLE; - } - - return DialectConstants.DB_DIALECT_GENERIC; - } - - /** - * Detects DB2 dialect. - */ - private static String detectDB2Dialect(final DatabaseMetaData metaData) throws SQLException - { - if (LOG.isDebugEnabled()) - { - LOG.debug("DB Major version = " + metaData.getDatabaseMajorVersion() + ", DB Minor version = " - + metaData.getDatabaseMinorVersion() + ", DB Product version = " + metaData.getDatabaseProductVersion()); - } - - int majorVersion = metaData.getDatabaseMajorVersion(); - if (majorVersion < 9) - { - if (LOG.isDebugEnabled()) - { - LOG.debug("The dialect " + DialectConstants.DB_DIALECT_DB2V8 - + " will be used as the major version is lower than 9."); - } - - return DialectConstants.DB_DIALECT_DB2V8; - } - else - { - if (LOG.isDebugEnabled()) - { - LOG.debug("The dialect " + DialectConstants.DB_DIALECT_DB2 - + " will be used as the major version is greater or equal to 9"); - } - - return DialectConstants.DB_DIALECT_DB2; - } - } - -} diff --git a/exo.core.component.database/src/main/java/org/exoplatform/services/database/utils/JDBCUtils.java b/exo.core.component.database/src/main/java/org/exoplatform/services/database/utils/JDBCUtils.java deleted file mode 100644 index acc54b134..000000000 --- a/exo.core.component.database/src/main/java/org/exoplatform/services/database/utils/JDBCUtils.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright (C) 2011 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database.utils; - -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -import javax.sql.DataSource; - -/** - * This class provides JDBC tools - * - * @author Nicolas Filotto - * @version $Id$ - */ -/** - * @author Anatoliy Bazko - * @version $Id: JDBCUtils.java 34360 2009-07-22 23:58:59Z tolusha $ - * - */ -public class JDBCUtils -{ - private static final Log LOG = ExoLogger.getLogger("exo.core.component.database.JDBCUtils"); - - /** - * Default SQL delimiter. - */ - public static final String SQL_DELIMITER = ";"; - - /** - * SQL delimiter comment prefix. - */ - public static final String SQL_DELIMITER_COMMENT_PREFIX = "/*$DELIMITER:"; - - public static final String SQL_DELIMITER_COMMENT_SUFFIX = "*/"; - - private JDBCUtils() - { - } - - /** - * Indicates whether or not a given table exists - * - * @param tableName - * the name of the table to check - * @param con - * the connection to use - * @return true if it exists, false otherwise - */ - public static boolean tableExists(String tableName, Connection con) - { - Statement stmt = null; - ResultSet trs = null; - try - { - String dialect = DialectDetecter.detect(con.getMetaData()); - String query; - if (dialect.startsWith(DialectConstants.DB_DIALECT_MYSQL) || dialect.startsWith(DialectConstants.DB_DIALECT_PGSQL)) - { - query = "SELECT count(*) from (SELECT 1 FROM " + tableName + " LIMIT 1) T"; - } - else if (dialect.startsWith(DialectConstants.DB_DIALECT_ORACLE)) - { - query = "SELECT count(*) from (SELECT 1 FROM " + tableName + " WHERE ROWNUM = 1) T"; - } - else if (dialect.startsWith(DialectConstants.DB_DIALECT_DB2) || dialect.startsWith(DialectConstants.DB_DIALECT_DERBY) - || dialect.startsWith(DialectConstants.DB_DIALECT_INGRES)) - { - query = "SELECT count(*) from (SELECT 1 FROM " + tableName + " FETCH FIRST 1 ROWS ONLY) T"; - } - else if (dialect.startsWith(DialectConstants.DB_DIALECT_MSSQL)) - { - query = "SELECT count(*) from (SELECT TOP (1) 1 as C FROM " + tableName + ") T"; - } - else if (dialect.startsWith(DialectConstants.DB_DIALECT_SYBASE)) - { - query = "SELECT count(*) from (SELECT TOP 1 1 FROM " + tableName + ") T"; - } - else - { - query = "SELECT count(*) FROM " + tableName; - } - stmt = con.createStatement(); - trs = stmt.executeQuery(query); - return trs.next(); - } - catch (SQLException e) - { - if (LOG.isDebugEnabled()) - { - LOG.debug("SQLException occurs while checking the table " + tableName, e); - } - return false; - } - finally - { - freeResources(trs, stmt, null); - } - } - - /** - * Retrieves the full message from SQLException. - * - * @param exception - * SQLException which will be parsed - */ - public static String getFullMessage(SQLException exception) - { - StringBuilder errorTrace = new StringBuilder(exception.getMessage()); - - SQLException next = exception; - while (next != null) - { - errorTrace.append("; "); - errorTrace.append(next.getMessage()); - - next = next.getNextException(); - } - - Throwable cause = exception.getCause(); - - return errorTrace + (cause != null ? " (Cause: " + cause.getMessage() + ")" : ""); - } - - /** - * Replace whitespace characters with space character. - */ - public static String cleanWhitespaces(String string) - { - if (string != null) - { - char[] cc = string.toCharArray(); - for (int ci = cc.length - 1; ci > 0; ci--) - { - if (Character.isWhitespace(cc[ci])) - { - cc[ci] = ' '; - } - } - return new String(cc); - } - return string; - } - - /** - * Split string resource with SQL Delimiter. Delimiter can be taken from resource - * at the begining of the first line. It surrounded with {@link #SQL_DELIMITER_COMMENT_PREFIX} - * and {@link #SQL_DELIMITER_COMMENT_SUFFIX}. Otherwise the default delimiter will - * be used {@link #SQL_DELIMITER}. - */ - public static String[] splitWithSQLDelimiter(String resource) - { - if (resource.startsWith(SQL_DELIMITER_COMMENT_PREFIX)) - { - try - { - String scripts = resource.substring(SQL_DELIMITER_COMMENT_PREFIX.length()); - - int endOfDelimIndex = scripts.indexOf(SQL_DELIMITER_COMMENT_SUFFIX); - String delim = scripts.substring(0, endOfDelimIndex).trim(); - - scripts = scripts.substring(endOfDelimIndex + 2).trim(); - return scripts.split(delim); - } - catch (IndexOutOfBoundsException e) - { - LOG.warn("Error of parse SQL-script file. Invalid DELIMITER configuration. Valid format is '" - + SQL_DELIMITER_COMMENT_PREFIX + "XXX*/' at begin of the SQL-script file, where XXX - DELIMITER string." - + " Spaces will be trimed. ", e); - LOG.info("Using DELIMITER:[" + SQL_DELIMITER + "]"); - - return resource.split(SQL_DELIMITER); - } - } - else - { - return resource.split(SQL_DELIMITER); - } - } - - /** - * Returns appropriate blob type field for specific database. - */ - public static String getAppropriateBlobType(DataSource dataSource) throws SQLException - { - String dialect = resolveDialect(dataSource); - - if (dialect.startsWith(DialectConstants.DB_DIALECT_HSQLDB)) - { - return "VARBINARY(65535)"; - } - else if (dialect.startsWith(DialectConstants.DB_DIALECT_MYSQL)) - { - return "LONGBLOB"; - } - else if (dialect.startsWith(DialectConstants.DB_DIALECT_PGSQL)) - { - return "bytea"; - } - else if (dialect.startsWith(DialectConstants.DB_DIALECT_MSSQL)) - { - return "VARBINARY(MAX)"; - } - else if (dialect.startsWith(DialectConstants.DB_DIALECT_SYBASE)) - { - return "IMAGE"; - } - else if (dialect.startsWith(DialectConstants.DB_DIALECT_INGRES)) - { - return "long byte"; - } - - return "BLOB"; - } - - /** - * Returns appropriate timestamp type field for specific database. - */ - public static String getAppropriateTimestamp(DataSource dataSource) throws SQLException - { - String dialect = resolveDialect(dataSource); - - if (dialect.startsWith(DialectConstants.DB_DIALECT_ORACLE)) - { - return "NUMBER(19, 0)"; - } - - return "BIGINT"; - } - - /** - * Returns appropriate char type field for specific database. - */ - public static String getAppropriateCharType(DataSource dataSource) throws SQLException - { - String dialect = resolveDialect(dataSource); - - if (dialect.startsWith(DialectConstants.DB_DIALECT_ORACLE)) - { - // Oracle suggests the use VARCHAR2 instead of VARCHAR while declaring data type. - return "VARCHAR2(512)"; - } - - return "VARCHAR(512)"; - } - - /** - * Returns dialect one of dialect {@link DialectConstants} based on {@link DataSource} name. - */ - public static String resolveDialect(final DataSource dataSource) throws SQLException - { - Connection jdbcConn = dataSource.getConnection(); - - try - { - return DialectDetecter.detect(jdbcConn.getMetaData()); - } - finally - { - freeResources(null, null, jdbcConn); - } - } - - /** - * Closes database related resources. - */ - public static void freeResources(ResultSet resultSet, Statement statement, Connection conn) - { - if (resultSet != null) - { - try - { - resultSet.close(); - } - catch (SQLException e) - { - LOG.error(e.getMessage(), e); - } - } - - if (statement != null) - { - try - { - statement.close(); - } - catch (SQLException e) - { - LOG.error(e.getMessage(), e); - } - } - - if (conn != null) - { - try - { - conn.close(); - } - catch (SQLException e) - { - LOG.error(e.getMessage(), e); - } - } - } - -} diff --git a/exo.core.component.database/src/main/resources/conf/portal/jdbcexo-configuration.db.xml b/exo.core.component.database/src/main/resources/conf/portal/jdbcexo-configuration.db.xml deleted file mode 100644 index b578c0ea1..000000000 --- a/exo.core.component.database/src/main/resources/conf/portal/jdbcexo-configuration.db.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - org.exoplatform.services.naming.InitialContextInitializer - - bind.datasource - addPlugin - org.exoplatform.services.naming.BindReferencePlugin - - - bind-name - jdbcexo - - - class-name - javax.sql.DataSource - - - factory - org.apache.commons.dbcp.BasicDataSourceFactory - - - ref-addresses - ref-addresses - - - - - - - - - - diff --git a/exo.core.component.database/src/main/resources/conf/portal/jdbcexo-configuration.hsql.xml b/exo.core.component.database/src/main/resources/conf/portal/jdbcexo-configuration.hsql.xml deleted file mode 100644 index 95e989a44..000000000 --- a/exo.core.component.database/src/main/resources/conf/portal/jdbcexo-configuration.hsql.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - org.exoplatform.services.naming.InitialContextInitializer - - bind.datasource - addPlugin - org.exoplatform.services.naming.BindReferencePlugin - - - bind-name - jdbexo - - - class-name - javax.sql.DataSource - - - factory - org.apache.commons.dbcp.BasicDataSourceFactory - - - ref-addresses - ref-addresses - - - - - - - - - - diff --git a/exo.core.component.database/src/main/sql/create.sql b/exo.core.component.database/src/main/sql/create.sql deleted file mode 100644 index 03335a6fb..000000000 --- a/exo.core.component.database/src/main/sql/create.sql +++ /dev/null @@ -1,16 +0,0 @@ ---table name for mysql on linux is case sensitive -create table hibernate_unique_key ( - next_hi BIGINT - ); -INSERT INTO hibernate_unique_key(next_hi) VALUES ( 100 ); -/* -create table RESOURCE_BUNDLE_DATA ( - id VARCHAR(128) NOT NULL, - name VARCHAR(128) NOT NULL, - language VARCHAR(25), - country VARCHAR(25), - variant VARCHAR(25), - resourceType VARCHAR(128) NOT NULL, - data TEXT NOT NULL, - PRIMARY KEY (id)); -*/ diff --git a/exo.core.component.database/src/test/java/org/exoplatform/services/database/DBCreatorTest.java b/exo.core.component.database/src/test/java/org/exoplatform/services/database/DBCreatorTest.java deleted file mode 100644 index 98a8af237..000000000 --- a/exo.core.component.database/src/test/java/org/exoplatform/services/database/DBCreatorTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import junit.framework.TestCase; - -import org.exoplatform.container.PortalContainer; -import org.exoplatform.services.database.jdbc.CreateDBSchemaPlugin; -import org.exoplatform.services.database.jdbc.DBSchemaCreator; - -import java.util.List; - -/** - * Created by The eXo Platform SAS . - * - * @author Gennady Azarenkov - * @version $Id: DBCreatorTest.java 5569 2006-05-17 12:48:47Z lautarul $ - */ -public class DBCreatorTest extends TestCase -{ - - // private StandaloneContainer container; - private DBSchemaCreator dbcreator; - - public void setUp() throws Exception - { - // >>>>> to avoid two top-level container exception - // StandaloneContainer.setConfigurationPath("src/main/java/conf/standalone/test-configuration.xml"); - // container = StandaloneContainer.getInstance(); - PortalContainer container = PortalContainer.getInstance(); - dbcreator = (DBSchemaCreator)container.getComponentInstanceOfType(DBSchemaCreator.class); - } - - public void testConf() throws Exception - { - // DBSchemaCreator dbcreator = (DBSchemaCreator) container.getComponentInstanceOfType(DBSchemaCreator.class); - List plugins = (List)dbcreator.getPlugins(); - assertFalse(plugins.isEmpty()); - - assertTrue(plugins.get(0) instanceof CreateDBSchemaPlugin); - CreateDBSchemaPlugin plugin = (CreateDBSchemaPlugin)plugins.get(0); - - assertNotNull(plugin.getDataSource()); - assertNotNull(plugin.getScript()); - } - - public void tearDown() throws Exception - { - // container.stop(); - } -} diff --git a/exo.core.component.database/src/test/java/org/exoplatform/services/database/Mock.java b/exo.core.component.database/src/test/java/org/exoplatform/services/database/Mock.java deleted file mode 100644 index 73694d8c6..000000000 --- a/exo.core.component.database/src/test/java/org/exoplatform/services/database/Mock.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import org.exoplatform.services.database.annotation.Table; -import org.exoplatform.services.database.annotation.TableField; - -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.Calendar; -import java.util.HashMap; - -/** - * Created by The eXo Platform SAS Author : Tuan Nguyen - * tuan.nguyen@exoplatform.com Mar 16, 2007 - */ -@Table(name = "MockTable", field = { - @TableField(name = "name", type = "string", length = 500, unique = true, nullable = false), - @TableField(name = "status", type = "int", defaultValue = "0"), @TableField(name = "start", type = "date"), - @TableField(name = "pass", type = "boolean", defaultValue = "false")}) -public class Mock extends DBObject -{ - - private String name; - - private int status; - - private Calendar start = Calendar.getInstance(); - - private boolean pass = false; - - public Mock() - { - } - - public Mock(String name, int status) - { - this.name = name; - this.status = status; - } - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - public boolean isPass() - { - return pass; - } - - public void setPass(boolean pass) - { - this.pass = pass; - } - - public Calendar getStart() - { - return start; - } - - public void setStart(Calendar start) - { - this.start = start; - } - - public int getStatus() - { - return status; - } - - public void setStatus(int status) - { - this.status = status; - } - - static public class MockMapper implements DBObjectMapper - { - - public String[][] toParameters(Mock bean) throws Exception - { - java.sql.Date date = new java.sql.Date(bean.getStart().getTimeInMillis()); - return new String[][]{{"id", String.valueOf(bean.getDBObjectId())}, {"name", bean.getName()}, - {"status", String.valueOf(bean.getStatus())}, {"start", date.toString()}, - {"pass", String.valueOf(bean.isPass())}}; - } - - public void mapResultSet(ResultSet res, Mock bean) throws Exception - { - bean.setName(res.getString("name")); - bean.setPass(res.getBoolean("pass")); - Calendar calendar = Calendar.getInstance(); - res.getDate("start", calendar); - bean.setStart(calendar); - bean.setStatus(res.getInt("status")); - } - - public void mapUpdate(Mock bean, PreparedStatement statement) throws Exception - { - statement.setString(1, bean.getName()); - statement.setInt(2, bean.getStatus()); - statement.setDate(3, new java.sql.Date(bean.getStart().getTimeInMillis())); - statement.setBoolean(4, bean.isPass()); - } - } - - /** - * Query( name = "GetUserByUserName" oracle = - * "select * from user where username= N'?' and fname = $fname" + - * ".............................................................." + - * ".............................................................." , - * standard="......................................................." , ) - */ - public void getUserByName(String s) - { - HashMap values = new HashMap(); - values.put("username", s); - values.put("fname", s); - // Object[] params = { - // {"username", "value"}, - // {"username", "value"}, - // {"username", "value"} - // } - // String query = createQuery("GetUserByUserName", params) ; - } - -} diff --git a/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDAO.java b/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDAO.java deleted file mode 100644 index cc8a8dc85..000000000 --- a/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDAO.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import junit.framework.TestCase; - -import org.exoplatform.services.listener.ListenerService; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; - -/** - * Created by The eXo Platform SAS Author : Tuan Nguyen - * tuan.nguyen@exoplatform.com Mar 27, 2007 - */ -public class TestDAO extends TestCase -{ - - public void testDummy() - { - // empty, to doesn't fail during the tests - } - - private String printQueryResult(DatabaseService service) throws Exception - { - Connection conn = service.getConnection(); - Statement statement = conn.createStatement(); - String output = "\nQuery result: \n"; - ResultSet rs = statement.executeQuery("SELECT * FROM ExoLongId"); - while (rs.next()) - { - output += rs.getString(1) + "\n" + rs.getString(2) + "\n" + rs.getString(3) + "====\n"; - } - - return output; - } - - private void queries(DatabaseService service) throws Exception - { - } -} diff --git a/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java b/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java deleted file mode 100644 index 6da600463..000000000 --- a/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDBCreator.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (C) 2010 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import junit.framework.TestCase; - -import org.exoplatform.container.PortalContainer; -import org.exoplatform.container.configuration.ConfigurationManager; -import org.exoplatform.services.database.creator.DBConnectionInfo; -import org.exoplatform.services.database.creator.DBCreator; -import org.exoplatform.services.naming.InitialContextInitializer; - -import java.sql.Connection; -import java.util.HashMap; -import java.util.Map; - -import javax.sql.DataSource; - -/** - * @author Anatoliy Bazko - * @version $Id$ - */ -public class TestDBCreator extends TestCase -{ - - protected DBCreator dbCreator; - - private InitialContextInitializer initContext; - - private PortalContainer container; - - @Override - public void setUp() throws Exception - { - container = PortalContainer.getInstance(); - dbCreator = (DBCreator)container.getComponentInstanceOfType(DBCreator.class); - initContext = (InitialContextInitializer)container.getComponentInstanceOfType(InitialContextInitializer.class); - } - - public void testDBCreate() throws Exception - { - assertNotNull(dbCreator); - - DBConnectionInfo dbInfo = dbCreator.createDatabase("testdb"); - DBConnectionInfo dbInfo1 = dbCreator.getDBConnectionInfo("testdb"); - - Map connProps = dbInfo.getProperties(); - Map connProps1 = dbInfo1.getProperties(); - - assertEquals(connProps.get("driverClassName"), connProps1.get("driverClassName")); - assertEquals(connProps.get("username"), connProps1.get("username")); - assertEquals(connProps.get("url"), connProps1.get("url")); - assertEquals(connProps.get("password"), connProps1.get("password")); - - Map refAddr = dbInfo.getProperties(); - - initContext.getInitialContextBinder().bind("testjdbcjcr", "javax.sql.DataSource", - "org.apache.commons.dbcp.BasicDataSourceFactory", null, - refAddr); - - DataSource ds = (DataSource)initContext.getInitialContext().lookup("testjdbcjcr"); - assertNotNull(ds); - - Connection conn = ds.getConnection(); - assertNotNull(conn); - } - - public void testDBCreateWithSpecificProperties() throws Exception - { - assertNotNull(dbCreator); - - String serverUrl = "jdbc:hsqldb:file:target/temp/data/dbcreator_test"; - Map connectionProperties = new HashMap(); - connectionProperties.put("driverClassName", "org.hsqldb.jdbcDriver"); - connectionProperties.put("username", "sa"); - connectionProperties.put("password", ""); - - ConfigurationManager cm = (ConfigurationManager)container.getComponentInstanceOfType(ConfigurationManager.class); - DBCreator dbCreator = - new DBCreator(serverUrl, connectionProperties, "classpath:/dbcreator/test.sql", "sa", "", cm); - - DBConnectionInfo dbInfo = dbCreator.createDatabase("testdb"); - DBConnectionInfo dbInfo1 = dbCreator.getDBConnectionInfo("testdb"); - - Map connProps = dbInfo.getProperties(); - Map connProps1 = dbInfo1.getProperties(); - - assertEquals(connProps.get("driverClassName"), connProps1.get("driverClassName")); - assertEquals(connProps.get("username"), connProps1.get("username")); - assertEquals(connProps.get("url"), connProps1.get("url")); - assertEquals(connProps.get("password"), connProps1.get("password")); - - Map refAddr = dbInfo.getProperties(); - - initContext.getInitialContextBinder().bind("testjdbcjcr2", "javax.sql.DataSource", - "org.apache.commons.dbcp.BasicDataSourceFactory", null, - refAddr); - - DataSource ds = (DataSource)initContext.getInitialContext().lookup("testjdbcjcr2"); - assertNotNull(ds); - - Connection conn = ds.getConnection(); - assertNotNull(conn); - } - - public void testDBCreateMultiThread() throws Exception - { - DBCreateThread[] queue = new DBCreateThread[100]; - - for (int i = 0; i < queue.length; i++) - { - queue[i] = new DBCreateThread(i); - queue[i].start(); - } - - for (int i = 0; i < queue.length; i++) - { - queue[i].join(); - } - - for (int i = 0; i < queue.length; i++) - { - DataSource ds = (DataSource)initContext.getInitialContext().lookup("testjdbcjcr_" + i); - assertNotNull(ds); - - Connection conn = ds.getConnection(); - assertNotNull(conn); - } - - } - - class DBCreateThread extends Thread - { - - private final int threadNumber; - - DBCreateThread(int threadNumber) - { - this.threadNumber = threadNumber; - } - - /** - * {@inheritDoc} - */ - @Override - public void run() - { - try - { - DBConnectionInfo dbInfo = dbCreator.createDatabase("testdb_" + threadNumber); - - Map refAddr = dbInfo.getProperties(); - - initContext.getInitialContextBinder().bind("testjdbcjcr_" + threadNumber, "javax.sql.DataSource", - "org.apache.commons.dbcp.BasicDataSourceFactory", null, refAddr); - } - catch (Exception e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - -} diff --git a/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDatabaseService.java b/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDatabaseService.java deleted file mode 100644 index 766efbd0c..000000000 --- a/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestDatabaseService.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import junit.framework.TestCase; - -import org.exoplatform.container.PortalContainer; -import org.exoplatform.services.database.impl.XAPoolTxSupportDatabaseService; -import org.exoplatform.services.database.table.ExoLongID; -import org.exoplatform.services.database.table.IDGenerator; -import org.exoplatform.services.transaction.TransactionService; - -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.Statement; - -import javax.transaction.UserTransaction; - -/** - * Thu, May 15, 2003 @ - * @author Tuan Nguyen - * @version $Id: TestDatabaseService.java 5332 2006-04-29 18:32:44Z geaz $ - * @since 0.0 - * @email tuan08@yahoo.com - */ -public class TestDatabaseService extends TestCase -{ - - public void testDatabaseService() throws Exception - { - PortalContainer pcontainer = PortalContainer.getInstance(); - DatabaseService service = - (DatabaseService)pcontainer.getComponentInstanceOfType(XAPoolTxSupportDatabaseService.class); - assertNotNull(service); - assertConfiguration(service); - assertDBTableManager(service); - assertIDGenerator(service); - } - - private void assertConfiguration(DatabaseService service) throws Exception - { - TransactionService txservice = service.getTransactionService(); - assertTrue(service != null); - UserTransaction utx = txservice.getUserTransaction(); - Connection conn = service.getConnection(); - Statement s = null; - utx.begin(); - try - { - s = conn.createStatement(); - s.addBatch("create table test (name varchar(25), data varchar(25))"); - s.addBatch("insert into test values('name1', 'value1')"); - s.executeBatch(); - s.close(); - /* - * Call conn.commit() will cause an exception since the connection is now - * part of a global transaction. You should call utx.commit() here - */ - conn.commit(); - utx.commit(); - } - catch (Exception ex) - { - utx.rollback(); - } - // tm.rollback() ; - service.closeConnection(conn); - conn = service.getConnection(); - s = conn.createStatement(); - ResultSet rs = s.executeQuery("select name from test"); - if (rs.next()) - { - fail("Should not have any data in the test table"); - } - } - - private void assertDBTableManager(DatabaseService service) throws Exception - { - ExoDatasource datasource = service.getDatasource(); - DBTableManager dbManager = datasource.getDBTableManager(); - assertEquals(dbManager.hasTable(Mock.class), false); - dbManager.createTable(Mock.class, true); - - assertEquals(dbManager.hasTable(Mock.class), true); - dbManager.dropTable(Mock.class); - - assertEquals(dbManager.hasTable(Mock.class), false); - } - - private void assertIDGenerator(DatabaseService service) throws Exception - { - ExoDatasource datasource = service.getDatasource(); - IDGenerator idGenerator = new IDGenerator(datasource); - - for (int i = 0; i < 10; i++) - { - idGenerator.generateLongId(ExoLongID.class); - } - - idGenerator.restartTracker(); - idGenerator.generateLongId(ExoLongID.class); - } - -} diff --git a/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestHibernateService.java b/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestHibernateService.java deleted file mode 100644 index 6b70fdd09..000000000 --- a/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestHibernateService.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import junit.framework.TestCase; - -import org.exoplatform.container.PortalContainer; - -/** - * Thu, May 15, 2003 @ - * @author Tuan Nguyen - * @version $Id: TestDatabaseService.java 5332 2006-04-29 18:32:44Z geaz $ - * @since 0.0 - * @email tuan08@yahoo.com - */ -public class TestHibernateService extends TestCase -{ - HibernateService hservice_; - - public TestHibernateService(String name) - { - super(name); - } - - public void setUp() throws Exception - { - PortalContainer pcontainer = PortalContainer.getInstance(); - hservice_ = (HibernateService)pcontainer.getComponentInstanceOfType(HibernateService.class); - } - - public void testDabaseService() throws Exception - { - // assertTrue("Expect hibernate service instance" , hservice_ != null) ; - assertTrue("Expect database service instance", hservice_ != null); - } - - protected String getDescription() - { - return "Test Database Service"; - } -} diff --git a/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestQueryManager.java b/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestQueryManager.java deleted file mode 100644 index ee3151410..000000000 --- a/exo.core.component.database/src/test/java/org/exoplatform/services/database/TestQueryManager.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.database; - -import junit.framework.TestCase; - -/** - * Created by The eXo Platform SAS Author : Nhu Dinh Thuan - * nhudinhthuan@exoplatform.com Mar 30, 2007 - */ -public class TestQueryManager extends TestCase -{ - - QueryBuilder manager_; - - public TestQueryManager(String name) - { - super(name); - } - - public void setUp() throws Exception - { - manager_ = new QueryBuilder(); - } - - public void testPaser() throws Exception - { - String template = "select name from $table where id = $id and name like '&yahoo'"; - String[][] parameters = {{"table", "student"}, {"id", "12345"}}; - String pamameterSql = manager_.mapDataToSql(template, parameters); - } - - static public class Student - { - - String name, value; - - public Student(String n, String v) - { - name = n; - value = v; - } - - public String getName() - { - return name; - } - - public void setValue(String value) - { - this.value = value; - } - } - -} diff --git a/exo.core.component.database/src/test/resources/conf/portal/test-configuration.xml b/exo.core.component.database/src/test/resources/conf/portal/test-configuration.xml deleted file mode 100644 index 7221e1d3f..000000000 --- a/exo.core.component.database/src/test/resources/conf/portal/test-configuration.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - org.exoplatform.services.cache.CacheService - cache:type=CacheService - org.exoplatform.services.cache.impl.CacheServiceImpl - - - cache.config.default - The default cache configuration - - - default - - - 300 - - - 300 - - - false - - - org.exoplatform.services.cache.concurrent.ConcurrentFIFOExoCache - - - - - - - - org.exoplatform.services.database.DatabaseService - org.exoplatform.services.database.impl.XAPoolTxSupportDatabaseService - support the transaction db connection pool implementation - - - connection.config - Connection configuration - - - - - - - - - - - - org.exoplatform.services.transaction.TransactionService - org.exoplatform.services.transaction.impl.atomikos.TransactionsEssentialsTransactionService - - - timeout - 5 - - - - - - org.exoplatform.services.database.HibernateService - org.exoplatform.services.database.impl.HibernateServiceImpl - - - hibernate.properties - Default Hibernate Service - - - - - - - - - - - - - - - - - - - jcr.datasource - org.exoplatform.services.database.impl.HibernateServiceImpl - - - hibernate.properties - JCR Workspace datasource - - - - - - - - - - - - - - - - - - - - classpath:/conf/standalone/test-configuration.xml - diff --git a/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml b/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml deleted file mode 100644 index 8eb12fa15..000000000 --- a/exo.core.component.database/src/test/resources/conf/standalone/test-configuration.xml +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - org.exoplatform.services.log.LogConfigurationInitializer - org.exoplatform.services.log.LogConfigurationInitializer - - - logger - org.exoplatform.services.log.impl.BufferedLog4JLogger - - - configurator - org.exoplatform.services.log.impl.SimpleExoLogConfigurator - - - - - - org.exoplatform.services.database.jdbc.DBSchemaCreator - org.exoplatform.services.database.jdbc.DBSchemaCreator - - - create.dbschema - addPlugin - org.exoplatform.services.database.jdbc.CreateDBSchemaPlugin - - - data-source - jdbcjcr - - - script - - - - - - - - - - - org.exoplatform.services.database.creator.DBCreator - org.exoplatform.services.database.creator.DBCreator - - - db-connection - database connection properties - - - - - - - db-creation - database creation properties - - - - - - - - - org.exoplatform.services.naming.InitialContextInitializer - org.exoplatform.services.naming.InitialContextInitializer - - - bind.datasource - addPlugin - org.exoplatform.services.naming.BindReferencePlugin - - - bind-name - jdbcjcr - - - class-name - javax.sql.DataSource - - - factory - org.apache.commons.dbcp.BasicDataSourceFactory - - - ref-addresses - ref-addresses - - - - - - - - - - - default-properties - Default initial context properties - - - - - - - diff --git a/exo.core.component.database/src/test/resources/dbcreator/test.sql b/exo.core.component.database/src/test/resources/dbcreator/test.sql deleted file mode 100644 index e69de29bb..000000000 diff --git a/exo.core.component.database/src/test/resources/test.policy b/exo.core.component.database/src/test/resources/test.policy deleted file mode 100644 index f8801c31f..000000000 --- a/exo.core.component.database/src/test/resources/test.policy +++ /dev/null @@ -1,15 +0,0 @@ -grant codeBase "@MAVEN_REPO@-"{ - permission java.security.AllPermission; -}; - -grant codeBase "@MAIN_CLASSES@-"{ - permission java.security.AllPermission; -}; - -grant codeBase "@TEST_CLASSES@-"{ -}; - - - - - diff --git a/exo.core.component.organization.api/pom.xml b/exo.core.component.organization.api/pom.xml index 4f3630884..53ca423c7 100644 --- a/exo.core.component.organization.api/pom.xml +++ b/exo.core.component.organization.api/pom.xml @@ -54,24 +54,6 @@ org.hibernate.orm hibernate-core - - - org.slf4j - slf4j-api - - - org.jboss.spec.javax.transaction - jboss-transaction-api_1.1_spec - - - org.jboss.logging - jboss-logging - - - org.javassist - javassist - - org.mockito diff --git a/exo.core.component.script.groovy/pom.xml b/exo.core.component.script.groovy/pom.xml deleted file mode 100644 index 838f1d1bd..000000000 --- a/exo.core.component.script.groovy/pom.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - 4.0.0 - - - io.meeds.core - core-parent - 7.0.x-exo-SNAPSHOT - - - exo.core.component.script.groovy - - Meeds:: PLF Core :: Component :: Groovy Scripts Instantiator - Groovy Scripts Instantiator of Exoplatform SAS 'eXo Core' project. - - - 0.69 - - - - - io.meeds.kernel - exo.kernel.container - - - io.meeds.kernel - exo.kernel.commons.test - test - - - org.codehaus.groovy - groovy-all - - - - - - - maven-antrun-plugin - - - prepare-test-policy - process-test-resources - - - Creating Access Policy for tests - - - - - - - - - - - - - - - - - run - - - - - - - diff --git a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptInstantiator.java b/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptInstantiator.java deleted file mode 100644 index bb919d70e..000000000 --- a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptInstantiator.java +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy; - -import groovy.lang.GroovyClassLoader; -import groovy.lang.GroovyCodeSource; - -import org.codehaus.groovy.control.CompilationFailedException; - -import org.exoplatform.commons.utils.IOUtil; -import org.exoplatform.container.ExoContainer; -import org.exoplatform.container.ExoContainerContext; -import org.exoplatform.container.component.ComponentPlugin; -import org.exoplatform.container.spi.DefinitionByType; -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; -import org.exoplatform.services.script.groovy.jarjar.JarJarClassLoader; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Constructor; -import java.net.MalformedURLException; -import java.net.URL; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Andrey Parfonov - * @version $Id: $ - */ -@DefinitionByType -public class GroovyScriptInstantiator -{ - - /** Our logger. */ - private static final Log LOG = ExoLogger.getLogger(GroovyScriptInstantiator.class); - - /** - * eXo Container. - */ - private ExoContainer container; - - /** The global mapping. */ - private Map mapping; - - /** - * @param containerContext container context - */ - public GroovyScriptInstantiator(ExoContainerContext containerContext) - { - this.container = containerContext.getContainer(); - this.mapping = Collections.synchronizedMap(new HashMap()); - } - - /** - * Load script from given address. - * - * @param spec the resource's address. - * @return the object created from groovy script. - * @throws MalformedURLException if parameter url have wrong - * format. - * @throws IOException if can't load script from given url. - * @see GroovyScriptInstantiator#instantiateScript(URL) - * @see GroovyScriptInstantiator#instantiateScript(InputStream) - */ - public Object instantiateScript(String spec) throws MalformedURLException, IOException - { - return instantiateScript(new URL(spec)); - } - - /** - * Load script from given address. - * - * @param url the resource's address. - * @return the object created from groovy script. - * @throws IOException if can't load script from given url. - * @see GroovyScriptInstantiator#instantiateScript(InputStream) - */ - public Object instantiateScript(URL url) throws IOException - { - String name = url.toString(); - return instantiateScript(new BufferedInputStream(url.openStream()), name); - } - - /** - * Parse given stream, the stream must represents groovy script. - * - * @param stream the stream represented groovy script. - * @return the object created from groovy script. - * @throws IOException if stream can't be parsed or object can't be created - * cause to illegal content of stream - */ - public Object instantiateScript(InputStream stream) throws IOException - { - return instantiateScript(stream, null); - } - - /** - * Parse given stream, the stream must represents groovy script. - * - * @param stream the stream represented groovy script. - * @param name script name is null or empty string that groovy completer will - * use default name - * @return the object created from groovy script. - * @throws IOException if stream can't be parsed or object can't be created - * cause to illegal content of stream - */ - public Object instantiateScript(InputStream stream, String name) throws IOException - { - GroovyClassLoader loader; - if (mapping.size() > 0) - { - JarJarClassLoader jarjarLoader = new JarJarClassLoader(); - - jarjarLoader.addMapping(mapping); - loader = jarjarLoader; - } - else - { - loader = new GroovyClassLoader(); - } - return instantiateScript(stream, name, loader); - } - - /** - * Parse given stream, the stream must represents groovy script and use given - * class-loader. If loader == null then - * {@link groovy.lang.GroovyClassLoader} will be is use. - * - * @param stream the stream represented groovy script. - * @param name script name is null or empty string that groovy completer will - * use default name - * @param loader GroovyClassLoader or null - * @return the object created from groovy script. - * @throws IOException if stream can't be parsed or object can't be created - * cause to illegal content of stream - */ - public Object instantiateScript(final InputStream stream, final String name, GroovyClassLoader loader) - throws IOException - { - if (loader == null) - { - loader = new GroovyClassLoader(); - } - Class clazz = null; - final GroovyClassLoader fLoader = loader; - clazz = fLoader.parseClass(IOUtil.getStreamContentAsString(stream)); - - try - { - return createObject(clazz); - } - catch (Exception e) - { - throw new RuntimeException("Can't instantiate groovy script: " + e.getMessage(), e); - } - finally - { - if(stream != null) { - try { - stream.close(); - } catch (IOException e) { - // Stream already closed - } - } - } - } - - /** - * Instantiate script from give {@link GroovyCodeSource} and use given - * class-loader. If loader == null then - * {@link groovy.lang.GroovyClassLoader} will be is use. - * - * @param codeSource code source - * @param loader - * @return - */ - public Object instantiateScript(final GroovyCodeSource codeSource, GroovyClassLoader loader) - { - if (loader == null) - { - loader = new GroovyClassLoader(); - } - - final GroovyClassLoader fLoader = loader; - Class clazz = fLoader.parseClass(codeSource); - - try - { - return createObject(clazz); - } - catch (Exception e) - { - throw new RuntimeException("Can't instantiate groovy script: " + e.getMessage(), e); - } - } - - /** - * Created object from given class, if class has parameters in constructor, - * then this parameters will be searched in container. - * - * @param clazz java-groovy class - */ - private Object createObject(Class clazz) throws Exception - { - - Constructor[] constructors = clazz.getConstructors(); - - /* - * Sort constructors by number of parameters. With more parameters must be - * first. - */ - Arrays.sort(constructors, COMPARATOR); - - l : for (Constructor c : constructors) - { - Class[] parameterTypes = c.getParameterTypes(); - if (parameterTypes.length == 0) - { - return c.newInstance(); - } - - List parameters = new ArrayList(parameterTypes.length); - - for (Class parameterType : parameterTypes) - { - Object param = container.getComponentInstanceOfType(parameterType); - if (param == null) - { - continue l; - } - parameters.add(param); - } - - return c.newInstance(parameters.toArray(new Object[parameters.size()])); - } - return null; - - } - - private static final ConstructorsComparator COMPARATOR = new ConstructorsComparator(); - - /** - * Sorts array of constructors by number of parameters. - */ - private static class ConstructorsComparator implements Comparator> - { - - /** - * {@inheritDoc} - */ - public int compare(Constructor constructor1, Constructor constructor2) - { - int c1 = constructor1.getParameterTypes().length; - int c2 = constructor2.getParameterTypes().length; - if (c1 < c2) - { - return 1; - } - if (c1 > c2) - { - return -1; - } - return 0; - } - - } - - public void addPlugin(ComponentPlugin plugin) - { - if (plugin instanceof GroovyScriptJarJarPlugin) - { - GroovyScriptJarJarPlugin jarjarPlugin = (GroovyScriptJarJarPlugin)plugin; - if (LOG.isDebugEnabled()) - { - LOG.debug("Add mapping to groovy instantiator:" + jarjarPlugin.getMapping()); - } - mapping.putAll(jarjarPlugin.getMapping()); - } - } - -} diff --git a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptJarJarPlugin.java b/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptJarJarPlugin.java deleted file mode 100644 index 39d5e263c..000000000 --- a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptJarJarPlugin.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy; - -import org.exoplatform.container.component.BaseComponentPlugin; -import org.exoplatform.container.xml.InitParams; -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * A plugin that retrieves a mapping from the init param named mapping. The param - * is a multivalued string, each string has the format {@literal left->right} where left and right - * are package full qualified names. - * - * @author Julien Viet - * @version $Revision$ - */ -public class GroovyScriptJarJarPlugin extends BaseComponentPlugin -{ - - /** The mapping state. */ - private final Map mapping = new HashMap(); - - /** Our logger. */ - private final static Log LOG = ExoLogger.getLogger("exo.core.component.script.groovy.GroovyScriptJarJarPlugin"); - - public GroovyScriptJarJarPlugin(InitParams params) - { - - List values = params.getValuesParam("mapping").getValues(); - - if (mapping == null) - { - LOG.warn("Was expecting a mapping init param"); - } - else - { - for (Iterator i = values.iterator(); i.hasNext();) - { - String rule = i.next(); - - String[] tmp = rule.split("\\-\\>"); - if (tmp.length == 2) - { - String left = tmp[0].trim(); - String right = tmp[1].trim(); - mapping.put(left, right); - LOG.debug("Added mapping rule " + left + " -> " + right); - } - else - { - LOG.warn("Malformed mapping rule:" + rule); - } - } - } - } - - public Map getMapping() - { - return mapping; - } -} diff --git a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptURLLoaderPlugin.java b/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptURLLoaderPlugin.java deleted file mode 100644 index 735a50a73..000000000 --- a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/GroovyScriptURLLoaderPlugin.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy; - -import org.exoplatform.container.component.BaseComponentPlugin; -import org.exoplatform.container.xml.InitParams; -import org.exoplatform.container.xml.ObjectParameter; - -import java.util.ArrayList; -import java.util.List; - -/** - * Should be used by third part service for loading script at start. - * - * @author Andrey Parfonov - * @version $Id: $ - */ -public class GroovyScriptURLLoaderPlugin extends BaseComponentPlugin -{ - - private List urls; - - public GroovyScriptURLLoaderPlugin(InitParams params) - { - if (params != null) - { - ObjectParameter param = params.getObjectParam("scripts"); - if (param != null) - urls = ((GroovyScriptURLs)param.getObject()).getUrls(); - } - } - - /** - * @return list of URL from configuration. - */ - public List getUrls() - { - return urls; - } - - /** - * Should be used in configuration as object parameter. - */ - public static class GroovyScriptURLs - { - - private List urls = new ArrayList(); - - public List getUrls() - { - return urls; - } - - public void setUrls(List urls) - { - this.urls = urls; - } - } - -} diff --git a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/jarjar/JarJarClassLoader.java b/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/jarjar/JarJarClassLoader.java deleted file mode 100644 index 404d66dce..000000000 --- a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/jarjar/JarJarClassLoader.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy.jarjar; - -import groovy.lang.GroovyClassLoader; - -import org.codehaus.groovy.ast.ClassNode; -import org.codehaus.groovy.ast.ImportNode; -import org.codehaus.groovy.ast.ModuleNode; -import org.codehaus.groovy.classgen.GeneratorContext; -import org.codehaus.groovy.control.CompilationFailedException; -import org.codehaus.groovy.control.CompilationUnit; -import org.codehaus.groovy.control.CompilerConfiguration; -import org.codehaus.groovy.control.Phases; -import org.codehaus.groovy.control.SourceUnit; - -import java.security.CodeSource; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * A groovy class loader that performs jar jar operations. - * - * @author Julien Viet - * @version $Revision$ - */ -public class JarJarClassLoader extends GroovyClassLoader -{ - - private Package root = new Package(); - - public JarJarClassLoader() - { - } - - public JarJarClassLoader(ClassLoader classLoader) - { - super(classLoader); - } - - public JarJarClassLoader(GroovyClassLoader groovyClassLoader) - { - super(groovyClassLoader); - } - - public JarJarClassLoader(ClassLoader classLoader, CompilerConfiguration compilerConfiguration, boolean b) - { - super(classLoader, compilerConfiguration, b); - } - - public JarJarClassLoader(ClassLoader classLoader, CompilerConfiguration compilerConfiguration) - { - super(classLoader, compilerConfiguration); - } - - public void addMapping(List source, List destination) - { - root.add(source, destination); - } - - public void addMapping(Map mapping) - { - for (Map.Entry entry : mapping.entrySet()) - { - addMapping(entry.getKey(), entry.getValue()); - } - } - - public void addMapping(String source, String destination) - { - List sourcePackage = Arrays.asList(source.split("\\.")); - List destinationPackage = Arrays.asList(destination.split("\\.")); - root.add(sourcePackage, destinationPackage); - } - - @Override - protected CompilationUnit createCompilationUnit(final CompilerConfiguration compilerConfiguration, - final CodeSource codeSource) - { - // - final CompilationUnit unit = JarJarClassLoader.super.createCompilationUnit(compilerConfiguration, codeSource); - - // - unit.addPhaseOperation(new CompilationUnit.PrimaryClassNodeOperation() - { - @Override - public void call(SourceUnit sourceUnit, GeneratorContext generatorContext, ClassNode classNode) - throws CompilationFailedException - { - - // - ModuleNode module = classNode.getModule(); - - // - for (Iterator i = module.getImports().iterator(); i.hasNext();) - { - ImportNode importNode = i.next(); - ClassNode cn = importNode.getType(); - String s = cn.getPackageName(); - List ss = root.map2(s); - if (ss != null) - { - StringBuilder sb = new StringBuilder(); - for (String n : ss) - { - sb.append(n).append('.'); - } - sb.append(cn.getNameWithoutPackage()); - String name = sb.toString(); - cn.setName(name); - } - } - - // - JarJarExpressionTransformer visitor = new JarJarExpressionTransformer(sourceUnit, root); - visitor.visitClass(classNode); - } - }, Phases.CONVERSION); - - return unit; - } - - static protected JarJarClassLoader createJarJarClassLoaderInPrivilegedMode(final ClassLoader classLoader) - { - return new JarJarClassLoader(classLoader); - } -} diff --git a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/jarjar/JarJarExpressionTransformer.java b/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/jarjar/JarJarExpressionTransformer.java deleted file mode 100644 index 126c5df09..000000000 --- a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/jarjar/JarJarExpressionTransformer.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy.jarjar; - -import org.codehaus.groovy.ast.ClassCodeExpressionTransformer; -import org.codehaus.groovy.ast.ClassHelper; -import org.codehaus.groovy.ast.ClassNode; -import org.codehaus.groovy.ast.expr.ConstantExpression; -import org.codehaus.groovy.ast.expr.Expression; -import org.codehaus.groovy.ast.expr.MethodCallExpression; -import org.codehaus.groovy.ast.expr.PropertyExpression; -import org.codehaus.groovy.ast.expr.VariableExpression; -import org.codehaus.groovy.control.SourceUnit; - -import java.util.List; - -/** - * @author Julien Viet - * @version $Revision$ - */ -class JarJarExpressionTransformer extends ClassCodeExpressionTransformer -{ - - /** . */ - private final SourceUnit source; - - /** . */ - private final Package root; - - JarJarExpressionTransformer(SourceUnit source, Package root) - { - this.source = source; - this.root = root; - } - - protected SourceUnit getSourceUnit() - { - return source; - } - - @Override - public Expression transform(Expression expression) - { - - // Handle method call expressions - if (expression instanceof MethodCallExpression) - { - MethodCallExpression mce = (MethodCallExpression)expression; - - // - if (mce.getObjectExpression() instanceof PropertyExpression) - { - PropertyExpression mce_pe = (PropertyExpression)mce.getObjectExpression(); - - // - Expression expr = bilto(mce_pe); - if (expr != null) - { - mce.setObjectExpression(expr); - } - } - } - return super.transform(expression); - } - - private Expression bilto(Expression exp) - { - - String s = exp.getText(); - - List ss = root.map2(exp); - - if (ss != null) - { - System.out.println(s + " -> " + ss); //NOSONAR - return createExpr(ss); - } - - return null; - } - - private static Expression createExpr(List packageName) - { - if (packageName.isEmpty()) - { - throw new IllegalStateException("Root does not have prefix"); - } - - // - if (packageName.size() == 1) - { - String name = packageName.get(0); - ClassNode objectCN = getClassNode(Object.class); - return new VariableExpression(name, objectCN); - } - else - { - Expression left = createExpr(packageName.subList(0, packageName.size() - 1)); - ConstantExpression right = new ConstantExpression(packageName.get(packageName.size() - 1)); - return new PropertyExpression(left, right); - } - } - - private static ClassNode getClassNode(Class clazz) - { - return ClassHelper.make(clazz); - } -} diff --git a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/jarjar/Package.java b/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/jarjar/Package.java deleted file mode 100644 index da39d7941..000000000 --- a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/jarjar/Package.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy.jarjar; - -import org.codehaus.groovy.ast.expr.ConstantExpression; -import org.codehaus.groovy.ast.expr.Expression; -import org.codehaus.groovy.ast.expr.PropertyExpression; -import org.codehaus.groovy.ast.expr.VariableExpression; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -/** - * Represents a package. - * - * @author Julien Viet - * @version $Revision$ - */ -class Package -{ - - /** . */ - private final Package parent; - - /** . */ - private final Map subMappers; - - /** . */ - private List target; - - public Package() - { - this.parent = null; - this.target = null; - this.subMappers = new HashMap(); - } - - private Package(Package parent) - { - this.parent = parent; - this.target = null; - this.subMappers = new HashMap(); - } - - public void add(List source, List target) - { - add(source.iterator(), target); - } - - public Package getSubPackage(String name) - { - return subMappers.get(name); - } - - private void add(Iterator source, List target) - { - if (source.hasNext()) - { - String name = source.next(); - Package sub = subMappers.get(name); - if (sub == null) - { - sub = new Package(this); - subMappers.put(name, sub); - } - sub.add(source, target); - } - else - { - if (this.target != null) - { - throw new IllegalStateException(); - } - this.target = Collections.unmodifiableList(target); - } - } - - public List getTarget() - { - return target; - } - - public String getName() - { - if (parent != null) - { - for (Map.Entry entry : parent.subMappers.entrySet()) - { - if (entry.getValue() == this) - { - return entry.getKey(); - } - } - } - return null; - } - - public Package map(Expression exp) - { - Package mapmap = null; - if (exp instanceof VariableExpression) - { - String name = ((VariableExpression)exp).getName(); - mapmap = getSubPackage(name); - } - else if (exp instanceof PropertyExpression) - { - PropertyExpression pe = (PropertyExpression)exp; - if (pe.getObjectExpression() instanceof VariableExpression) - { - mapmap = map(pe.getObjectExpression()); - } - else if (pe.getObjectExpression() instanceof PropertyExpression) - { - PropertyExpression pe_pe = (PropertyExpression)pe.getObjectExpression(); - mapmap = map(pe_pe); - } - else - { - // - } - if (mapmap != null) - { - ConstantExpression pe_ce = (ConstantExpression)pe.getProperty(); - if (pe_ce.getType().getName().equals("java.lang.String")) - { - Package sub_sub = mapmap.getSubPackage((String)pe_ce.getValue()); - if (sub_sub != null) - { - mapmap = sub_sub; - } - } - } - } - return mapmap; - } - - private static class BiltoVisitor extends PackageNameVisitor - { - - Package ref; - - List bilto = new LinkedList(); - - boolean repackaged = false; - - private BiltoVisitor(Package mapper) - { - this.ref = mapper; - } - - protected void accept(String name) - { - if (ref != null) - { - Package sub = ref.getSubPackage(name); - if (sub != null) - { - List target = sub.target; - if (target != null) - { - // Use the repackaging rule - bilto.clear(); - bilto.addAll(target); - repackaged = true; - } - else - { - // Add name - bilto.add(name); - } - ref = sub; - } - else - { - // Add name and set null as marker - bilto.add(name); - ref = null; - } - } - else - { - // Add name - bilto.add(name); - } - } - } - - public List map2(Expression expr) - { - BiltoVisitor visitor = new BiltoVisitor(this); - visitor.visit(expr); - return visitor.repackaged ? visitor.bilto : null; - } - - public List map2(String expr) - { - BiltoVisitor visitor = new BiltoVisitor(this); - visitor.visit(expr); - return visitor.repackaged ? visitor.bilto : null; - } - - @Override - public String toString() - { - StringBuilder sb = new StringBuilder(); - toString(sb); - return sb.toString(); - } - - private void toString(StringBuilder sb) - { - if (parent != null) - { - parent.toString(sb); - String name = getName(); - sb.append(".").append(name); - } - } -} diff --git a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/jarjar/PackageNameVisitor.java b/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/jarjar/PackageNameVisitor.java deleted file mode 100644 index 4806f9943..000000000 --- a/exo.core.component.script.groovy/src/main/java/org/exoplatform/services/script/groovy/jarjar/PackageNameVisitor.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy.jarjar; - -import org.codehaus.groovy.ast.expr.ConstantExpression; -import org.codehaus.groovy.ast.expr.Expression; -import org.codehaus.groovy.ast.expr.PropertyExpression; -import org.codehaus.groovy.ast.expr.VariableExpression; - -/** - * Implement visitor pattern for visiting a package name from left to right. - * - * @author Julien Viet - * @version $Revision$ - */ -abstract class PackageNameVisitor -{ - - /** - * Visit a name from its dotted string representation. - * - * @param packageName the package name - */ - public void visit(String packageName) - { - for (String name : packageName.split("\\.")) - { - accept(name); - } - } - - /** - * Visit a name from its groovy expression AST representation. - * - *

- * The AST structure we are recognizing in that method is: - *

    - *
  • Expression -> VariableExpression
  • - *
  • Expression -> PropertyExpression[ObjectExpression,ConstantExpression] - *
- *

- * - *

A VariableExpression is considered as a terminal that is the top left term. Its name - * value is obtained by calling the getName() method.

- * - *

A PropertyExpression is composed of an ObjectExpression and a Property. The ObjectExpression is evaluated - * recursively as an Expression. The Property must be a ConstantExpression and the name value is obtained - * by calling the getValue() method.

- * - * @param expr the expression AST - */ - public void visit(Expression expr) - { - if (expr instanceof VariableExpression) - { - String name = ((VariableExpression)expr).getName(); - accept(name); - } - else if (expr instanceof PropertyExpression) - { - PropertyExpression pe = (PropertyExpression)expr; - visit(pe.getObjectExpression()); - ConstantExpression pe_ce = (ConstantExpression)pe.getProperty(); - accept((String)pe_ce.getValue()); - } - else - { - throw new UnsupportedOperationException("Do not support expression of type" + expr + " with text " - + expr.getText()); - } - } - - /** - * Implement this method to receive a name callback. - * - * @param name the name - */ - protected abstract void accept(String name); - -} diff --git a/exo.core.component.script.groovy/src/test/java/a/ClassLitteral.java b/exo.core.component.script.groovy/src/test/java/a/ClassLitteral.java deleted file mode 100644 index 560cbc9c6..000000000 --- a/exo.core.component.script.groovy/src/test/java/a/ClassLitteral.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package a; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class ClassLitteral -{ - - public static String getValue() - { - return "a"; - } -} diff --git a/exo.core.component.script.groovy/src/test/java/a/ImportedClass.java b/exo.core.component.script.groovy/src/test/java/a/ImportedClass.java deleted file mode 100644 index de5b8ed1a..000000000 --- a/exo.core.component.script.groovy/src/test/java/a/ImportedClass.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package a; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class ImportedClass -{ - - public String getValue() - { - return "a"; - } -} diff --git a/exo.core.component.script.groovy/src/test/java/b/ClassLitteral.java b/exo.core.component.script.groovy/src/test/java/b/ClassLitteral.java deleted file mode 100644 index 768180680..000000000 --- a/exo.core.component.script.groovy/src/test/java/b/ClassLitteral.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package b; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class ClassLitteral -{ - - public static String getValue() - { - return "b"; - } -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/java/b/ImportedClass.java b/exo.core.component.script.groovy/src/test/java/b/ImportedClass.java deleted file mode 100644 index 4db7ef43f..000000000 --- a/exo.core.component.script.groovy/src/test/java/b/ImportedClass.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package b; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class ImportedClass -{ - - public String getValue() - { - return "b"; - } -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/Book.java b/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/Book.java deleted file mode 100644 index 4eced2629..000000000 --- a/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/Book.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy; - -/** - * @author Andrey Parfonov - * @version $Id: $ - */ -public class Book -{ - - private String title = "Groovy in Action"; - - private String author = "Andrew Glover"; - - private float price = 20.10F; - - private String isdn = "1234567890987654321"; - - public String getTitle() - { - return title; - } - - public void setTitle(String title) - { - this.title = title; - } - - public String getAuthor() - { - return author; - } - - public void setAuthor(String author) - { - this.author = author; - } - - public float getPrice() - { - return price; - } - - public void setPrice(float price) - { - this.price = price; - } - - public String getIsdn() - { - return isdn; - } - - public void setIsdn(String isdn) - { - this.isdn = isdn; - } - -} diff --git a/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/GroovyInstantiatorTest.java b/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/GroovyInstantiatorTest.java deleted file mode 100644 index 314f1e73a..000000000 --- a/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/GroovyInstantiatorTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy; - -import b.ImportedClass; -import groovy.lang.GroovyObject; -import junit.framework.TestCase; - -import org.exoplatform.container.ExoContainer; -import org.exoplatform.container.StandaloneContainer; - -/** - * @author Andrey Parfonov - * @version $Id: $ - */ -public class GroovyInstantiatorTest extends TestCase -{ - - private GroovyScriptInstantiator groovyScriptInstantiator; - - private GroovyScriptInstantiator jarjarGroovyScriptInstantiator; - - /* - * (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - @Override - public void setUp() throws Exception - { - StandaloneContainer.setConfigurationPath("src/test/resources/conf/standalone/test-configuration.xml"); - ExoContainer container = StandaloneContainer.getInstance(); - groovyScriptInstantiator = - (GroovyScriptInstantiator)container.getComponentInstance(GroovyScriptInstantiator.class); - jarjarGroovyScriptInstantiator = - (GroovyScriptInstantiator)container.getComponentInstance("JarJarGroovyScriptInstantiator"); - assertNotNull(groovyScriptInstantiator); - assertNotNull(jarjarGroovyScriptInstantiator); - } - - public void testGroovyScriptInstantiatorSimple() throws Exception - { - String url = Thread.currentThread().getContextClassLoader().getResource("Book.groovy").toString(); - GroovyObject groovyObject = (GroovyObject)groovyScriptInstantiator.instantiateScript(url); - /* - * --- Groovy code --- def title = "Groovy in Action" def author = - * "Andrew Glover" def price = 20.10 def isdn = "1234567890987654321" - */ - assertEquals("Andrew Glover", groovyObject.getProperty("author")); - assertEquals("Groovy in Action", groovyObject.getProperty("title")); - assertEquals("1234567890987654321", groovyObject.getProperty("isdn")); - assertEquals(20, groovyObject.getProperty("price")); - groovyObject.setProperty("price", 10); - assertEquals(10, groovyObject.getProperty("price")); - } - - public void testGroovyScriptInstantiatorInjection() throws Exception - { - String url = Thread.currentThread().getContextClassLoader().getResource("TestInjection.groovy").toString(); - GroovyObject groovyObject = (GroovyObject)groovyScriptInstantiator.instantiateScript(url); - assertNotNull(groovyObject.getProperty("sampleComponent")); - assertEquals("sample component", ((SampleComponent)groovyObject.getProperty("sampleComponent")).getAbout()); - } - - public void testGroovyScriptInstantiatorXML() throws Exception - { - String url = - Thread.currentThread().getContextClassLoader().getResource("TestSimpleXMLGenerator.groovy").toString(); - GroovyObject groovyObject = (GroovyObject)groovyScriptInstantiator.instantiateScript(url); - groovyObject.invokeMethod("generateXML", new Object[]{new Book()}); - } - - public void testGroovyScriptJarJar() throws Exception - { - String url = Thread.currentThread().getContextClassLoader().getResource("TestJarJar.groovy").toString(); - GroovyObject groovyObject = (GroovyObject)jarjarGroovyScriptInstantiator.instantiateScript(url); - Object field = groovyObject.getProperty("field"); - assertNotNull(field); - assertTrue("Was expecting object " + field + " to be an instance of class " + ImportedClass.class.getName() - + "instead of class " + field.getClass().getName(), field instanceof ImportedClass); - } -} diff --git a/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/SampleComponent.java b/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/SampleComponent.java deleted file mode 100644 index babb1d921..000000000 --- a/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/SampleComponent.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy; - -/** - * @author Andrey Parfonov - * @version $Id: $ - */ -public class SampleComponent -{ - - // nothing to do, it must be injected it constructor of Groovy script - - private String about = "sample component"; - - public String getAbout() - { - return about; - } - - public void setAbout(String about) - { - this.about = about; - } - -} diff --git a/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/jarjar/JarJarTest.java b/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/jarjar/JarJarTest.java deleted file mode 100644 index cfcf818a3..000000000 --- a/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/jarjar/JarJarTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy.jarjar; - -import junit.framework.AssertionFailedError; -import junit.framework.TestCase; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class JarJarTest extends TestCase -{ - - public static AssertionFailedError error = null; - - public JarJarTest() - { - } - - public JarJarTest(String s) - { - super(s); - } - - private void testTop(TestScript script) - { - Mapping m1 = new Mapping(); - m1.addMapping("a", "b"); - Mapping m2 = new Mapping(); - m2.addMapping("a", "prefix1.a"); - - // Transform a top package into a top package - assertEquals("b", script.execute(m1)); - - // Transform a top package into a prefixed package - assertEquals("prefix1.a", script.execute(m2)); - } - - public void testTopClassLitteral() throws Exception - { - testTop(new TestScript("classlitteral1.groovy")); - testTop(new TestScript("classlitteral_1.groovy")); - testTop(new TestScript("import1.groovy")); - } - - private void testPrefix(TestScript script) throws Exception - { - Mapping m1 = new Mapping(); - m1.addMapping("prefix1", "prefix2"); - Mapping m2 = new Mapping(); - m2.addMapping("prefix1.a", "a"); - Mapping m3 = new Mapping(); - m3.addMapping("prefix1.a", "prefix2.b"); - Mapping m4 = new Mapping(); - m4.addMapping("prefix1.a", "prefix1.b"); - - // Transform the top package prefix - assertEquals("prefix2.a", script.execute(m1)); - - // Transform the full prefixed package - assertEquals("a", script.execute(m2)); - - // Transform the full prefixed package - assertEquals("prefix2.b", script.execute(m3)); - - // Transform the full prefixed package - assertEquals("prefix1.b", script.execute(m4)); - } - - public void testPrefixClassLitteral() throws Exception - { - testPrefix(new TestScript("classlitteral2.groovy")); - testPrefix(new TestScript("classlitteral_2.groovy")); - testPrefix(new TestScript("import2.groovy")); - } -} diff --git a/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/jarjar/Mapping.java b/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/jarjar/Mapping.java deleted file mode 100644 index e54f7d606..000000000 --- a/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/jarjar/Mapping.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy.jarjar; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class Mapping -{ - - /** . */ - private final Map, List> map; - - public Mapping() - { - map = new HashMap, List>(); - } - - public void addMapping(String source, String destination) - { - List sourcePackage = Arrays.asList(source.split("\\.")); - List destinationPackage = Arrays.asList(destination.split("\\.")); - map.put(sourcePackage, destinationPackage); - } - - public void configure(JarJarClassLoader loader) - { - for (Map.Entry, List> entry : map.entrySet()) - { - loader.addMapping(entry.getKey(), entry.getValue()); - } - } -} diff --git a/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/jarjar/TestScript.java b/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/jarjar/TestScript.java deleted file mode 100644 index 03dc5fab5..000000000 --- a/exo.core.component.script.groovy/src/test/java/org/exoplatform/services/script/groovy/jarjar/TestScript.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.script.groovy.jarjar; - -import groovy.lang.GroovyCodeSource; -import groovy.lang.GroovyObject; -import junit.framework.Assert; -import junit.framework.AssertionFailedError; - -import java.io.IOException; -import java.net.URL; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class TestScript -{ - - /** . */ - private final String name; - - public TestScript(String name) - { - this.name = name; - } - - public Object execute(Mapping mapping) - { - - // - JarJarClassLoader loader = - JarJarClassLoader.createJarJarClassLoaderInPrivilegedMode(Thread.currentThread().getContextClassLoader()); - - // - mapping.configure(loader); - - // Obtain script class - URL url = Thread.currentThread().getContextClassLoader().getResource("jarjar/" + name); - Assert.assertNotNull(url); - GroovyCodeSource gcs; - try - { - gcs = new GroovyCodeSource(url); - } - catch (Exception e) - { - AssertionFailedError err = new AssertionFailedError(); - err.initCause(e); - throw err; - } - - Class testClass = loader.parseClass(gcs);; - - // Instantiate script - GroovyObject testObject; - try - { - testObject = (GroovyObject)testClass.newInstance(); - } - catch (Exception e) - { - AssertionFailedError err = new AssertionFailedError(); - err.initCause(e); - throw err; - } - - // Invoke finally - return testObject.invokeMethod("run", new Object[0]); - } -} diff --git a/exo.core.component.script.groovy/src/test/java/prefix1/a/ClassLitteral.java b/exo.core.component.script.groovy/src/test/java/prefix1/a/ClassLitteral.java deleted file mode 100644 index 9b4f68ba3..000000000 --- a/exo.core.component.script.groovy/src/test/java/prefix1/a/ClassLitteral.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package prefix1.a; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class ClassLitteral -{ - - public static String getValue() - { - return "prefix1.a"; - } -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/java/prefix1/a/ImportedClass.java b/exo.core.component.script.groovy/src/test/java/prefix1/a/ImportedClass.java deleted file mode 100644 index b958f1221..000000000 --- a/exo.core.component.script.groovy/src/test/java/prefix1/a/ImportedClass.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package prefix1.a; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class ImportedClass -{ - - public String getValue() - { - return "prefix1.a"; - } -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/java/prefix1/b/ClassLitteral.java b/exo.core.component.script.groovy/src/test/java/prefix1/b/ClassLitteral.java deleted file mode 100644 index 129baa64b..000000000 --- a/exo.core.component.script.groovy/src/test/java/prefix1/b/ClassLitteral.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package prefix1.b; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class ClassLitteral -{ - - public static String getValue() - { - return "prefix1.b"; - } -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/java/prefix1/b/ImportedClass.java b/exo.core.component.script.groovy/src/test/java/prefix1/b/ImportedClass.java deleted file mode 100644 index dff145b1a..000000000 --- a/exo.core.component.script.groovy/src/test/java/prefix1/b/ImportedClass.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package prefix1.b; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class ImportedClass -{ - - public String getValue() - { - return "prefix1.b"; - } -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/java/prefix2/a/ClassLitteral.java b/exo.core.component.script.groovy/src/test/java/prefix2/a/ClassLitteral.java deleted file mode 100644 index e761b5864..000000000 --- a/exo.core.component.script.groovy/src/test/java/prefix2/a/ClassLitteral.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package prefix2.a; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class ClassLitteral -{ - - public static String getValue() - { - return "prefix2.a"; - } -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/java/prefix2/a/ImportedClass.java b/exo.core.component.script.groovy/src/test/java/prefix2/a/ImportedClass.java deleted file mode 100644 index ea042fad8..000000000 --- a/exo.core.component.script.groovy/src/test/java/prefix2/a/ImportedClass.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package prefix2.a; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class ImportedClass -{ - - public String getValue() - { - return "prefix2.a"; - } -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/java/prefix2/b/ClassLitteral.java b/exo.core.component.script.groovy/src/test/java/prefix2/b/ClassLitteral.java deleted file mode 100644 index 0d58a6b1a..000000000 --- a/exo.core.component.script.groovy/src/test/java/prefix2/b/ClassLitteral.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package prefix2.b; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class ClassLitteral -{ - - public static String getValue() - { - return "prefix2.b"; - } -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/java/prefix2/b/ImportedClass.java b/exo.core.component.script.groovy/src/test/java/prefix2/b/ImportedClass.java deleted file mode 100644 index 73bea2a76..000000000 --- a/exo.core.component.script.groovy/src/test/java/prefix2/b/ImportedClass.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package prefix2.b; - -/** - * @author Julien Viet - * @version $Revision$ - */ -public class ImportedClass -{ - - public String getValue() - { - return "prefix2.b"; - } -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/resources/Book.groovy b/exo.core.component.script.groovy/src/test/resources/Book.groovy deleted file mode 100644 index 66e365fca..000000000 --- a/exo.core.component.script.groovy/src/test/resources/Book.groovy +++ /dev/null @@ -1,8 +0,0 @@ -package org.exoplatform.script.groovy.test - -class Book { - def title = "Groovy in Action" - def author = "Andrew Glover" - def price = 20 - def isdn = "1234567890987654321" -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/resources/TestInjection.groovy b/exo.core.component.script.groovy/src/test/resources/TestInjection.groovy deleted file mode 100644 index efda0172f..000000000 --- a/exo.core.component.script.groovy/src/test/resources/TestInjection.groovy +++ /dev/null @@ -1,12 +0,0 @@ -package org.exoplatform.script.groovy.test - -public class TestInjection { - - def org.exoplatform.services.script.groovy.SampleComponent sampleComponent - - // Object in constructor must be in container - public TestInjection(org.exoplatform.services.script.groovy.SampleComponent sampleComponent) { - this.sampleComponent = sampleComponent; - } - -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/resources/TestJarJar.groovy b/exo.core.component.script.groovy/src/test/resources/TestJarJar.groovy deleted file mode 100644 index ba3866faa..000000000 --- a/exo.core.component.script.groovy/src/test/resources/TestJarJar.groovy +++ /dev/null @@ -1,13 +0,0 @@ -package org.exoplatform.script.groovy.test - -import a.ImportedClass - -public class TestJarJar { - - def ImportedClass field = new ImportedClass(); - - // Object in constructor must be in container - public TestInjection() { - } - -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/resources/TestSimpleXMLGenerator.groovy b/exo.core.component.script.groovy/src/test/resources/TestSimpleXMLGenerator.groovy deleted file mode 100644 index f67580737..000000000 --- a/exo.core.component.script.groovy/src/test/resources/TestSimpleXMLGenerator.groovy +++ /dev/null @@ -1,18 +0,0 @@ -package org.exoplatform.script.groovy.test - -import groovy.xml.MarkupBuilder -import org.exoplatform.services.script.groovy.Book -public class SimpleXMLGenerator { - - public void generateXML (Book b) { - def xmlBuilder = new MarkupBuilder() - xmlBuilder.books() { - book() { - title(b.getTitle()) - author(b.getAuthor()) - price(b.getPrice()) - ISDN(b.getIsdn()) - } - } - } -} \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/resources/conf/standalone/test-configuration.xml b/exo.core.component.script.groovy/src/test/resources/conf/standalone/test-configuration.xml deleted file mode 100644 index d00316657..000000000 --- a/exo.core.component.script.groovy/src/test/resources/conf/standalone/test-configuration.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - org.exoplatform.services.log.LogConfigurationInitializer - org.exoplatform.services.log.LogConfigurationInitializer - - - logger - org.exoplatform.services.log.impl.BufferedLog4JLogger - - - configurator - org.exoplatform.services.log.impl.SimpleExoLogConfigurator - - - - - - org.exoplatform.services.script.groovy.SampleComponent - - - - org.exoplatform.services.script.groovy.GroovyScriptInstantiator - - - - JarJarGroovyScriptInstantiator - org.exoplatform.services.script.groovy.GroovyScriptInstantiator - - - jarjar.mapping - addPlugin - org.exoplatform.services.script.groovy.GroovyScriptJarJarPlugin - - - mapping - a->b - - - - - - - diff --git a/exo.core.component.script.groovy/src/test/resources/jarjar/classlitteral1.groovy b/exo.core.component.script.groovy/src/test/resources/jarjar/classlitteral1.groovy deleted file mode 100644 index c5befe9c4..000000000 --- a/exo.core.component.script.groovy/src/test/resources/jarjar/classlitteral1.groovy +++ /dev/null @@ -1,2 +0,0 @@ -def value = a.ClassLitteral.class.getValue(); -return value; \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/resources/jarjar/classlitteral2.groovy b/exo.core.component.script.groovy/src/test/resources/jarjar/classlitteral2.groovy deleted file mode 100644 index 06d1cbeac..000000000 --- a/exo.core.component.script.groovy/src/test/resources/jarjar/classlitteral2.groovy +++ /dev/null @@ -1,2 +0,0 @@ -def value = prefix1.a.ClassLitteral.class.getValue(); -return value; \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/resources/jarjar/classlitteral_1.groovy b/exo.core.component.script.groovy/src/test/resources/jarjar/classlitteral_1.groovy deleted file mode 100644 index 2d2e8321a..000000000 --- a/exo.core.component.script.groovy/src/test/resources/jarjar/classlitteral_1.groovy +++ /dev/null @@ -1,2 +0,0 @@ -def value = a.ClassLitteral.getValue(); -return value; \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/resources/jarjar/classlitteral_2.groovy b/exo.core.component.script.groovy/src/test/resources/jarjar/classlitteral_2.groovy deleted file mode 100644 index 66d982a16..000000000 --- a/exo.core.component.script.groovy/src/test/resources/jarjar/classlitteral_2.groovy +++ /dev/null @@ -1,2 +0,0 @@ -def value = prefix1.a.ClassLitteral.getValue(); -return value; \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/resources/jarjar/import1.groovy b/exo.core.component.script.groovy/src/test/resources/jarjar/import1.groovy deleted file mode 100644 index 741ac8e7a..000000000 --- a/exo.core.component.script.groovy/src/test/resources/jarjar/import1.groovy +++ /dev/null @@ -1,3 +0,0 @@ -import a.ImportedClass; -def value = new ImportedClass().getValue(); -return value; \ No newline at end of file diff --git a/exo.core.component.script.groovy/src/test/resources/jarjar/import2.groovy b/exo.core.component.script.groovy/src/test/resources/jarjar/import2.groovy deleted file mode 100644 index 7d1b72f0d..000000000 --- a/exo.core.component.script.groovy/src/test/resources/jarjar/import2.groovy +++ /dev/null @@ -1,3 +0,0 @@ -import prefix1.a.ImportedClass; -def value = new ImportedClass().getValue(); -return value; \ No newline at end of file diff --git a/exo.core.component.xml-processing/pom.xml b/exo.core.component.xml-processing/pom.xml deleted file mode 100644 index 24165fd01..000000000 --- a/exo.core.component.xml-processing/pom.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - - - 4.0.0 - - io.meeds.core - core-parent - 7.0.x-exo-SNAPSHOT - - exo.core.component.xml-processing - Meeds:: PLF Core :: Component :: XML Processing Service - Implementation of XML Processing Service of Exoplatform SAS 'eXo Core' project. - - 0.25 - - - - io.meeds.kernel - exo.kernel.container - - - io.meeds.kernel - exo.kernel.commons.test - test - - - - - - src/main/java - - **/*.properties - **/*.xml - **/*.xsl - **/*.ent - **/*.dtd - **/*.xsd - - - - src/main/resources - - **/*.properties - **/*.xml - **/*.xsl - **/*.ent - **/*.dtd - **/*.xsd - - - - - - src/test/resources - - **/*.properties - **/*.xml - **/*.xhtml - **/*.html - **/*.xsl - - - - src/test/java - - **/*.properties - **/*.xml - **/*.xhtml - **/*.html - **/*.xsl - - - - - - maven-antrun-plugin - - - prepare-test-policy - process-test-resources - - - Creating Access Policy for tests - - - - - - - - - - - - - - - - - run - - - - - - - diff --git a/exo.core.component.xml-processing/readme.txt b/exo.core.component.xml-processing/readme.txt deleted file mode 100644 index 5ac77dced..000000000 --- a/exo.core.component.xml-processing/readme.txt +++ /dev/null @@ -1,22 +0,0 @@ -@version $Id: readme.txt 5799 2006-05-28 17:55:42Z geaz $ - -Services notes. -=============== - -exo.services.xml.resolving.impl.xmlcommons.XmlCommonsResolvingServiceImpl -------------------------------------------------------------------------- -Based on catalogs - see catalog/CatalogManager.properties -> catalogs property -Example of catalog - exo-catalog.xml - OASIS XML format. -NOTE: this service can use filesystem file ONLY as catalog. - -exo.services.xml.resolving.impl.simple.SimpleResolvingServiceImpl ------------------------------------------------------------------ -Currently used for internal eXo XML-resolving tasks as use directory (/dtd) -inside jar as local dtds source. -To add new dtd just copy it to this dir and rebuild service jar. -In code: -service.setDtdName(dtdName); // - dtdName - dtd file name -EntityResolver resolver = service.getEntityResolver(); - -NOTE: In both services - if creation of EntityResolver failed - parser will -try to use systemId for Data Type Description. \ No newline at end of file diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/XMLResolvingService.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/XMLResolvingService.java deleted file mode 100644 index 808101ee2..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/XMLResolvingService.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.resolving; - -import org.xml.sax.EntityResolver; - -/** - * Created by The eXo Platform SAS . XML resolving service - an abstract - * EntityResolver creator. - * - * @author Gennady Azarenkov - * @version $Id: XMLResolvingService.java 5799 2006-05-28 17:55:42Z geaz $ - */ - -public interface XMLResolvingService -{ - /** - * Returns a pre-created EntityResolver - * - * @return EntityResolver object - */ - EntityResolver getEntityResolver(); - -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/impl/AddXMLResolvingContextPlugin.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/impl/AddXMLResolvingContextPlugin.java deleted file mode 100644 index cfb687544..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/impl/AddXMLResolvingContextPlugin.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.resolving.impl; - -import org.exoplatform.container.component.BaseComponentPlugin; -import org.exoplatform.container.xml.InitParams; -import org.exoplatform.container.xml.PropertiesParam; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -/** - * @author Andrey Parfonov - * @version $Id: $ - */ -public class AddXMLResolvingContextPlugin extends BaseComponentPlugin -{ - - private Map publicIDs_ = new HashMap(); - - private Map systemIDs_ = new HashMap(); - - public AddXMLResolvingContextPlugin(InitParams params) - { - if (params != null) - { - Iterator iterator = params.getPropertiesParamIterator(); - while (iterator.hasNext()) - { - PropertiesParam propertiesParam = iterator.next(); - String uri = propertiesParam.getProperty("uri"); - String publicId = propertiesParam.getProperty("publicId"); - String systemId = propertiesParam.getProperty("systemId"); - if (publicId != null && uri != null) - publicIDs_.put(publicId, uri); - if (systemId != null && uri != null) - systemIDs_.put(systemId, uri); - } - } - } - - public Map getPublicIDsResolvingtable() - { - return publicIDs_; - } - - public Map getSystemIDsResolvingtable() - { - return systemIDs_; - } - -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/impl/XMLResolver.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/impl/XMLResolver.java deleted file mode 100644 index d484d1e73..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/impl/XMLResolver.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.resolving.impl; - -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import java.io.IOException; -import java.util.Map; - -/** - * @author Andrey Parfonov - * @version $Id: $ - */ -public class XMLResolver implements EntityResolver -{ - - private Map publicIDs_; - - private Map systemIDs_; - - /** - * Is publicID prefer. - */ - private boolean publicIDPrefer_ = false; - - public XMLResolver(Map publicIDs, Map systemIDs) - { - publicIDs_ = publicIDs; - systemIDs_ = systemIDs; - } - - /* - * (non-Javadoc) - * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, - * java.lang.String) - */ - public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException - { - String entity = null; - // if publicId is prefer first check publicIDs table - if (publicIDPrefer_ && publicId != null && publicId.length() != 0) - entity = publicIDs_.get(publicId); - // if publicId is not prefer - if (entity == null && systemId != null && systemId.length() != 0) - entity = systemIDs_.get(systemId); - // if entity still null try get it from publicIDs table - if (entity == null && publicId != null && publicId.length() != 0) - entity = publicIDs_.get(publicId); - if (entity != null) - { - if (this.getClass().getResource(entity) != null) - { - InputSource src = new InputSource(Thread.currentThread().getContextClassLoader().getResourceAsStream(entity)); - src.setSystemId(Thread.currentThread().getContextClassLoader().getResource(entity).getPath()); - return src; - } - } - return null; - } - - public boolean isPublicIDPrefer() - { - return publicIDPrefer_; - } - - public void setPublicIDPrefer(boolean publicPrefer) - { - publicIDPrefer_ = publicPrefer; - } - -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/impl/XMLResolvingServiceImpl.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/impl/XMLResolvingServiceImpl.java deleted file mode 100644 index 7a45bde3f..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/impl/XMLResolvingServiceImpl.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.resolving.impl; - -import org.exoplatform.container.component.ComponentPlugin; -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; -import org.exoplatform.services.xml.resolving.XMLResolvingService; -import org.xml.sax.EntityResolver; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * @author Andrey Parfonov - * @version $Id: $ - */ -public class XMLResolvingServiceImpl implements XMLResolvingService -{ - - private static final Log LOG = ExoLogger.getLogger("exo.core.component.xml-processing.XMLResolvingServiceImpl"); - - private Map publicIDs_ = new HashMap(); - - private Map systemIDs_ = new HashMap(); - - public XMLResolvingServiceImpl() - { - } - - public EntityResolver getEntityResolver() - { - return new XMLResolver(publicIDs_, systemIDs_); - } - - private void addEntityPublicID(String publicId, String uri) - { - if (publicIDs_.get(publicId) != null) - throw new IllegalArgumentException("Entity whith publicId " + publicId + " already exists."); - publicIDs_.put(publicId, uri); - LOG.info("New entries to ResolvingService added (public) : " + publicId + " : " + uri); - } - - private void addEntitySystemID(String systemId, String uri) - { - if (systemIDs_.get(systemId) != null) - throw new IllegalArgumentException("Entity whith systemId " + systemId + " already exists."); - systemIDs_.put(systemId, uri); - LOG.info("New entries to ResolvingService added (system) : " + systemId + " : " + uri); - } - - public void addPlugin(ComponentPlugin plugin) - { - if (plugin instanceof AddXMLResolvingContextPlugin) - { - AddXMLResolvingContextPlugin resolvingContextPlugin = (AddXMLResolvingContextPlugin)plugin; - Map t = resolvingContextPlugin.getPublicIDsResolvingtable(); - Set keys = t.keySet(); - for (String key : keys) - { - addEntityPublicID(key, t.get(key)); - } - t = resolvingContextPlugin.getSystemIDsResolvingtable(); - keys = t.keySet(); - for (String key : keys) - { - addEntitySystemID(key, t.get(key)); - } - } - } - -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/impl/package.html b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/impl/package.html deleted file mode 100644 index 334790104..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/impl/package.html +++ /dev/null @@ -1,13 +0,0 @@ - - -XML Resolving Service - - -/***************************************************************************
- * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
- * Please look at license.txt in info directory for more license detail. *
- ***************************************************************************/
-
-XML Resolving Service for The eXo Platform SARL - - diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/package.html b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/package.html deleted file mode 100644 index 334790104..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/resolving/package.html +++ /dev/null @@ -1,13 +0,0 @@ - - -XML Resolving Service - - -/***************************************************************************
- * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
- * Please look at license.txt in info directory for more license detail. *
- ***************************************************************************/
-
-XML Resolving Service for The eXo Platform SARL - - diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/AbstractTransformer.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/AbstractTransformer.java deleted file mode 100644 index 5dca7eadd..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/AbstractTransformer.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.TransformerException; - -/** - * Created by The eXo Platform SAS . - * - * @author Gennady Azarenkov - * @author Alexander Kravchuk - * @version $Id: AbstractTransformer.java 5799 2006-05-28 17:55:42Z geaz $ - */ - -public interface AbstractTransformer -{ - /** - * Initialize a result of transformation - * - * @param result Result - * @throws NotSupportedIOTypeException if try to initialize with not supported - * implementation of Result - */ - void initResult(Result result) throws NotSupportedIOTypeException; - - /** - * Transform source data to result - * - * @param source Source - input of transformation - * @throws NotSupportedIOTypeException if not supported implementation of - * Source - * @throws TransformerException if error occurred on transformation process - * @throws IllegalStateException if result not initialized by initResult - */ - void transform(Source source) throws NotSupportedIOTypeException, TransformerException, IllegalStateException; -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/EncodingMap.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/EncodingMap.java deleted file mode 100644 index 301948ddc..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/EncodingMap.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform; - -import org.exoplatform.container.spi.DefinitionByType; -import org.exoplatform.services.xml.transform.impl.EncodingMapImpl; - -/** - * Created by The eXo Platform SAS . Conversions between IANA encoding names and - * Java encoding names, - * - * @author Alexander Kravchuk - * @version $Id: - */ -@DefinitionByType(type = EncodingMapImpl.class) -public interface EncodingMap -{ - public String convertIANA2Java(String iana); - - public String convertJava2IANA(String java); -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/NotSupportedIOTypeException.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/NotSupportedIOTypeException.java deleted file mode 100644 index e29711f49..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/NotSupportedIOTypeException.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; - -/** - * Created by The eXo Platform SAS . - * - * @author Gennady Azarenkov - * @version $Id: NotSupportedIOTypeException.java 5799 2006-05-28 17:55:42Z geaz - * $ - */ - -public class NotSupportedIOTypeException extends Exception -{ - - /** Constructs an Exception without a message. */ - public NotSupportedIOTypeException() - { - super(); - } - - /** Constructs an Exception with a message. */ - public NotSupportedIOTypeException(Result result) - { - super("Result type " + result.getClass().getName() + " is not supported by this transformer."); - } - - /** Constructs an Exception with a message. */ - public NotSupportedIOTypeException(Source source) - { - super("Source type " + source.getClass().getName() + " is not supported by this transformer."); - } - - /** - * Constructs an Exception with a detailed message. - * - * @param message The message associated with the exception. - */ - public NotSupportedIOTypeException(String message) - { - super(message); - } -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/PipeTransformer.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/PipeTransformer.java deleted file mode 100644 index ff494b8c3..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/PipeTransformer.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform; - -import javax.xml.transform.Result; - -/** - * Created by The eXo Platform SAS . - * - * @author Alexander Kravchuk - * @version $Id: PipeTransformer.java 5799 2006-05-28 17:55:42Z geaz $ - */ - -public interface PipeTransformer extends AbstractTransformer -{ - Result getTransformerAsResult(); -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/EncodingMapImpl.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/EncodingMapImpl.java deleted file mode 100644 index 4fc22cdb9..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/EncodingMapImpl.java +++ /dev/null @@ -1,448 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform.impl; - -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; -import org.exoplatform.services.xml.transform.EncodingMap; - -import java.util.Hashtable; - -/** - * Created by The eXo Platform SAS . Conversions between IANA encoding names and - * Java encoding names, - * See http://java.sun.com/j2se/1.5.0/docs/guide/intl/encoding.doc.html - * - * @author Alexander Kravchuk - * @version $Id: - */ - -public class EncodingMapImpl implements EncodingMap -{ - private static final Log LOG = ExoLogger.getLogger("exo.core.component.xml-processing.EncodingMapImpl"); - - protected final static Hashtable IANA2JavaMap = new Hashtable(); - - protected final static Hashtable Java2IANAMap = new Hashtable(); - - public static void addIANA2JavaMapping(String iana, String java) - { - IANA2JavaMap.put(iana, java); - if (Java2IANAMap.get(java) == null) - { - Java2IANAMap.put(java, iana); - } - } - - public static void removeIANA2JavaMapping(String iana, String java) - { - IANA2JavaMap.remove(iana); - Java2IANAMap.remove(java); - } - - public static void IANA2JavaMapping(String iana, String java) - { - IANA2JavaMap.put(iana, java); - Java2IANAMap.put(java, iana); - } - - public String convertIANA2Java(String iana) - { - return IANA2JavaMap.get(iana); - } - - public String convertJava2IANA(String java) - { - LOG.debug("convert [" + java + "] to iana coding [" + Java2IANAMap.get(java) + "]"); - return Java2IANAMap.get(java); - } - - static - { - addIANA2JavaMapping("BIG5", "Big5"); - addIANA2JavaMapping("CSBIG5", "Big5"); - addIANA2JavaMapping("CP037", "CP037"); - addIANA2JavaMapping("IBM037", "CP037"); - addIANA2JavaMapping("CSIBM037", "CP037"); - addIANA2JavaMapping("EBCDIC-CP-US", "CP037"); - addIANA2JavaMapping("EBCDIC-CP-CA", "CP037"); - addIANA2JavaMapping("EBCDIC-CP-NL", "CP037"); - addIANA2JavaMapping("EBCDIC-CP-WT", "CP037"); - addIANA2JavaMapping("IBM273", "CP273"); - addIANA2JavaMapping("CP273", "CP273"); - addIANA2JavaMapping("CSIBM273", "CP273"); - addIANA2JavaMapping("IBM277", "CP277"); - addIANA2JavaMapping("CP277", "CP277"); - addIANA2JavaMapping("CSIBM277", "CP277"); - addIANA2JavaMapping("EBCDIC-CP-DK", "CP277"); - addIANA2JavaMapping("EBCDIC-CP-NO", "CP277"); - addIANA2JavaMapping("IBM278", "CP278"); - addIANA2JavaMapping("CP278", "CP278"); - addIANA2JavaMapping("CSIBM278", "CP278"); - addIANA2JavaMapping("EBCDIC-CP-FI", "CP278"); - addIANA2JavaMapping("EBCDIC-CP-SE", "CP278"); - addIANA2JavaMapping("IBM280", "CP280"); - addIANA2JavaMapping("CP280", "CP280"); - addIANA2JavaMapping("CSIBM280", "CP280"); - addIANA2JavaMapping("EBCDIC-CP-IT", "CP280"); - addIANA2JavaMapping("IBM284", "CP284"); - addIANA2JavaMapping("CP284", "CP284"); - addIANA2JavaMapping("CSIBM284", "CP284"); - addIANA2JavaMapping("EBCDIC-CP-ES", "CP284"); - addIANA2JavaMapping("EBCDIC-CP-GB", "CP285"); - addIANA2JavaMapping("IBM285", "CP285"); - addIANA2JavaMapping("CP285", "CP285"); - addIANA2JavaMapping("CSIBM285", "CP285"); - addIANA2JavaMapping("EBCDIC-JP-KANA", "CP290"); - addIANA2JavaMapping("IBM290", "CP290"); - addIANA2JavaMapping("CP290", "CP290"); - addIANA2JavaMapping("CSIBM290", "CP290"); - addIANA2JavaMapping("EBCDIC-CP-FR", "CP297"); - addIANA2JavaMapping("IBM297", "CP297"); - addIANA2JavaMapping("CP297", "CP297"); - addIANA2JavaMapping("CSIBM297", "CP297"); - addIANA2JavaMapping("EBCDIC-CP-AR1", "CP420"); - addIANA2JavaMapping("IBM420", "CP420"); - addIANA2JavaMapping("CP420", "CP420"); - addIANA2JavaMapping("CSIBM420", "CP420"); - addIANA2JavaMapping("EBCDIC-CP-HE", "CP424"); - addIANA2JavaMapping("IBM424", "CP424"); - addIANA2JavaMapping("CP424", "CP424"); - addIANA2JavaMapping("CSIBM424", "CP424"); - addIANA2JavaMapping("IBM437", "CP437"); - addIANA2JavaMapping("437", "CP437"); - addIANA2JavaMapping("CP437", "CP437"); - addIANA2JavaMapping("CSPC8CODEPAGE437", "CP437"); - addIANA2JavaMapping("EBCDIC-CP-CH", "CP500"); - addIANA2JavaMapping("IBM500", "CP500"); - addIANA2JavaMapping("CP500", "CP500"); - addIANA2JavaMapping("CSIBM500", "CP500"); - addIANA2JavaMapping("EBCDIC-CP-CH", "CP500"); - addIANA2JavaMapping("EBCDIC-CP-BE", "CP500"); - addIANA2JavaMapping("IBM775", "CP775"); - addIANA2JavaMapping("CP775", "CP775"); - addIANA2JavaMapping("CSPC775BALTIC", "CP775"); - addIANA2JavaMapping("IBM850", "CP850"); - addIANA2JavaMapping("850", "CP850"); - addIANA2JavaMapping("CP850", "CP850"); - addIANA2JavaMapping("CSPC850MULTILINGUAL", "CP850"); - addIANA2JavaMapping("IBM852", "CP852"); - addIANA2JavaMapping("852", "CP852"); - addIANA2JavaMapping("CP852", "CP852"); - addIANA2JavaMapping("CSPCP852", "CP852"); - addIANA2JavaMapping("IBM855", "CP855"); - addIANA2JavaMapping("855", "CP855"); - addIANA2JavaMapping("CP855", "CP855"); - addIANA2JavaMapping("CSIBM855", "CP855"); - addIANA2JavaMapping("IBM857", "CP857"); - addIANA2JavaMapping("857", "CP857"); - addIANA2JavaMapping("CP857", "CP857"); - addIANA2JavaMapping("CSIBM857", "CP857"); - addIANA2JavaMapping("IBM00858", "CP858"); - addIANA2JavaMapping("CP00858", "CP858"); - addIANA2JavaMapping("CCSID00858", "CP858"); - addIANA2JavaMapping("IBM860", "CP860"); - addIANA2JavaMapping("860", "CP860"); - addIANA2JavaMapping("CP860", "CP860"); - addIANA2JavaMapping("CSIBM860", "CP860"); - addIANA2JavaMapping("IBM861", "CP861"); - addIANA2JavaMapping("861", "CP861"); - addIANA2JavaMapping("CP861", "CP861"); - addIANA2JavaMapping("CP-IS", "CP861"); - addIANA2JavaMapping("CSIBM861", "CP861"); - addIANA2JavaMapping("IBM862", "CP862"); - addIANA2JavaMapping("862", "CP862"); - addIANA2JavaMapping("CP862", "CP862"); - addIANA2JavaMapping("CSPC862LATINHEBREW", "CP862"); - addIANA2JavaMapping("IBM863", "CP863"); - addIANA2JavaMapping("863", "CP863"); - addIANA2JavaMapping("CP863", "CP863"); - addIANA2JavaMapping("CSIBM863", "CP863"); - addIANA2JavaMapping("IBM864", "CP864"); - addIANA2JavaMapping("CP864", "CP864"); - addIANA2JavaMapping("CSIBM864", "CP864"); - addIANA2JavaMapping("IBM865", "CP865"); - addIANA2JavaMapping("865", "CP865"); - addIANA2JavaMapping("CP865", "CP865"); - addIANA2JavaMapping("CSIBM865", "CP865"); - addIANA2JavaMapping("IBM866", "CP866"); - addIANA2JavaMapping("866", "CP866"); - addIANA2JavaMapping("CP866", "CP866"); - addIANA2JavaMapping("CSIBM866", "CP866"); - addIANA2JavaMapping("IBM868", "CP868"); - addIANA2JavaMapping("CP868", "CP868"); - addIANA2JavaMapping("CSIBM868", "CP868"); - addIANA2JavaMapping("CP-AR", "CP868"); - addIANA2JavaMapping("IBM869", "CP869"); - addIANA2JavaMapping("CP869", "CP869"); - addIANA2JavaMapping("CSIBM869", "CP869"); - addIANA2JavaMapping("CP-GR", "CP869"); - addIANA2JavaMapping("IBM870", "CP870"); - addIANA2JavaMapping("CP870", "CP870"); - addIANA2JavaMapping("CSIBM870", "CP870"); - addIANA2JavaMapping("EBCDIC-CP-ROECE", "CP870"); - addIANA2JavaMapping("EBCDIC-CP-YU", "CP870"); - addIANA2JavaMapping("IBM871", "CP871"); - addIANA2JavaMapping("CP871", "CP871"); - addIANA2JavaMapping("CSIBM871", "CP871"); - addIANA2JavaMapping("EBCDIC-CP-IS", "CP871"); - addIANA2JavaMapping("IBM918", "CP918"); - addIANA2JavaMapping("CP918", "CP918"); - addIANA2JavaMapping("CSIBM918", "CP918"); - addIANA2JavaMapping("EBCDIC-CP-AR2", "CP918"); - addIANA2JavaMapping("IBM00924", "CP924"); - addIANA2JavaMapping("CP00924", "CP924"); - addIANA2JavaMapping("CCSID00924", "CP924"); - // is this an error??? - addIANA2JavaMapping("EBCDIC-LATIN9--EURO", "CP924"); - addIANA2JavaMapping("IBM1026", "CP1026"); - addIANA2JavaMapping("CP1026", "CP1026"); - addIANA2JavaMapping("CSIBM1026", "CP1026"); - addIANA2JavaMapping("IBM01140", "Cp1140"); - addIANA2JavaMapping("CP01140", "Cp1140"); - addIANA2JavaMapping("CCSID01140", "Cp1140"); - addIANA2JavaMapping("IBM01141", "Cp1141"); - addIANA2JavaMapping("CP01141", "Cp1141"); - addIANA2JavaMapping("CCSID01141", "Cp1141"); - addIANA2JavaMapping("IBM01142", "Cp1142"); - addIANA2JavaMapping("CP01142", "Cp1142"); - addIANA2JavaMapping("CCSID01142", "Cp1142"); - addIANA2JavaMapping("IBM01143", "Cp1143"); - addIANA2JavaMapping("CP01143", "Cp1143"); - addIANA2JavaMapping("CCSID01143", "Cp1143"); - addIANA2JavaMapping("IBM01144", "Cp1144"); - addIANA2JavaMapping("CP01144", "Cp1144"); - addIANA2JavaMapping("CCSID01144", "Cp1144"); - addIANA2JavaMapping("IBM01145", "Cp1145"); - addIANA2JavaMapping("CP01145", "Cp1145"); - addIANA2JavaMapping("CCSID01145", "Cp1145"); - addIANA2JavaMapping("IBM01146", "Cp1146"); - addIANA2JavaMapping("CP01146", "Cp1146"); - addIANA2JavaMapping("CCSID01146", "Cp1146"); - addIANA2JavaMapping("IBM01147", "Cp1147"); - addIANA2JavaMapping("CP01147", "Cp1147"); - addIANA2JavaMapping("CCSID01147", "Cp1147"); - addIANA2JavaMapping("IBM01148", "Cp1148"); - addIANA2JavaMapping("CP01148", "Cp1148"); - addIANA2JavaMapping("CCSID01148", "Cp1148"); - addIANA2JavaMapping("IBM01149", "Cp1149"); - addIANA2JavaMapping("CP01149", "Cp1149"); - addIANA2JavaMapping("CCSID01149", "Cp1149"); - addIANA2JavaMapping("EUC-JP", "EUCJIS"); - addIANA2JavaMapping("CSEUCPKDFMTJAPANESE", "EUCJIS"); - addIANA2JavaMapping("EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", "EUCJIS"); - addIANA2JavaMapping("EUC-KR", "KSC5601"); - addIANA2JavaMapping("CSEUCKR", "KSC5601"); - addIANA2JavaMapping("KS_C_5601-1987", "KS_C_5601-1987"); - addIANA2JavaMapping("ISO-IR-149", "KS_C_5601-1987"); - addIANA2JavaMapping("KS_C_5601-1989", "KS_C_5601-1987"); - addIANA2JavaMapping("KSC_5601", "KS_C_5601-1987"); - addIANA2JavaMapping("KOREAN", "KS_C_5601-1987"); - addIANA2JavaMapping("CSKSC56011987", "KS_C_5601-1987"); - addIANA2JavaMapping("GB2312", "GB2312"); - addIANA2JavaMapping("CSGB2312", "GB2312"); - addIANA2JavaMapping("ISO-2022-JP", "JIS"); - addIANA2JavaMapping("CSISO2022JP", "JIS"); - addIANA2JavaMapping("ISO-2022-KR", "ISO2022KR"); - addIANA2JavaMapping("CSISO2022KR", "ISO2022KR"); - addIANA2JavaMapping("ISO-2022-CN", "ISO2022CN"); - - addIANA2JavaMapping("X0201", "JIS0201"); - addIANA2JavaMapping("CSISO13JISC6220JP", "JIS0201"); - addIANA2JavaMapping("X0208", "JIS0208"); - addIANA2JavaMapping("ISO-IR-87", "JIS0208"); - addIANA2JavaMapping("X0208dbiJIS_X0208-1983", "JIS0208"); - addIANA2JavaMapping("CSISO87JISX0208", "JIS0208"); - addIANA2JavaMapping("X0212", "JIS0212"); - addIANA2JavaMapping("ISO-IR-159", "JIS0212"); - addIANA2JavaMapping("CSISO159JISX02121990", "JIS0212"); - addIANA2JavaMapping("GB18030", "GB18030"); - addIANA2JavaMapping("GBK", "GBK"); - addIANA2JavaMapping("CP936", "GBK"); - addIANA2JavaMapping("MS936", "GBK"); - addIANA2JavaMapping("WINDOWS-936", "GBK"); - addIANA2JavaMapping("SHIFT_JIS", "SJIS"); - addIANA2JavaMapping("CSSHIFTJIS", "SJIS"); - addIANA2JavaMapping("MS_KANJI", "SJIS"); - addIANA2JavaMapping("WINDOWS-31J", "MS932"); - addIANA2JavaMapping("CSWINDOWS31J", "MS932"); - - // Add support for Cp1252 and its friends - addIANA2JavaMapping("WINDOWS-1250", "Cp1250"); - addIANA2JavaMapping("WINDOWS-1251", "Cp1251"); - addIANA2JavaMapping("WINDOWS-1252", "Cp1252"); - addIANA2JavaMapping("WINDOWS-1253", "Cp1253"); - addIANA2JavaMapping("WINDOWS-1254", "Cp1254"); - addIANA2JavaMapping("WINDOWS-1255", "Cp1255"); - addIANA2JavaMapping("WINDOWS-1256", "Cp1256"); - addIANA2JavaMapping("WINDOWS-1257", "Cp1257"); - addIANA2JavaMapping("WINDOWS-1258", "Cp1258"); - addIANA2JavaMapping("TIS-620", "TIS620"); - - addIANA2JavaMapping("ISO-8859-1", "ISO8859_1"); - addIANA2JavaMapping("ISO-IR-100", "ISO8859_1"); - addIANA2JavaMapping("ISO_8859-1", "ISO8859_1"); - addIANA2JavaMapping("LATIN1", "ISO8859_1"); - addIANA2JavaMapping("CSISOLATIN1", "ISO8859_1"); - addIANA2JavaMapping("L1", "ISO8859_1"); - addIANA2JavaMapping("IBM819", "ISO8859_1"); - addIANA2JavaMapping("CP819", "ISO8859_1"); - - addIANA2JavaMapping("ISO-8859-2", "ISO8859_2"); - addIANA2JavaMapping("ISO-IR-101", "ISO8859_2"); - addIANA2JavaMapping("ISO_8859-2", "ISO8859_2"); - addIANA2JavaMapping("LATIN2", "ISO8859_2"); - addIANA2JavaMapping("CSISOLATIN2", "ISO8859_2"); - addIANA2JavaMapping("L2", "ISO8859_2"); - - addIANA2JavaMapping("ISO-8859-3", "ISO8859_3"); - addIANA2JavaMapping("ISO-IR-109", "ISO8859_3"); - addIANA2JavaMapping("ISO_8859-3", "ISO8859_3"); - addIANA2JavaMapping("LATIN3", "ISO8859_3"); - addIANA2JavaMapping("CSISOLATIN3", "ISO8859_3"); - addIANA2JavaMapping("L3", "ISO8859_3"); - - addIANA2JavaMapping("ISO-8859-4", "ISO8859_4"); - addIANA2JavaMapping("ISO-IR-110", "ISO8859_4"); - addIANA2JavaMapping("ISO_8859-4", "ISO8859_4"); - addIANA2JavaMapping("LATIN4", "ISO8859_4"); - addIANA2JavaMapping("CSISOLATIN4", "ISO8859_4"); - addIANA2JavaMapping("L4", "ISO8859_4"); - - addIANA2JavaMapping("ISO-8859-5", "ISO8859_5"); - addIANA2JavaMapping("ISO-IR-144", "ISO8859_5"); - addIANA2JavaMapping("ISO_8859-5", "ISO8859_5"); - addIANA2JavaMapping("CYRILLIC", "ISO8859_5"); - addIANA2JavaMapping("CSISOLATINCYRILLIC", "ISO8859_5"); - - addIANA2JavaMapping("ISO-8859-6", "ISO8859_6"); - addIANA2JavaMapping("ISO-IR-127", "ISO8859_6"); - addIANA2JavaMapping("ISO_8859-6", "ISO8859_6"); - addIANA2JavaMapping("ECMA-114", "ISO8859_6"); - addIANA2JavaMapping("ASMO-708", "ISO8859_6"); - addIANA2JavaMapping("ARABIC", "ISO8859_6"); - addIANA2JavaMapping("CSISOLATINARABIC", "ISO8859_6"); - - addIANA2JavaMapping("ISO-8859-7", "ISO8859_7"); - addIANA2JavaMapping("ISO-IR-126", "ISO8859_7"); - addIANA2JavaMapping("ISO_8859-7", "ISO8859_7"); - addIANA2JavaMapping("ELOT_928", "ISO8859_7"); - addIANA2JavaMapping("ECMA-118", "ISO8859_7"); - addIANA2JavaMapping("GREEK", "ISO8859_7"); - addIANA2JavaMapping("CSISOLATINGREEK", "ISO8859_7"); - addIANA2JavaMapping("GREEK8", "ISO8859_7"); - - addIANA2JavaMapping("ISO-8859-8", "ISO8859_8"); - addIANA2JavaMapping("ISO-8859-8-I", "ISO8859_8"); // added since this - // encoding only differs - // w.r.t. presentation - addIANA2JavaMapping("ISO-IR-138", "ISO8859_8"); - addIANA2JavaMapping("ISO_8859-8", "ISO8859_8"); - addIANA2JavaMapping("HEBREW", "ISO8859_8"); - addIANA2JavaMapping("CSISOLATINHEBREW", "ISO8859_8"); - - addIANA2JavaMapping("ISO-8859-9", "ISO8859_9"); - addIANA2JavaMapping("ISO-IR-148", "ISO8859_9"); - addIANA2JavaMapping("ISO_8859-9", "ISO8859_9"); - addIANA2JavaMapping("LATIN5", "ISO8859_9"); - addIANA2JavaMapping("CSISOLATIN5", "ISO8859_9"); - addIANA2JavaMapping("L5", "ISO8859_9"); - - addIANA2JavaMapping("ISO-8859-13", "ISO8859_13"); - - addIANA2JavaMapping("ISO-8859-15", "ISO8859_15_FDIS"); - addIANA2JavaMapping("ISO_8859-15", "ISO8859_15_FDIS"); - addIANA2JavaMapping("LATIN-9", "ISO8859_15_FDIS"); - - addIANA2JavaMapping("KOI8-R", "KOI8_R"); - addIANA2JavaMapping("CSKOI8R", "KOI8_R"); - addIANA2JavaMapping("US-ASCII", "ASCII"); - addIANA2JavaMapping("ISO-IR-6", "ASCII"); - addIANA2JavaMapping("ANSI_X3.4-1968", "ASCII"); - addIANA2JavaMapping("ANSI_X3.4-1986", "ASCII"); - addIANA2JavaMapping("ISO_646.IRV:1991", "ASCII"); - addIANA2JavaMapping("ASCII", "ASCII"); - addIANA2JavaMapping("CSASCII", "ASCII"); - addIANA2JavaMapping("ISO646-US", "ASCII"); - addIANA2JavaMapping("US", "ASCII"); - addIANA2JavaMapping("IBM367", "ASCII"); - addIANA2JavaMapping("CP367", "ASCII"); - addIANA2JavaMapping("UTF-8", "UTF-8"); - addIANA2JavaMapping("UTF-16", "UTF-16"); - addIANA2JavaMapping("UTF-16BE", "UnicodeBig"); - addIANA2JavaMapping("UTF-16LE", "UnicodeLittle"); - - // support for 1047, as proposed to be added to the - // IANA registry in - // http://lists.w3.org/Archives/Public/ietf-charset/2002JulSep/0049.html - addIANA2JavaMapping("IBM-1047", "Cp1047"); - addIANA2JavaMapping("IBM1047", "Cp1047"); - addIANA2JavaMapping("CP1047", "Cp1047"); - - // Adding new aliases as proposed in - // http://lists.w3.org/Archives/Public/ietf-charset/2002JulSep/0058.html - addIANA2JavaMapping("IBM-37", "CP037"); - addIANA2JavaMapping("IBM-273", "CP273"); - addIANA2JavaMapping("IBM-277", "CP277"); - addIANA2JavaMapping("IBM-278", "CP278"); - addIANA2JavaMapping("IBM-280", "CP280"); - addIANA2JavaMapping("IBM-284", "CP284"); - addIANA2JavaMapping("IBM-285", "CP285"); - addIANA2JavaMapping("IBM-290", "CP290"); - addIANA2JavaMapping("IBM-297", "CP297"); - addIANA2JavaMapping("IBM-420", "CP420"); - addIANA2JavaMapping("IBM-424", "CP424"); - addIANA2JavaMapping("IBM-437", "CP437"); - addIANA2JavaMapping("IBM-500", "CP500"); - addIANA2JavaMapping("IBM-775", "CP775"); - addIANA2JavaMapping("IBM-850", "CP850"); - addIANA2JavaMapping("IBM-852", "CP852"); - addIANA2JavaMapping("IBM-855", "CP855"); - addIANA2JavaMapping("IBM-857", "CP857"); - addIANA2JavaMapping("IBM-858", "CP858"); - addIANA2JavaMapping("IBM-860", "CP860"); - addIANA2JavaMapping("IBM-861", "CP861"); - addIANA2JavaMapping("IBM-862", "CP862"); - addIANA2JavaMapping("IBM-863", "CP863"); - addIANA2JavaMapping("IBM-864", "CP864"); - addIANA2JavaMapping("IBM-865", "CP865"); - addIANA2JavaMapping("IBM-866", "CP866"); - addIANA2JavaMapping("IBM-868", "CP868"); - addIANA2JavaMapping("IBM-869", "CP869"); - addIANA2JavaMapping("IBM-870", "CP870"); - addIANA2JavaMapping("IBM-871", "CP871"); - addIANA2JavaMapping("IBM-918", "CP918"); - addIANA2JavaMapping("IBM-924", "CP924"); - addIANA2JavaMapping("IBM-1026", "CP1026"); - addIANA2JavaMapping("IBM-1140", "Cp1140"); - addIANA2JavaMapping("IBM-1141", "Cp1141"); - addIANA2JavaMapping("IBM-1142", "Cp1142"); - addIANA2JavaMapping("IBM-1143", "Cp1143"); - addIANA2JavaMapping("IBM-1144", "Cp1144"); - addIANA2JavaMapping("IBM-1145", "Cp1145"); - addIANA2JavaMapping("IBM-1146", "Cp1146"); - addIANA2JavaMapping("IBM-1147", "Cp1147"); - addIANA2JavaMapping("IBM-1148", "Cp1148"); - addIANA2JavaMapping("IBM-1149", "Cp1149"); - addIANA2JavaMapping("IBM-819", "ISO8859_1"); - addIANA2JavaMapping("IBM-367", "ASCII"); - // https://jira.jboss.org/jira/browse/EXOJCR-588 - addIANA2JavaMapping("x-MacRoman", "MacRoman"); - } -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/TransformerBase.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/TransformerBase.java deleted file mode 100644 index 6434bf80d..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/TransformerBase.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform.impl; - -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; -import org.exoplatform.services.xml.resolving.XMLResolvingService; -import org.exoplatform.services.xml.transform.AbstractTransformer; -import org.exoplatform.services.xml.transform.NotSupportedIOTypeException; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.security.PrivilegedExceptionAction; - -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.TransformerException; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.sax.TransformerHandler; -import javax.xml.transform.stream.StreamResult; - -/** - * Created by The eXo Platform SAS . - * - * @author Alexander Kravchuk - * @version $Id: TransformerBase.java 5799 2006-05-28 17:55:42Z geaz $ - */ -public abstract class TransformerBase implements AbstractTransformer -{ - private Result result = null; - - protected static final Log LOG = ExoLogger.getLogger("exo.core.component.xml-processing.TransformerBase"); - - protected SAXTransformerFactory tSAXFactory; - - protected XMLResolvingService resolvingService; - - public TransformerBase() - { - LOG.debug("Current javax.xml.parsers.SAXParserFactory sys property [ " - + System.getProperty("javax.xml.parsers.SAXParserFactory", "-Not set-") + "]"); - - tSAXFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); - } - - /** - * TODO change. Must no use explicit parser class name - */ - static public XMLReader getXMLReader() throws SAXException - { - return XMLReaderFactory.createXMLReader(); - } - - public void setResolvingService(XMLResolvingService r) - { - resolvingService = r; - } - - /** - * override when need some operation after initialization result in - * transformer - */ - protected void afterInitResult() - { - LOG.debug("Result is set"); - } - - final public void initResult(Result result) throws NotSupportedIOTypeException - { - if (!isResultSupported(result)) - { - throw new NotSupportedIOTypeException(result); - } - this.result = result; - afterInitResult(); - } - - protected Result getResult() - { - return this.result; - } - - protected boolean isSourceSupported(Source source) - { - return true; - } - - protected boolean isResultSupported(Result result) - { - return true; - } - - protected abstract void internalTransform(Source src) throws NotSupportedIOTypeException, TransformerException, - IllegalStateException; - - final public void transform(Source source) throws NotSupportedIOTypeException, TransformerException, - IllegalStateException - { - - if (!isSourceSupported(source)) - { - LOG.error("source of type " + source.getClass().getName() + " not supported"); - throw new NotSupportedIOTypeException(source); - } - - if (this.result == null) - { - LOG.error("Result not set"); - throw new IllegalStateException("Result not specified. See initResult(Result)"); - } - - internalTransform(source); - } - - /** - * Tranform InputStream to specified result, according to type of result - * - * @param input InputStream - * @param result Result - * @throws TransformerException - */ - - public void transformInputStream2Result(InputStream input, Result result) throws TransformerException - { - LOG.debug("Transform InputStream to result of type " + result.getClass().getName()); - - // StreamResult - write data from InputStream to OutputStream - if (result instanceof StreamResult) - { - OutputStream outputStream = ((StreamResult)result).getOutputStream(); - try - { - int counter = 0; - while (input.available() > 0) - { - byte[] byteArray = new byte[input.available()]; - int readBytes = input.read(byteArray); - counter += readBytes; - outputStream.write(byteArray, 0, readBytes); - } - LOG.debug("Write " + counter + " bytes to ouput stream"); - } - catch (IOException ex) - { - LOG.error("Error on read/write ", ex); - throw new TransformerException(ex); - } - } - // not StreamResult - else - { - XMLReader xmlReader = null; - try - { - xmlReader = getXMLReader(); - LOG.debug("xmlReader class is " + xmlReader.getClass().getName()); - - // set default resolver - if (resolvingService != null) - { - xmlReader.setEntityResolver(resolvingService.getEntityResolver()); - LOG.debug("Set entity resolver"); - } - - // SAXResult use XMLReader to parce InputStream to SAXEvents - if (result instanceof SAXResult) - { - SAXResult saxResult = (SAXResult)result; - xmlReader.setContentHandler(saxResult.getHandler()); - LOG.debug("Parse direct to result"); - } - - // not StreamResult, not SAXResult - create empty transformation - else - { - LOG.debug("Create empty transformation"); - TransformerHandler transformerHandler = tSAXFactory.newTransformerHandler(); - transformerHandler.setResult(result); - xmlReader.setContentHandler(transformerHandler); - LOG.debug("Parse to result throw empty transformer"); - } - xmlReader.parse(new InputSource(input)); - LOG.debug("Parse complete"); - } - catch (SAXException ex) - { - throw new TransformerException(ex); - } - catch (IOException ex) - { - throw new TransformerException(ex); - } - } - } - - /** - * Transform javax.xml.transform.Source to java.io.InputStream if can't - * transform throw exception - * - * @param source Source - * @return InputStream - * @throws NotSupportedIOTypeException - */ - protected InputStream sourceAsInputStream(Source source) throws NotSupportedIOTypeException - { - InputSource inputSource = SAXSource.sourceToInputSource(source); - if (inputSource == null) - { - throw new NotSupportedIOTypeException(source); - } - return inputSource.getByteStream(); - } - - /** - * TODO REMOVE!!!! For debug only!!! - * @deprecated see Warning - */ - protected void writeTofile(byte[] bytes, String postfix) - { - String POSTFIX = new java.text.SimpleDateFormat("yy-MM-DD_HH-mm-ss_").format(new java.util.Date()); - try - { - - java.io.FileOutputStream fileLog = - new java.io.FileOutputStream("c:/tmp/transf" + POSTFIX + postfix + ".xhtml"); - fileLog.write(bytes); - fileLog.flush(); - fileLog.close(); - - } - catch (java.io.FileNotFoundException ex) - { - if (LOG.isTraceEnabled()) - { - LOG.trace("An exception occurred: " + ex.getMessage()); - } - } - catch (IOException ex) - { - if (LOG.isTraceEnabled()) - { - LOG.trace("An exception occurred: " + ex.getMessage()); - } - } - } - -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTemplatesImpl.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTemplatesImpl.java deleted file mode 100644 index db6563327..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTemplatesImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform.impl.trax; - -import org.exoplatform.services.xml.resolving.XMLResolvingService; -import org.exoplatform.services.xml.transform.trax.TRAXTemplates; -import org.exoplatform.services.xml.transform.trax.TRAXTransformer; - -import java.util.Properties; - -import javax.xml.transform.Templates; -import javax.xml.transform.TransformerConfigurationException; - -/** - * Created by The eXo Platform SAS . Wrapper for Trax Transformer. - * - * @author Alexander Kravchuk - * @version $Id: TRAXTemplatesImpl.java 5799 2006-05-28 17:55:42Z geaz $ - */ - -public class TRAXTemplatesImpl implements TRAXTemplates -{ - private Templates templates; - - private XMLResolvingService resolvingService; - - public TRAXTemplatesImpl(Templates templates) - { - this.templates = templates; - } - - public Properties getOutputProperties() - { - return templates.getOutputProperties(); - } - - public TRAXTransformer newTransformer() throws TransformerConfigurationException - { - TRAXTransformerImpl transf = new TRAXTransformerImpl(this.templates); - transf.setResolvingService(resolvingService); - return transf; - } - - public void setResolvingService(XMLResolvingService r) - { - resolvingService = r; - } -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTemplatesLoaderPlugin.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTemplatesLoaderPlugin.java deleted file mode 100644 index 68a3b3424..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTemplatesLoaderPlugin.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform.impl.trax; - -import org.exoplatform.container.component.BaseComponentPlugin; -import org.exoplatform.container.xml.InitParams; -import org.exoplatform.container.xml.PropertiesParam; - -import java.util.HashMap; -import java.util.Map; - -/** - * @author Andrey Parfonov - * @version $Id: $ - */ -public class TRAXTemplatesLoaderPlugin extends BaseComponentPlugin -{ - - private Map templates_ = new HashMap(); - - public TRAXTemplatesLoaderPlugin(InitParams params) throws Exception - { - if (params != null) - { - PropertiesParam pparams = params.getPropertiesParam("xsl-source-urls"); - if (pparams != null) - templates_ = pparams.getProperties(); - } - } - - public Map getTRAXTemplates() - { - return templates_; - } - -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTemplatesServiceImpl.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTemplatesServiceImpl.java deleted file mode 100644 index 9dfa88f4b..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTemplatesServiceImpl.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform.impl.trax; - -import org.exoplatform.container.component.ComponentPlugin; -import org.exoplatform.services.log.ExoLogger; -import org.exoplatform.services.log.Log; -import org.exoplatform.services.xml.transform.NotSupportedIOTypeException; -import org.exoplatform.services.xml.transform.trax.TRAXTemplates; -import org.exoplatform.services.xml.transform.trax.TRAXTemplatesService; -import org.exoplatform.services.xml.transform.trax.TRAXTransformerService; -import org.picocontainer.Startable; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import javax.xml.transform.Source; -import javax.xml.transform.TransformerException; -import javax.xml.transform.stream.StreamSource; - -/** - * @author Andrey Parfonov - * @version $Id: $ - */ -public class TRAXTemplatesServiceImpl implements TRAXTemplatesService, Startable -{ - - private static final Log LOG = ExoLogger.getLogger("exo.core.component.xml-processing.TRAXTemplatesServiceImpl"); - - private Map templates_; - - private TRAXTransformerService traxTransformerService_; - - public TRAXTemplatesServiceImpl(TRAXTransformerService traxTransformerService) - { - traxTransformerService_ = traxTransformerService; - templates_ = new HashMap(); - } - - /* - * (non-Javadoc) - * @see - * org.exoplatform.services.xml.transform.trax.TRAXTemplatesService#getTemplates - * ( java.lang.String) - */ - public TRAXTemplates getTemplates(String key) - { - return templates_.get(key); - } - - /* - * (non-Javadoc) - * @seeorg.exoplatform.services.xml.transform.trax.TRAXTemplatesService# - * addTRAXTemplates( java.lang.String, - * org.exoplatform.services.xml.transform.trax.TRAXTemplates) - */ - public void addTRAXTemplates(String key, TRAXTemplates templates) throws IllegalArgumentException - { - if (templates_.get(key) != null) - { - throw new IllegalArgumentException("Templates with key '" + key + "' already exists!"); - } - templates_.put(key, templates); - } - - /* - * (non-Javadoc) - * @seeorg.exoplatform.services.xml.transform.trax.TRAXTemplatesService# - * addTRAXTemplates( java.lang.String, javax.xml.transform.Source) - */ - public void addTRAXTemplates(String key, Source source) throws IllegalArgumentException - { - if (templates_.get(key) != null) - { - throw new IllegalArgumentException("Templates with key '" + key + "' already exists!"); - } - try - { - templates_.put(key, traxTransformerService_.getTemplates(source)); - } - catch (NotSupportedIOTypeException e) - { - throw new IllegalArgumentException("Source has unsupported context." + e, e); - } - catch (TransformerException e) - { - throw new IllegalArgumentException("Can't get templates from source." + e, e); - } - } - - public void addPlugin(ComponentPlugin plugin) - { - if (plugin instanceof TRAXTemplatesLoaderPlugin) - { - Map m = ((TRAXTemplatesLoaderPlugin)plugin).getTRAXTemplates(); - Set keys = m.keySet(); - for (String key : keys) - { - String xsltSchema = m.get(key); - try - { - if (Thread.currentThread().getContextClassLoader().getResource(xsltSchema) != null) - { - LOG.info("XSLT schema found by relative path: " + xsltSchema); - addTRAXTemplates(key, traxTransformerService_.getTemplates(new StreamSource(Thread.currentThread().getContextClassLoader() - .getResourceAsStream(xsltSchema)))); - } - else - LOG.error("XSLT schema not found: " + xsltSchema); - } - catch (IllegalArgumentException e) - { - LOG.error("Add new TRAXTemplates failed : " + e.getMessage()); - } - catch (TransformerException e) - { - LOG.error("Add new TRAXTemplates failed : " + e.getMessage()); - } - catch (NotSupportedIOTypeException e) - { - LOG.error("Add new TRAXTemplates failed : " + e.getMessage()); - } - } - } - } - - // ------ Startable ------- - - /* - * (non-Javadoc) - * @see org.picocontainer.Startable#start() - */ - public void start() - { - } - - /* - * (non-Javadoc) - * @see org.picocontainer.Startable#stop() - */ - public void stop() - { - } - -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTransformerImpl.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTransformerImpl.java deleted file mode 100644 index ea1e42d87..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTransformerImpl.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform.impl.trax; - -import org.exoplatform.services.xml.transform.NotSupportedIOTypeException; -import org.exoplatform.services.xml.transform.impl.TransformerBase; -import org.exoplatform.services.xml.transform.trax.TRAXTransformer; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.Properties; - -import javax.xml.transform.ErrorListener; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.URIResolver; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.sax.SAXResult; -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.sax.TransformerHandler; -import javax.xml.transform.stream.StreamResult; - -/** - * Created by The eXo Platform SAS . Implementation of Trax Transformer - * interface - * - * @author Gennady Azarenkov - * @author Alexander Kravchuk - * @version $Id: TRAXTransformerImpl.java 5799 2006-05-28 17:55:42Z geaz $ - */ - -public class TRAXTransformerImpl extends TransformerBase implements TRAXTransformer -{ - - protected TransformerHandler tHandler; - - protected Transformer getTransformer() - { - return tHandler.getTransformer(); - } - - public TRAXTransformerImpl() throws TransformerConfigurationException - { - SAXTransformerFactory saxTFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); - tHandler = saxTFactory.newTransformerHandler(); - } - - public TRAXTransformerImpl(final Source source) throws TransformerConfigurationException - { - final SAXTransformerFactory saxTFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); - - tHandler = saxTFactory.newTransformerHandler(source); - - } - - public TRAXTransformerImpl(Templates templates) throws TransformerConfigurationException - { - SAXTransformerFactory saxTFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); - tHandler = saxTFactory.newTransformerHandler(templates); - } - - @Override - protected void internalTransform(Source source) throws TransformerException, NotSupportedIOTypeException, - IllegalStateException - { - - XMLReader xmlReader = null; - - try - { - // xmlReader = XMLReaderFactory. - // createXMLReader("org.apache.xerces.parsers.SAXParser"); - xmlReader = getXMLReader(); - // set default resolver - if (resolvingService != null) - { - xmlReader.setEntityResolver(resolvingService.getEntityResolver()); - LOG.debug("Set entity resolver"); - } - } - catch (SAXException ex) - { - throw new TransformerException(ex); - } - - xmlReader.setContentHandler(tHandler); - // tHandler.setResult(getResult()); - - InputSource inputSource = null; - // todo simplify - // SAXSource.sourceToInputSource(Source source) from JSDK does not supported - // DOMSource - if (source instanceof DOMSource) - { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - SAXTransformerFactory.newInstance().newTransformer().transform(source, new StreamResult(outputStream)); - inputSource = new InputSource(new ByteArrayInputStream(outputStream.toByteArray())); - } - else - { - inputSource = SAXSource.sourceToInputSource(source); - } - if (inputSource == null) - { - throw new NotSupportedIOTypeException(source); - } - - try - { - final XMLReader fXMLReader = xmlReader; - final InputSource fInputSource = inputSource; - fXMLReader.parse(fInputSource); - } - catch (Exception e) - { - Throwable cause = e.getCause(); - if (cause instanceof SAXException) - { - throw new TransformerException(cause); - } - else if (cause instanceof IOException) - { - throw new TransformerException(cause); - } - else if (cause instanceof RuntimeException) - { - throw (RuntimeException)cause; - } - else - { - throw new RuntimeException(cause); - } - } - } - - @Override - protected void afterInitResult() - { - tHandler.setResult(getResult()); - } - - // delegation to Transformer, see getTransformer() - public Result getTransformerAsResult() - { - return new SAXResult(tHandler); - } - - public Object getParameter(String param) - { - return getTransformer().getParameter(param); - } - - public void setParameter(String name, Object value) - { - getTransformer().setParameter(name, value); - } - - public void clearParameters() - { - getTransformer().clearParameters(); - } - - public String getOutputProperty(String prop) - { - return getTransformer().getOutputProperty(prop); - } - - public void setOutputProperty(String name, String value) - { - getTransformer().setOutputProperty(name, value); - } - - public void setOutputProperties(Properties props) - { - getTransformer().setOutputProperties(props); - } - - public Properties getOutputProperties() - { - return getTransformer().getOutputProperties(); - } - - public URIResolver getURIResolver() - { - return getTransformer().getURIResolver(); - } - - public void setURIResolver(URIResolver resolver) - { - getTransformer().setURIResolver(resolver); - } - - public ErrorListener getErrorListener() - { - return getTransformer().getErrorListener(); - } - - public void setErrorListener(ErrorListener listener) - { - getTransformer().setErrorListener(listener); - } - -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTransformerServiceImpl.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTransformerServiceImpl.java deleted file mode 100644 index f75df317e..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/impl/trax/TRAXTransformerServiceImpl.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform.impl.trax; - -import org.exoplatform.services.xml.resolving.XMLResolvingService; -import org.exoplatform.services.xml.transform.NotSupportedIOTypeException; -import org.exoplatform.services.xml.transform.trax.TRAXTemplates; -import org.exoplatform.services.xml.transform.trax.TRAXTransformer; -import org.exoplatform.services.xml.transform.trax.TRAXTransformerService; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -import java.io.IOException; - -import javax.xml.transform.Source; -import javax.xml.transform.Templates; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.sax.SAXSource; -import javax.xml.transform.sax.SAXTransformerFactory; -import javax.xml.transform.sax.TemplatesHandler; - -/** - * Created by The eXo Platform SAS . - * - * @author Gennady Azarenkov - * @author Alexander Kravchuk - * @version $Id: TRAXTransformerServiceImpl.java 5799 2006-05-28 17:55:42Z geaz - * $ - */ - -public class TRAXTransformerServiceImpl implements TRAXTransformerService -{ - - private XMLResolvingService resolvingService; - - public TRAXTransformerServiceImpl(XMLResolvingService resolvingService) - { - this.resolvingService = resolvingService; - } - - public TRAXTransformer getTransformer() throws TransformerConfigurationException - { - TRAXTransformerImpl transf = new TRAXTransformerImpl(); - transf.setResolvingService(resolvingService); - return transf; - } - - public TRAXTransformer getTransformer(Source source) throws TransformerConfigurationException - { - TRAXTransformerImpl transf = new TRAXTransformerImpl(source); - transf.setResolvingService(resolvingService); - return transf; - } - - public TRAXTemplates getTemplates(Source source) throws TransformerException, NotSupportedIOTypeException - { - TRAXTemplatesImpl templates = new TRAXTemplatesImpl(getXSLTemplates(source)); - templates.setResolvingService(resolvingService); - return templates; - } - - private Templates getXSLTemplates(Source source) throws TransformerException, NotSupportedIOTypeException - { - SAXTransformerFactory saxTFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); - - TemplatesHandler templateHandler = saxTFactory.newTemplatesHandler(); - XMLReader xmlReader; - try - { - // xmlReader = XMLReaderFactory. - // createXMLReader("org.apache.xerces.parsers.SAXParser"); - xmlReader = TRAXTransformerImpl.getXMLReader(); - // set default resolver - if (resolvingService != null) - { - xmlReader.setEntityResolver(resolvingService.getEntityResolver()); - } - - } - catch (SAXException ex) - { - throw new TransformerException(ex); - } - - xmlReader.setContentHandler(templateHandler); - InputSource inputSource = SAXSource.sourceToInputSource(source); - if (inputSource == null) - { - throw new NotSupportedIOTypeException(source); - } - - try - { - xmlReader.parse(inputSource); - } - catch (SAXException ex) - { - throw new TransformerException(ex); - } - catch (IOException ex) - { - throw new TransformerException(ex); - } - - return templateHandler.getTemplates(); - - } - -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/Constants.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/Constants.java deleted file mode 100644 index 83e23dda7..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/Constants.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform.trax; - -/** - * Created by The eXo Platform SAS . - * - * @author Gennady Azarenkov - * @version $Id: Constants.java 5799 2006-05-28 17:55:42Z geaz $ - */ - -public class Constants -{ - public static final String XSLT_DIR = "xslt"; - - public static final String DOCBOOK_TO_HTML_STYLE = XSLT_DIR + "/docbook/html/docbook.xsl"; - - public static final String DOCBOOK_TO_FO_STYLE = XSLT_DIR + "/docbook/fo/docbook.xsl"; -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/TRAXTemplates.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/TRAXTemplates.java deleted file mode 100644 index 7415818f3..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/TRAXTemplates.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform.trax; - -import java.util.Properties; - -import javax.xml.transform.TransformerConfigurationException; - -/** - * Created by The eXo Platform SAS . An object that implements this interface is - * the runtime representation of processed transformation instructions Analog of - * javax.xml.transform.Templates - * - * @author Alexander Kravchuk - * @version $Id: TRAXTemplates.java 5799 2006-05-28 17:55:42Z geaz $ - * @see javax.xml.transform.Templates - */ -public interface TRAXTemplates -{ - - /** - * @see javax.xml.transform.Templates#getOutputProperties() - */ - Properties getOutputProperties(); - - TRAXTransformer newTransformer() throws TransformerConfigurationException; - -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/TRAXTemplatesService.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/TRAXTemplatesService.java deleted file mode 100644 index f95bb6214..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/TRAXTemplatesService.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform.trax; - -import javax.xml.transform.Source; - -/** - * @author Andrey Parfonov - * @version $Id: $ - */ -public interface TRAXTemplatesService -{ - - /** - * Add new TRAXTemplates to the service. - * - * @param key the key for this templates. - * @param templates the TRAXTemplates. - * @throws IllegalArgumentException - */ - void addTRAXTemplates(String key, TRAXTemplates templates) throws IllegalArgumentException; - - /** - * Add new TRAXTemplates to the service from javax.xml.transform.Source. - * - * @param key the key for this templates. - * @param source the TRAXTemplates. - * @throws IllegalArgumentException - */ - void addTRAXTemplates(String key, Source source) throws IllegalArgumentException; - - /** - * Get templates by key. - * - * @param key the key. - * @return the TRAXTemplates or null. - */ - TRAXTemplates getTemplates(String key); - -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/TRAXTransformer.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/TRAXTransformer.java deleted file mode 100644 index ea9b22690..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/TRAXTransformer.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform.trax; - -import org.exoplatform.services.xml.transform.PipeTransformer; - -import java.util.Properties; - -import javax.xml.transform.ErrorListener; -import javax.xml.transform.URIResolver; - -/** - * Created by The eXo Platform SAS. - * - * @author Gennady Azarenkov - * @author Alexander Kravchuk - * @version $Id: TRAXTransformer.java 5799 2006-05-28 17:55:42Z geaz $ - */ -public interface TRAXTransformer extends PipeTransformer -{ - /** - * @see javax.xml.transform.Transformer#getParameter(java.lang.String) - */ - Object getParameter(String param); - - /** - * @see javax.xml.transform.Transformer#setParameter(java.lang.String, - * java.lang.Object) - */ - void setParameter(String name, Object value); - - /** - * @see javax.xml.transform.Transformer#clearParameters() - */ - void clearParameters(); - - /** - * @see javax.xml.transform.Transformer#getOutputProperty(java.lang.String) - */ - String getOutputProperty(String prop); - - /** - * @see javax.xml.transform.Transformer#setOutputProperty(java.lang.String, - * java.lang.String) - */ - void setOutputProperty(String name, String value); - - /** - * @see javax.xml.transform.Transformer#setOutputProperties(java.util.Properties) - */ - void setOutputProperties(Properties props); - - /** - * @see javax.xml.transform.Transformer#getOutputProperties() - */ - Properties getOutputProperties(); - - /** - * @see javax.xml.transform.Transformer#getURIResolver() - */ - URIResolver getURIResolver(); - - /** - * @see javax.xml.transform.Transformer#setURIResolver(javax.xml.transform.URIResolver) - */ - void setURIResolver(URIResolver resolver); - - /** - * @see javax.xml.transform.Transformer#getErrorListener() - */ - ErrorListener getErrorListener(); - - /** - * @see javax.xml.transform.Transformer#setErrorListener(javax.xml.transform.ErrorListener) - */ - void setErrorListener(ErrorListener listener); - -} diff --git a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/TRAXTransformerService.java b/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/TRAXTransformerService.java deleted file mode 100644 index 3e2facfec..000000000 --- a/exo.core.component.xml-processing/src/main/java/org/exoplatform/services/xml/transform/trax/TRAXTransformerService.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform.trax; - -import org.exoplatform.container.spi.DefinitionByType; -import org.exoplatform.services.xml.transform.NotSupportedIOTypeException; -import org.exoplatform.services.xml.transform.impl.trax.TRAXTransformerServiceImpl; - -import javax.xml.transform.Source; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; - -/** - * Created by The eXo Platform SAS . - * - * @author Gennady Azarenkov - * @author Alexander Kravchuk - * @version $Id: TRAXTransformerService.java 5799 2006-05-28 17:55:42Z geaz $ - */ -@DefinitionByType(type = TRAXTransformerServiceImpl.class) -public interface TRAXTransformerService -{ - TRAXTransformer getTransformer() throws TransformerConfigurationException; - - TRAXTransformer getTransformer(Source source) throws TransformerConfigurationException; - - TRAXTemplates getTemplates(Source source) throws TransformerException, NotSupportedIOTypeException; -} diff --git a/exo.core.component.xml-processing/src/main/resources/CatalogManager.properties b/exo.core.component.xml-processing/src/main/resources/CatalogManager.properties deleted file mode 100644 index 984089fb0..000000000 --- a/exo.core.component.xml-processing/src/main/resources/CatalogManager.properties +++ /dev/null @@ -1,9 +0,0 @@ -#CatalogManager.properties -verbosity=1 -relative-catalogs=yes -# Always use semicolons in this list /xcatalog;/share/doctypes/catalog -catalogs=catalog/exo-catalog.xml -prefer=public -static-catalog=yes -allow-oasis-xml-catalog-pi=yes -catalog-class-name=org.apache.xml.resolver.Resolver diff --git a/exo.core.component.xml-processing/src/main/resources/catalog/exo-catalog.xml b/exo.core.component.xml-processing/src/main/resources/catalog/exo-catalog.xml deleted file mode 100644 index ac3009a2f..000000000 --- a/exo.core.component.xml-processing/src/main/resources/catalog/exo-catalog.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/conf/configuration.xml b/exo.core.component.xml-processing/src/main/resources/conf/configuration.xml deleted file mode 100644 index 8f9aa4cf0..000000000 --- a/exo.core.component.xml-processing/src/main/resources/conf/configuration.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - org.exoplatform.services.xml.resolving.impl.XMLResolvingServiceImpl - - - add.resolving.table - addPlugin - org.exoplatform.services.xml.resolving.impl.AddXMLResolvingContextPlugin - - - xhtml1-transitional.dtd - - - - - - web-app_2_3.dtd - - - - - - datatypes.dtd - - - - - XMLSchema.dtd - - - - - - xhtml1-frameset.dtd - - - - - - xhtml1-strict.dtd - - - - - - xhtml-lat1.ent - - - - - - xhtml-special.ent - - - - - - xhtml-symbol.ent - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/conf/portal/configuration.xml b/exo.core.component.xml-processing/src/main/resources/conf/portal/configuration.xml deleted file mode 100644 index 7c62b11a0..000000000 --- a/exo.core.component.xml-processing/src/main/resources/conf/portal/configuration.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - org.exoplatform.services.xml.transform.impl.trax.TRAXTemplatesServiceImpl - - - org.exoplatform.services.xml.resolving.impl.XMLResolvingServiceImpl - - - add.resolving.table - addPlugin - org.exoplatform.services.xml.resolving.impl.AddXMLResolvingContextPlugin - - - xhtml1-transitional.dtd - - - - - - web-app_2_3.dtd - - - - - - datatypes.dtd - - - - - XMLSchema.dtd - - - - - - xhtml1-frameset.dtd - - - - - - xhtml1-strict.dtd - - - - - - xhtml-lat1.ent - - - - - - xhtml-special.ent - - - - - - xhtml-symbol.ent - - - - - - - - - \ No newline at end of file diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/XMLSchema.dtd b/exo.core.component.xml-processing/src/main/resources/dtd/XMLSchema.dtd deleted file mode 100644 index 9e57dda97..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/XMLSchema.dtd +++ /dev/null @@ -1,402 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -%xs-datatypes; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/datatypes.dtd b/exo.core.component.xml-processing/src/main/resources/dtd/datatypes.dtd deleted file mode 100644 index 3547e11a7..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/datatypes.dtd +++ /dev/null @@ -1,203 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/j2ee_1_4.xsd b/exo.core.component.xml-processing/src/main/resources/dtd/j2ee_1_4.xsd deleted file mode 100644 index e19c16dcc..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/j2ee_1_4.xsd +++ /dev/null @@ -1,1674 +0,0 @@ - - - - - @(#)j2ee_1_4.xsds 1.43 03/09/16 - - - - - - - Copyright 2003 Sun Microsystems, Inc., 901 San Antonio - Road, Palo Alto, California 94303, U.S.A. All rights - reserved. - - Sun Microsystems, Inc. has intellectual property rights - relating to technology described in this document. In - particular, and without limitation, these intellectual - property rights may include one or more of the U.S. patents - listed at http://www.sun.com/patents and one or more - additional patents or pending patent applications in the - U.S. and other countries. - - This document and the technology which it describes are - distributed under licenses restricting their use, copying, - distribution, and decompilation. No part of this document - may be reproduced in any form by any means without prior - written authorization of Sun and its licensors, if any. - - Third-party software, including font technology, is - copyrighted and licensed from Sun suppliers. - - Sun, Sun Microsystems, the Sun logo, Solaris, Java, J2EE, - JavaServer Pages, Enterprise JavaBeans and the Java Coffee - Cup logo are trademarks or registered trademarks of Sun - Microsystems, Inc. in the U.S. and other countries. - - Federal Acquisitions: Commercial Software - Government Users - Subject to Standard License Terms and Conditions. - - - - - - - -The following definitions that appear in the common -shareable schema(s) of J2EE deployment descriptors should be -interpreted with respect to the context they are included: - -Deployment Component may indicate one of the following: - j2ee application; - application client; - web application; - enterprise bean; - resource adapter; - -Deployment File may indicate one of the following: - ear file; - war file; - jar file; - rar file; - - - - - - - - - - - - - - - - This group keeps the usage of the contained description related - elements consistent across J2EE deployment descriptors. - - All elements may occur multiple times with different languages, - to support localization of the content. - - - - - - - - - - - - - - - - - - The description type is used by a description element to - provide text describing the parent element. The elements - that use this type should include any information that the - Deployment Component's Deployment File file producer wants - to provide to the consumer of the Deployment Component's - Deployment File (i.e., to the Deployer). Typically, the - tools used by such a Deployment File consumer will display - the description when processing the parent element that - contains the description. - - The lang attribute defines the language that the - description is provided in. The default value is "en" (English). - - - - - - - - - - - - - - - - - - This type defines a dewey decimal which is used - to describe versions of documents. - - - - - - - - - - - - - - - - - - Employee Self Service - - The value of the xml:lang attribute is "en" (English) by default. - - ]]> - - - - - - - - - - - - - - - - EmployeeRecord - - ../products/product.jar#ProductEJB - - ]]> - - - - - - - - - - - - - - - - The ejb-local-refType is used by ejb-local-ref elements for - the declaration of a reference to an enterprise bean's local - home. The declaration consists of: - - - an optional description - - the EJB reference name used in the code of the Deployment - Component that's referencing the enterprise bean - - the expected type of the referenced enterprise bean - - the expected local home and local interfaces of the - referenced enterprise bean - - optional ejb-link information, used to specify the - referenced enterprise bean - - - - - - - - - - - - - - - - - - - - - - - ejb/Payroll - - ]]> - - - - - - - - - - - - - - The ejb-ref-typeType contains the expected type of the - referenced enterprise bean. - - The ejb-ref-type designates a value - that must be one of the following: - - Entity - Session - - - - - - - - - - - - - - - - - - - - The ejb-refType is used by ejb-ref elements for the - declaration of a reference to an enterprise bean's home. The - declaration consists of: - - - an optional description - - the EJB reference name used in the code of - the Deployment Component that's referencing the enterprise - bean - - the expected type of the referenced enterprise bean - - the expected home and remote interfaces of the referenced - enterprise bean - - optional ejb-link information, used to specify the - referenced enterprise bean - - - - - - - - - - - - - - - - - - - - - - - - This type is used to designate an empty - element when used. - - - - - - - - - - - - java.lang.Boolean - - ]]> - - - - - - - - - - - - - - - - - - - - - - - - - - The env-entryType is used to declare an application's - environment entry. The declaration consists of an optional - description, the name of the environment entry, and an - optional value. If a value is not specified, one must be - supplied during deployment. - - It is used by env-entry elements. - - - - - - - - - - - minAmount - - ]]> - - - - - - - - - - - 100.00 - - ]]> - - - - - - - - - - - - - - - The elements that use this type designate the name of a - Java class or interface. The name is in the form of a - "binary name", as defined in the JLS. This is the form - of name used in Class.forName(). Tools that need the - canonical name (the name used in source code) will need - to convert this binary name to the canonical name. - - - - - - - - - - - - - - - - This type defines four different values which can designate - boolean values. This includes values yes and no which are - not designated by xsd:boolean - - - - - - - - - - - - - - - - - - - - - com.aardvark.payroll.PayrollHome - - ]]> - - - - - - - - - - - - - - - The icon type contains small-icon and large-icon elements - that specify the file names for small and large GIF or - JPEG icon images used to represent the parent element in a - GUI tool. - - The xml:lang attribute defines the language that the - icon file names are provided in. Its value is "en" (English) - by default. - - - - - - - - - employee-service-icon16x16.jpg - - ]]> - - - - - - - - employee-service-icon32x32.jpg - - ]]> - - - - - - - - - - - - - - - - - - - - The java-identifierType defines a Java identifier. - The users of this type should further verify that - the content does not contain Java reserved keywords. - - - - - - - - - - - - - - - - - - This is a generic type that designates a Java primitive - type or a fully qualified name of a Java interface/type, - or an array of such types. - - - - - - - - - - - - - - - - - - The jndi-nameType type designates a JNDI name in the - Deployment Component's environment and is relative to the - java:comp/env context. A JNDI name must be unique within the - Deployment Component. - - - - - - - - - - - - - - - - This group keeps the usage of the contained JNDI environment - reference elements consistent across J2EE deployment descriptors. - - - - - - - - - - - - - - - - - - - - - - - The listenerType indicates the deployment properties for a web - application listener bean. - - - - - - - - - - - The listener-class element declares a class in the - application must be registered as a web - application listener bean. The value is the fully - qualified classname of the listener class. - - - - - - - - - - - - - - - - The local-homeType defines the fully-qualified - name of an enterprise bean's local home interface. - - - - - - - - - - - - - - - The localType defines the fully-qualified name of an - enterprise bean's local interface. - - - - - - - - - - - - - - - - The message-destination-linkType is used to link a message - destination reference or message-driven bean to a message - destination. - - The Assembler sets the value to reflect the flow of messages - between producers and consumers in the application. - - The value must be the message-destination-name of a message - destination in the same Deployment File or in another - Deployment File in the same J2EE application unit. - - Alternatively, the value may be composed of a path name - specifying a Deployment File containing the referenced - message destination with the message-destination-name of the - destination appended and separated from the path name by - "#". The path name is relative to the Deployment File - containing Deployment Component that is referencing the - message destination. This allows multiple message - destinations with the same name to be uniquely identified. - - - - - - - - - - - - - - - - - jms/StockQueue - - javax.jms.Queue - - Consumes - - CorporateStocks - - - - ]]> - - - - - - - - - The message-destination-ref-name element specifies - the name of a message destination reference; its - value is the environment entry name used in - Deployment Component code. The name is a JNDI name - relative to the java:comp/env context and must be - unique within an ejb-jar (for enterprise beans) or a - Deployment File (for others). - - - - - - - - - - - - - - - - - - javax.jms.Queue - - - ]]> - - - - - - - - - - - - - - - The message-destination-usageType specifies the use of the - message destination indicated by the reference. The value - indicates whether messages are consumed from the message - destination, produced for the destination, or both. The - Assembler makes use of this information in linking producers - of a destination with its consumers. - - The value of the message-destination-usage element must be - one of the following: - Consumes - Produces - ConsumesProduces - - - - - - - - - - - - - - - - - - - - CorporateStocks - - - - ]]> - - - - - - - - - - The message-destination-name element specifies a - name for a message destination. This name must be - unique among the names of message destinations - within the Deployment File. - - - - - - - - - - - - - - - - This type is a general type that can be used to declare - parameter/value lists. - - - - - - - - - - - The param-name element contains the name of a - parameter. - - - - - - - - - - The param-value element contains the value of a - parameter. - - - - - - - - - - - - - - - - - The elements that use this type designate either a relative - path or an absolute path starting with a "/". - - In elements that specify a pathname to a file within the - same Deployment File, relative filenames (i.e., those not - starting with "/") are considered relative to the root of - the Deployment File's namespace. Absolute filenames (i.e., - those starting with "/") also specify names in the root of - the Deployment File's namespace. In general, relative names - are preferred. The exception is .war files where absolute - names are preferred for consistency with the Servlet API. - - - - - - - - - - - - - - com.wombat.empl.EmployeeService - - ]]> - - - - - - - - - - - - - - - The res-authType specifies whether the Deployment Component - code signs on programmatically to the resource manager, or - whether the Container will sign on to the resource manager - on behalf of the Deployment Component. In the latter case, - the Container uses information that is supplied by the - Deployer. - - The value must be one of the two following: - - Application - Container - - - - - - - - - - - - - - - - - - - The res-sharing-scope type specifies whether connections - obtained through the given resource manager connection - factory reference can be shared. The value, if specified, - must be one of the two following: - - Shareable - Unshareable - - The default value is Shareable. - - - - - - - - - - - - - - - - - - - - jms/StockQueue - - javax.jms.Queue - - - - ]]> - - - - - - - - - - - The resource-env-ref-name element specifies the name - of a resource environment reference; its value is - the environment entry name used in - the Deployment Component code. The name is a JNDI - name relative to the java:comp/env context and must - be unique within a Deployment Component. - - - - - - - - - - The resource-env-ref-type element specifies the type - of a resource environment reference. It is the - fully qualified name of a Java language class or - interface. - - - - - - - - - - - - - - - - jdbc/EmployeeAppDB - javax.sql.DataSource - Container - Shareable - - - ]]> - - - - - - - - - - - The res-ref-name element specifies the name of a - resource manager connection factory reference. - The name is a JNDI name relative to the - java:comp/env context. - The name must be unique within a Deployment File. - - - - - - - - - - - The res-type element specifies the type of the data - source. The type is specified by the fully qualified - Java language class or interface - expected to be implemented by the data source. - - - - - - - - - - - - - - - - - - - - The role-nameType designates the name of a security role. - - The name must conform to the lexical rules for a token. - - - - - - - - - - - - - - - - - - The run-asType specifies the run-as identity to be - used for the execution of a component. It contains an - optional description, and the name of a security role. - - - - - - - - - - - - - - - - - - - The security-role-refType contains the declaration of a - security role reference in a component's or a - Deployment Component's code. The declaration consists of an - optional description, the security role name used in the - code, and an optional link to a security role. If the - security role is not specified, the Deployer must choose an - appropriate security role. - - - - - - - - - - - - The value of the role-name element must be the String used - as the parameter to the - EJBContext.isCallerInRole(String roleName) method or the - HttpServletRequest.isUserInRole(String role) method. - - - - - - - - - - - The role-link element is a reference to a defined - security role. The role-link element must contain - the name of one of the security roles defined in the - security-role elements. - - - - - - - - - - - - - - - - - - This role includes all employees who are authorized - to access the employee service application. - - employee - - - ]]> - - - - - - - - - - - - - - - - - - This is a special string datatype that is defined by J2EE as - a base type for defining collapsed strings. When schemas - require trailing/leading space elimination as well as - collapsing the existing whitespace, this base type may be - used. - - - - - - - - - - - - - - - - - - - This simple type designates a boolean with only two - permissible values - - - true - - false - - - - - - - - - - - - - - - - - - The url-patternType contains the url pattern of the mapping. - It must follow the rules specified in Section 11.2 of the - Servlet API Specification. This pattern is assumed to be in - URL-decoded form and must not contain CR(#xD) or LF(#xA). - If it contains those characters, the container must inform - the developer with a descriptive error message. - The container must preserve all characters including whitespaces. - - - - - - - - - - - - - - - - - This type adds an "id" attribute to xsd:anyURI. - - - - - - - - - - - - - - - - - - This type adds an "id" attribute to xsd:boolean. - - - - - - - - - - - - - - - - - - - This type adds an "id" attribute to xsd:integer. - - - - - - - - - - - - - - - - - - This type adds an "id" attribute to xsd:NMTOKEN. - - - - - - - - - - - - - - - - - - This type adds an "id" attribute to xsd:nonNegativeInteger. - - - - - - - - - - - - - - - - - - This type adds an "id" attribute to xsd:positiveInteger. - - - - - - - - - - - - - - - - - - This type adds an "id" attribute to xsd:QName. - - - - - - - - - - - - - - - - - - This type adds an "id" attribute to xsd:string. - - - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/j2ee_web_services_client_1_1.xsd b/exo.core.component.xml-processing/src/main/resources/dtd/j2ee_web_services_client_1_1.xsd deleted file mode 100644 index 12160f233..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/j2ee_web_services_client_1_1.xsd +++ /dev/null @@ -1,355 +0,0 @@ - - - - - @(#)j2ee_web_services_client_1_1.xsds 1.10 02/11/03 - - - - - - - Copyright 2002 Sun Microsystems, Inc., 901 San Antonio - Road, Palo Alto, California 94303, U.S.A. All rights - reserved. - - Sun Microsystems, Inc. has intellectual property rights - relating to technology described in this document. In - particular, and without limitation, these intellectual - property rights may include one or more of the U.S. patents - listed at http://www.sun.com/patents and one or more - additional patents or pending patent applications in the - U.S. and other countries. - - This document and the technology which it describes are - distributed under licenses restricting their use, copying, - distribution, and decompilation. No part of this document - may be reproduced in any form by any means without prior - written authorization of Sun and its licensors, if any. - - Third-party software, including font technology, is - copyrighted and licensed from Sun suppliers. - - Sun, Sun Microsystems, the Sun logo, Solaris, Java, J2EE, - JavaServer Pages, Enterprise JavaBeans and the Java Coffee - Cup logo are trademarks or registered trademarks of Sun - Microsystems, Inc. in the U.S. and other countries. - - Federal Acquisitions: Commercial Software - Government Users - Subject to Standard License Terms and Conditions. - - - - - - - (C) Copyright International Business Machines Corporation 2002 - - - - - - - - - - - - The port-component-ref element declares a client dependency - on the container for resolving a Service Endpoint Interface - to a WSDL port. It optionally associates the Service Endpoint - Interface with a particular port-component. This is only used - by the container for a Service.getPort(Class) method call. - - - - - - - - - - - The service-endpoint-interface element defines a fully qualified - Java class that represents the Service Endpoint Interface of a - WSDL port. - - - - - - - - - - - The port-component-link element links a port-component-ref - to a specific port-component required to be made available - by a service reference. - - The value of a port-component-link must be the - port-component-name of a port-component in the same module - or another module in the same application unit. The syntax - for specification follows the syntax defined for ejb-link - in the EJB 2.0 specification. - - - - - - - - - - - - - - - - - - Defines the name of the handler. The name must be unique - within the module. - - - - - - - - - - - - - - - - - - The service-ref element declares a reference to a Web - service. It contains optional description, display name and - icons, a declaration of the required Service interface, - an optional WSDL document location, an optional set - of JAX-RPC mappings, an optional QName for the service element, - an optional set of Service Endpoint Interfaces to be resolved - by the container to a WSDL port, and an optional set of handlers. - - - - - - - - - - - - The service-ref-name element declares logical name that the - components in the module use to look up the Web service. It - is recommended that all service reference names start with - "service/". - - - - - - - - - - - The service-interface element declares the fully qualified class - name of the JAX-RPC Service interface the client depends on. - In most cases the value will be javax.xml.rpc.Service. A JAX-RPC - generated Service Interface class may also be specified. - - - - - - - - - - - The wsdl-file element contains the URI location of a WSDL - file. The location is relative to the root of the module. - - - - - - - - - - The jaxrpc-mapping-file element contains the name of a file that - describes the JAX-RPC mapping between the Java interaces used by - the application and the WSDL description in the wsdl-file. The - file name is a relative path within the module file. - - - - - - - - - - The service-qname element declares the specific WSDL service - element that is being refered to. It is not specified if no - wsdl-file is declared. - - - - - - - - - - - The port-component-ref element declares a client dependency - on the container for resolving a Service Endpoint Interface - to a WSDL port. It optionally associates the Service Endpoint - Interface with a particular port-component. This is only used - by the container for a Service.getPort(Class) method call. - - - - - - - - - - - Declares the handler for a port-component. Handlers can - access the init-param name/value pairs using the - HandlerInfo interface. If port-name is not specified, the - handler is assumed to be associated with all ports of the - service. - - - - - - - - - - - - - - - - Declares the handler for a port-component. Handlers can access the - init-param name/value pairs using the HandlerInfo interface. If - port-name is not specified, the handler is assumed to be associated - with all ports of the service. - - Used in: service-ref - - - - - - - - - - - Defines the name of the handler. The name must be unique - within the module. - - - - - - - - - - Defines a fully qualified class name for the handler - implementation. - - - - - - - - - - - Defines the QName of a SOAP header that will be processed - by the handler. - - - - - - - - - - - The soap-role element contains a SOAP actor definition that - the Handler will play as a role. - - - - - - - - - - - The port-name element defines the WSDL port-name that a - handler should be associated with. - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/jsp_2_0.xsd b/exo.core.component.xml-processing/src/main/resources/dtd/jsp_2_0.xsd deleted file mode 100644 index c073b701f..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/jsp_2_0.xsd +++ /dev/null @@ -1,313 +0,0 @@ - - - - - @(#)jsp_2_0.xsds 1.17 03/18/03 - - - - - - - Copyright 2003 Sun Microsystems, Inc., 901 San Antonio - Road, Palo Alto, California 94303, U.S.A. All rights - reserved. - - Sun Microsystems, Inc. has intellectual property rights - relating to technology described in this document. In - particular, and without limitation, these intellectual - property rights may include one or more of the U.S. patents - listed at http://www.sun.com/patents and one or more - additional patents or pending patent applications in the - U.S. and other countries. - - This document and the technology which it describes are - distributed under licenses restricting their use, copying, - distribution, and decompilation. No part of this document - may be reproduced in any form by any means without prior - written authorization of Sun and its licensors, if any. - - Third-party software, including font technology, is - copyrighted and licensed from Sun suppliers. - - Sun, Sun Microsystems, the Sun logo, Solaris, Java, J2EE, - JavaServer Pages, Enterprise JavaBeans and the Java Coffee - Cup logo are trademarks or registered trademarks of Sun - Microsystems, Inc. in the U.S. and other countries. - - Federal Acquisitions: Commercial Software - Government Users - Subject to Standard License Terms and Conditions. - - - - - - - - This is the XML Schema for the JSP 2.0 deployment descriptor - types. The JSP 2.0 schema contains all the special - structures and datatypes that are necessary to use JSP files - from a web application. - - The contents of this schema is used by the web-app_2_4.xsd - file to define JSP specific content. - - - - - - - - The following conventions apply to all J2EE - deployment descriptor elements unless indicated otherwise. - - - In elements that specify a pathname to a file within the - same JAR file, relative filenames (i.e., those not - starting with "/") are considered relative to the root of - the JAR file's namespace. Absolute filenames (i.e., those - starting with "/") also specify names in the root of the - JAR file's namespace. In general, relative names are - preferred. The exception is .war files where absolute - names are preferred for consistency with the Servlet API. - - - - - - - - - - - - - - The jsp-configType is used to provide global configuration - information for the JSP files in a web application. It has - two subelements, taglib and jsp-property-group. - - - - - - - - - - - - - - - - - - - The jsp-file element contains the full path to a JSP file - within the web application beginning with a `/'. - - - - - - - - - - - - - - - - The jsp-property-groupType is used to group a number of - files so they can be given global property information. - All files so described are deemed to be JSP files. The - following additional properties can be described: - - - Control whether EL is ignored - - Control whether scripting elements are invalid - - Indicate pageEncoding information. - - Indicate that a resource is a JSP document (XML) - - Prelude and Coda automatic includes. - - - - - - - - - - - - - Can be used to easily set the isELIgnored - property of a group of JSP pages. By default, the - EL evaluation is enabled for Web Applications using - a Servlet 2.4 or greater web.xml, and disabled - otherwise. - - - - - - - - - - The valid values of page-encoding are those of the - pageEncoding page directive. It is a - translation-time error to name different encodings - in the pageEncoding attribute of the page directive - of a JSP page and in a JSP configuration element - matching the page. It is also a translation-time - error to name different encodings in the prolog - or text declaration of a document in XML syntax and - in a JSP configuration element matching the document. - It is legal to name the same encoding through - mulitple mechanisms. - - - - - - - - - Can be used to easily disable scripting in a - group of JSP pages. By default, scripting is - enabled. - - - - - - - - - If true, denotes that the group of resources - that match the URL pattern are JSP documents, - and thus must be interpreted as XML documents. - If false, the resources are assumed to not - be JSP documents, unless there is another - property group that indicates otherwise. - - - - - - - - - - The include-prelude element is a context-relative - path that must correspond to an element in the - Web Application. When the element is present, - the given path will be automatically included (as - in an include directive) at the beginning of each - JSP page in this jsp-property-group. - - - - - - - - - - The include-coda element is a context-relative - path that must correspond to an element in the - Web Application. When the element is present, - the given path will be automatically included (as - in an include directive) at the end of each - JSP page in this jsp-property-group. - - - - - - - - - - - - - - - - The taglibType defines the syntax for declaring in - the deployment descriptor that a tag library is - available to the application. This can be done - to override implicit map entries from TLD files and - from the container. - - - - - - - - - - A taglib-uri element describes a URI identifying a - tag library used in the web application. The body - of the taglib-uri element may be either an - absolute URI specification, or a relative URI. - There should be no entries in web.xml with the - same taglib-uri value. - - - - - - - - - - the taglib-location element contains the location - (as a resource relative to the root of the web - application) where to find the Tag Library - Description file for the tag library. - - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/web-app_2_3.dtd b/exo.core.component.xml-processing/src/main/resources/dtd/web-app_2_3.dtd deleted file mode 100644 index 5e3ab01c0..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/web-app_2_3.dtd +++ /dev/null @@ -1,1063 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/web-app_2_4.xsd b/exo.core.component.xml-processing/src/main/resources/dtd/web-app_2_4.xsd deleted file mode 100644 index e49366205..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/web-app_2_4.xsd +++ /dev/null @@ -1,1279 +0,0 @@ - - - - - @(#)web-app_2_4.xsds 1.60 03/08/26 - - - - - - - Copyright 2003 Sun Microsystems, Inc., 901 San Antonio - Road, Palo Alto, California 94303, U.S.A. All rights - reserved. - - Sun Microsystems, Inc. has intellectual property rights - relating to technology described in this document. In - particular, and without limitation, these intellectual - property rights may include one or more of the U.S. patents - listed at http://www.sun.com/patents and one or more - additional patents or pending patent applications in the - U.S. and other countries. - - This document and the technology which it describes are - distributed under licenses restricting their use, copying, - distribution, and decompilation. No part of this document - may be reproduced in any form by any means without prior - written authorization of Sun and its licensors, if any. - - Third-party software, including font technology, is - copyrighted and licensed from Sun suppliers. - - Sun, Sun Microsystems, the Sun logo, Solaris, Java, J2EE, - JavaServer Pages, Enterprise JavaBeans and the Java Coffee - Cup logo are trademarks or registered trademarks of Sun - Microsystems, Inc. in the U.S. and other countries. - - Federal Acquisitions: Commercial Software - Government Users - Subject to Standard License Terms and Conditions. - - - - - - - - ... - - - The instance documents may indicate the published version of - the schema using the xsi:schemaLocation attribute for J2EE - namespace with the following location: - - http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd - - ]]> - - - - - - - - The following conventions apply to all J2EE - deployment descriptor elements unless indicated otherwise. - - - In elements that specify a pathname to a file within the - same JAR file, relative filenames (i.e., those not - starting with "/") are considered relative to the root of - the JAR file's namespace. Absolute filenames (i.e., those - starting with "/") also specify names in the root of the - JAR file's namespace. In general, relative names are - preferred. The exception is .war files where absolute - names are preferred for consistency with the Servlet API. - - - - - - - - - - - - - - - - The web-app element is the root of the deployment - descriptor for a web application. Note that the sub-elements - of this element can be in the arbitrary order. Because of - that, the multiplicity of the elements of distributable, - session-config, welcome-file-list, jsp-config, login-config, - and locale-encoding-mapping-list was changed from "?" to "*" - in this schema. However, the deployment descriptor instance - file must not contain multiple elements of session-config, - jsp-config, and login-config. When there are multiple elements of - welcome-file-list or locale-encoding-mapping-list, the container - must concatinate the element contents. The multiple occurance - of the element distributable is redundant and the container - treats that case exactly in the same way when there is only - one distributable. - - - - - - - - - The servlet element contains the name of a servlet. - The name must be unique within the web application. - - - - - - - - - - - - - The filter element contains the name of a filter. - The name must be unique within the web application. - - - - - - - - - - - - - The ejb-local-ref-name element contains the name of an EJB - reference. The EJB reference is an entry in the web - application's environment and is relative to the - java:comp/env context. The name must be unique within - the web application. - - It is recommended that name is prefixed with "ejb/". - - - - - - - - - - - - - The ejb-ref-name element contains the name of an EJB - reference. The EJB reference is an entry in the web - application's environment and is relative to the - java:comp/env context. The name must be unique within - the web application. - - It is recommended that name is prefixed with "ejb/". - - - - - - - - - - - - - The resource-env-ref-name element specifies the name of - a resource environment reference; its value is the - environment entry name used in the web application code. - The name is a JNDI name relative to the java:comp/env - context and must be unique within a web application. - - - - - - - - - - - - - The message-destination-ref-name element specifies the name of - a message destination reference; its value is the - environment entry name used in the web application code. - The name is a JNDI name relative to the java:comp/env - context and must be unique within a web application. - - - - - - - - - - - - - The res-ref-name element specifies the name of a - resource manager connection factory reference. The name - is a JNDI name relative to the java:comp/env context. - The name must be unique within a web application. - - - - - - - - - - - - - The env-entry-name element contains the name of a web - application's environment entry. The name is a JNDI - name relative to the java:comp/env context. The name - must be unique within a web application. - - - - - - - - - - - - - - A role-name-key is specified to allow the references - from the security-role-refs. - - - - - - - - - - - - The keyref indicates the references from - security-role-ref to a specified role-name. - - - - - - - - - - - - - - - - The auth-constraintType indicates the user roles that - should be permitted access to this resource - collection. The role-name used here must either correspond - to the role-name of one of the security-role elements - defined for this web application, or be the specially - reserved role-name "*" that is a compact syntax for - indicating all roles in the web application. If both "*" - and rolenames appear, the container interprets this as all - roles. If no roles are defined, no user is allowed access - to the portion of the web application described by the - containing security-constraint. The container matches - role names case sensitively when determining access. - - - - - - - - - - - - - - - - - - - The auth-methodType is used to configure the authentication - mechanism for the web application. As a prerequisite to - gaining access to any web resources which are protected by - an authorization constraint, a user must have authenticated - using the configured mechanism. Legal values are "BASIC", - "DIGEST", "FORM", "CLIENT-CERT", or a vendor-specific - authentication scheme. - - Used in: login-config - - - - - - - - - - - - - - - - The dispatcher has four legal values: FORWARD, REQUEST, INCLUDE, - and ERROR. A value of FORWARD means the Filter will be applied - under RequestDispatcher.forward() calls. A value of REQUEST - means the Filter will be applied under ordinary client calls to - the path or servlet. A value of INCLUDE means the Filter will be - applied under RequestDispatcher.include() calls. A value of - ERROR means the Filter will be applied under the error page - mechanism. The absence of any dispatcher elements in a - filter-mapping indicates a default of applying filters only under - ordinary client calls to the path or servlet. - - - - - - - - - - - - - - - - - - - - - - The encodingType defines IANA character sets. - - - - - - - - - - - - - - - - - The error-code contains an HTTP error code, ex: 404 - - Used in: error-page - - - - - - - - - - - - - - - - - - - - The error-pageType contains a mapping between an error code - or exception type to the path of a resource in the web - application. - - Used in: web-app - - - - - - - - - - - - - - The exception-type contains a fully qualified class - name of a Java exception type. - - - - - - - - - - - - The location element contains the location of the - resource in the web application relative to the root of - the web application. The value of the location must have - a leading `/'. - - - - - - - - - - - - - - - - Declaration of the filter mappings in this web - application is done by using filter-mappingType. - The container uses the filter-mapping - declarations to decide which filters to apply to a request, - and in what order. The container matches the request URI to - a Servlet in the normal way. To determine which filters to - apply it matches filter-mapping declarations either on - servlet-name, or on url-pattern for each filter-mapping - element, depending on which style is used. The order in - which filters are invoked is the order in which - filter-mapping declarations that match a request URI for a - servlet appear in the list of filter-mapping elements.The - filter-name value must be the value of the filter-name - sub-elements of one of the filter declarations in the - deployment descriptor. - - - - - - - - - - - - - - - - - - - - - - - - The logical name of the filter is declare - by using filter-nameType. This name is used to map the - filter. Each filter name is unique within the web - application. - - Used in: filter, filter-mapping - - - - - - - - - - - - - - - - The filterType is used to declare a filter in the web - application. The filter is mapped to either a servlet or a - URL pattern in the filter-mapping element, using the - filter-name value to reference. Filters can access the - initialization parameters declared in the deployment - descriptor at runtime via the FilterConfig interface. - - Used in: web-app - - - - - - - - - - - - - The fully qualified classname of the filter. - - - - - - - - - - The init-param element contains a name/value pair as - an initialization param of a servlet filter - - - - - - - - - - - - - - - - The form-login-configType specifies the login and error - pages that should be used in form based login. If form based - authentication is not used, these elements are ignored. - - Used in: login-config - - - - - - - - - - - - The form-login-page element defines the location in the web - app where the page that can be used for login can be - found. The path begins with a leading / and is interpreted - relative to the root of the WAR. - - - - - - - - - - - The form-error-page element defines the location in - the web app where the error page that is displayed - when login is not successful can be found. - The path begins with a leading / and is interpreted - relative to the root of the WAR. - - - - - - - - - - - - - - - - - The http-method contains an HTTP method recognized by the - web-app, for example GET, POST, ... - - - - - - - - - - - - - - - - - - - - - - - - - The locale-encoding-mapping-list contains one or more - locale-encoding-mapping(s). - - - - - - - - - - - - - - - - - - The locale-encoding-mapping contains locale name and - encoding name. The locale name must be either "Language-code", - such as "ja", defined by ISO-639 or "Language-code_Country-code", - such as "ja_JP". "Country code" is defined by ISO-3166. - - - - - - - - - - - - - - - - - - - The localeType defines valid locale defined by ISO-639-1 - and ISO-3166. - - - - - - - - - - - - - - - - - The login-configType is used to configure the authentication - method that should be used, the realm name that should be - used for this application, and the attributes that are - needed by the form login mechanism. - - Used in: web-app - - - - - - - - - - - - The realm name element specifies the realm name to - use in HTTP Basic authorization. - - - - - - - - - - - - - - - - - - The mime-mappingType defines a mapping between an extension - and a mime type. - - Used in: web-app - - - - - - - - - The extension element contains a string describing an - extension. example: "txt" - - - - - - - - - - - - - - - - - The mime-typeType is used to indicate a defined mime type. - - Example: - "text/plain" - - Used in: mime-mapping - - - - - - - - - - - - - - - - - - - This type defines a string which contains at least one - character. - - - - - - - - - - - - - - - - - The security-constraintType is used to associate - security constraints with one or more web resource - collections - - Used in: web-app - - - - - - - - - - - - - - - - - - - - The servlet-mappingType defines a mapping between a - servlet and a url pattern. - - Used in: web-app - - - - - - - - - - - - - - - - - - - - The servlet-name element contains the canonical name of the - servlet. Each servlet name is unique within the web - application. - - - - - - - - - - - - - - - - The servletType is used to declare a servlet. - It contains the declarative data of a - servlet. If a jsp-file is specified and the load-on-startup - element is present, then the JSP should be precompiled and - loaded. - - Used in: web-app - - - - - - - - - - - - - - The servlet-class element contains the fully - qualified class name of the servlet. - - - - - - - - - - - - - - - - The load-on-startup element indicates that this - servlet should be loaded (instantiated and have - its init() called) on the startup of the web - application. The optional contents of these - element must be an integer indicating the order in - which the servlet should be loaded. If the value - is a negative integer, or the element is not - present, the container is free to load the servlet - whenever it chooses. If the value is a positive - integer or 0, the container must load and - initialize the servlet as the application is - deployed. The container must guarantee that - servlets marked with lower integers are loaded - before servlets marked with higher integers. The - container may choose the order of loading of - servlets with the same load-on-start-up value. - - - - - - - - - - - - - - - - - The session-configType defines the session parameters - for this web application. - - Used in: web-app - - - - - - - - - - - The session-timeout element defines the default - session timeout interval for all sessions created - in this web application. The specified timeout - must be expressed in a whole number of minutes. - If the timeout is 0 or less, the container ensures - the default behaviour of sessions is never to time - out. If this element is not specified, the container - must set its default timeout period. - - - - - - - - - - - - - - - - The transport-guaranteeType specifies that the communication - between client and server should be NONE, INTEGRAL, or - CONFIDENTIAL. NONE means that the application does not - require any transport guarantees. A value of INTEGRAL means - that the application requires that the data sent between the - client and server be sent in such a way that it can't be - changed in transit. CONFIDENTIAL means that the application - requires that the data be transmitted in a fashion that - prevents other entities from observing the contents of the - transmission. In most cases, the presence of the INTEGRAL or - CONFIDENTIAL flag will indicate that the use of SSL is - required. - - Used in: user-data-constraint - - - - - - - - - - - - - - - - - - - - The user-data-constraintType is used to indicate how - data communicated between the client and container should be - protected. - - Used in: security-constraint - - - - - - - - - - - - - - - - - - - - The elements that use this type designate a path starting - with a "/" and interpreted relative to the root of a WAR - file. - - - - - - - - - - - - - - - - - - This type contains the recognized versions of - web-application supported. It is used to designate the - version of the web application. - - - - - - - - - - - - - - - - - - - - - - - The context-param element contains the declaration - of a web application's servlet context - initialization parameters. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The web-resource-collectionType is used to identify a subset - of the resources and HTTP methods on those resources within - a web application to which a security constraint applies. If - no HTTP methods are specified, then the security constraint - applies to all HTTP methods. - - Used in: security-constraint - - - - - - - - - - The web-resource-name contains the name of this web - resource collection. - - - - - - - - - - - - - - - - - - - The welcome-file-list contains an ordered list of welcome - files elements. - - Used in: web-app - - - - - - - - - - - The welcome-file element contains file name to use - as a default welcome file, such as index.html - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/xhtml-lat1.ent b/exo.core.component.xml-processing/src/main/resources/dtd/xhtml-lat1.ent deleted file mode 100644 index ffee223eb..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/xhtml-lat1.ent +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/xhtml-special.ent b/exo.core.component.xml-processing/src/main/resources/dtd/xhtml-special.ent deleted file mode 100644 index ca358b2fe..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/xhtml-special.ent +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/xhtml-symbol.ent b/exo.core.component.xml-processing/src/main/resources/dtd/xhtml-symbol.ent deleted file mode 100644 index 63c2abfa6..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/xhtml-symbol.ent +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/xhtml1-frameset.dtd b/exo.core.component.xml-processing/src/main/resources/dtd/xhtml1-frameset.dtd deleted file mode 100644 index b22e50705..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/xhtml1-frameset.dtd +++ /dev/null @@ -1,1235 +0,0 @@ - - - - - -%HTMLlat1; - - -%HTMLsymbol; - - -%HTMLspecial; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/xhtml1-strict.dtd b/exo.core.component.xml-processing/src/main/resources/dtd/xhtml1-strict.dtd deleted file mode 100644 index 9f1095d31..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/xhtml1-strict.dtd +++ /dev/null @@ -1,978 +0,0 @@ - - - - - -%HTMLlat1; - - -%HTMLsymbol; - - -%HTMLspecial; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/xhtml1-transitional.dtd b/exo.core.component.xml-processing/src/main/resources/dtd/xhtml1-transitional.dtd deleted file mode 100644 index a182723be..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/xhtml1-transitional.dtd +++ /dev/null @@ -1,1201 +0,0 @@ - - - - - -%HTMLlat1; - - -%HTMLsymbol; - - -%HTMLspecial; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/main/resources/dtd/xml.xsd b/exo.core.component.xml-processing/src/main/resources/dtd/xml.xsd deleted file mode 100644 index f82cdabd7..000000000 --- a/exo.core.component.xml-processing/src/main/resources/dtd/xml.xsd +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - See http://www.w3.org/XML/1998/namespace.html and - http://www.w3.org/TR/REC-xml for information about this namespace. - - This schema document describes the XML namespace, in a form - suitable for import by other schema documents. - - Note that local names in this namespace are intended to be defined - only by the World Wide Web Consortium or its subgroups. The - following names are currently defined in this namespace and should - not be used with conflicting semantics by any Working Group, - specification, or document instance: - - base (as an attribute name): denotes an attribute whose value - provides a URI to be used as the base for interpreting any - relative URIs in the scope of the element on which it - appears; its value is inherited. This name is reserved - by virtue of its definition in the XML Base specification. - - lang (as an attribute name): denotes an attribute whose value - is a language code for the natural language of the content of - any element; its value is inherited. This name is reserved - by virtue of its definition in the XML specification. - - space (as an attribute name): denotes an attribute whose - value is a keyword indicating what whitespace processing - discipline is intended for the content of the element; its - value is inherited. This name is reserved by virtue of its - definition in the XML specification. - - Father (in any context at all): denotes Jon Bosak, the chair of - the original XML Working Group. This name is reserved by - the following decision of the W3C XML Plenary and - XML Coordination groups: - - In appreciation for his vision, leadership and dedication - the W3C XML Plenary on this 10th day of February, 2000 - reserves for Jon Bosak in perpetuity the XML name - xml:Father - - - - - This schema defines attributes and an attribute group - suitable for use by - schemas wishing to allow xml:base, xml:lang or xml:space attributes - on elements they define. - - To enable this, such a schema must import this schema - for the XML namespace, e.g. as follows: - <schema . . .> - . . . - <import namespace="http://www.w3.org/XML/1998/namespace" - schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> - - Subsequently, qualified reference to any of the attributes - or the group defined below will have the desired effect, e.g. - - <type . . .> - . . . - <attributeGroup ref="xml:specialAttrs"/> - - will define a type which will schema-validate an instance - element with any of those attributes - - - - - In keeping with the XML Schema WG's standard versioning - policy, this schema document will persist at - http://www.w3.org/2001/03/xml.xsd. - At the date of issue it can also be found at - http://www.w3.org/2001/xml.xsd. - The schema document at that URI may however change in the future, - in order to remain compatible with the latest version of XML Schema - itself. In other words, if the XML Schema namespace changes, the version - of this document at - http://www.w3.org/2001/xml.xsd will change - accordingly; the version at - http://www.w3.org/2001/03/xml.xsd will not change. - - - - - - In due course, we should install the relevant ISO 2- and 3-letter - codes as the enumerated possible values . . . - - - - - - - - - - - - - - - - - See http://www.w3.org/TR/xmlbase/ for - information about this attribute. - - - - - - - - - - \ No newline at end of file diff --git a/exo.core.component.xml-processing/src/main/resources/xslt/html-url-rewite.xsl b/exo.core.component.xml-processing/src/main/resources/xslt/html-url-rewite.xsl deleted file mode 100644 index 09da7429f..000000000 --- a/exo.core.component.xml-processing/src/main/resources/xslt/html-url-rewite.xsl +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - - - - url - - - - - - - - - - - - - - - - Parameter list: - portalURI=[ - - ] portletURI=[ - - ] param-name=[ - - ] portalContextPath =[ - - ] portalQueryString =[ - - ] paramNamespace =[ - - ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *begin**********Auto added fields*********[new url= - - - - *end**********Auto added fields********* - - - - - - - - - - - - - - - hidden - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - / - - - - - ? - - - & - - - - - = - - - - - - diff --git a/exo.core.component.xml-processing/src/test/java/org/exoplatform/services/xml/BaseTest.java b/exo.core.component.xml-processing/src/test/java/org/exoplatform/services/xml/BaseTest.java deleted file mode 100644 index 6b4f44aaf..000000000 --- a/exo.core.component.xml-processing/src/test/java/org/exoplatform/services/xml/BaseTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml; - -import junit.framework.TestCase; - -import org.exoplatform.container.StandaloneContainer; -import org.exoplatform.services.xml.resolving.XMLResolvingService; -import org.xml.sax.InputSource; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; - -import java.io.InputStream; -import java.net.URL; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * Created by the Exo Development team. Base transformer test - */ -public abstract class BaseTest extends TestCase -{ - private final String DATE_PATTERN = "yy-MM-DD_HH-mm-ss"; - - private DateFormat dateFormat; - - protected String getTimeStamp() - { - return dateFormat.format(new Date()); - } - - protected InputStream resourceStream(String name) - { - return Thread.currentThread().getContextClassLoader().getResourceAsStream(name); - } - - public BaseTest() - { - dateFormat = new SimpleDateFormat(DATE_PATTERN); - } - - protected void validateXML(InputStream input) throws Exception - { - StandaloneContainer.setConfigurationPath("src/test/resources/conf/standalone/test-configuration.xml"); - StandaloneContainer container = StandaloneContainer.getInstance(); - - XMLResolvingService resolvingService = - (XMLResolvingService)container.getComponentInstanceOfType(XMLResolvingService.class); - assertNotNull("XMLResolvingService", resolvingService); - - XMLReader xmlReader = XMLReaderFactory.createXMLReader(); - xmlReader.setEntityResolver(resolvingService.getEntityResolver()); - - assertNotNull("resolvingService.getEntityResolver()", resolvingService.getEntityResolver()); - - InputSource src = - resolvingService.getEntityResolver().resolveEntity("-//W3C//DTD XHTML 1.0 Transitional//EN", - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"); - - assertNotNull("Not resolved InputSource entity", src); - - xmlReader.setFeature("http://xml.org/sax/features/validation", true); // validation - // on - // transform - try - { - xmlReader.parse(new InputSource(input)); - } - catch (org.xml.sax.SAXParseException ex) - { - fail("Document is not valid XML. See: \n" + ex.getMessage()); - } - } - -} diff --git a/exo.core.component.xml-processing/src/test/java/org/exoplatform/services/xml/resolving/impl/TestXMLResolver.java b/exo.core.component.xml-processing/src/test/java/org/exoplatform/services/xml/resolving/impl/TestXMLResolver.java deleted file mode 100644 index c74211a97..000000000 --- a/exo.core.component.xml-processing/src/test/java/org/exoplatform/services/xml/resolving/impl/TestXMLResolver.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.resolving.impl; - -import org.exoplatform.container.StandaloneContainer; -import org.exoplatform.services.xml.BaseTest; -import org.exoplatform.services.xml.resolving.XMLResolvingService; -import org.xml.sax.InputSource; - -/** - * Created by the Exo Development team. - */ -public class TestXMLResolver extends BaseTest -{ - - private XMLResolvingService service; - - public void setUp() throws Exception - { - if (service == null) - { - StandaloneContainer.setConfigurationPath("src/test/resources/conf/standalone/test-configuration.xml"); - StandaloneContainer container = StandaloneContainer.getInstance(); - service = (XMLResolvingService)container.getComponentInstanceOfType(XMLResolvingService.class); - } - } - - public void testLookupFailed() throws Exception - { - javax.xml.parsers.SAXParserFactory factory = javax.xml.parsers.SAXParserFactory.newInstance(); - factory.setNamespaceAware(true); - javax.xml.parsers.SAXParser jaxpParser = factory.newSAXParser(); - org.xml.sax.XMLReader reader = jaxpParser.getXMLReader(); - - reader.setEntityResolver(service.getEntityResolver()); - try - { - reader.parse(new InputSource(resourceStream("tmp/dtd-not-found.xml"))); - - } - catch (Throwable e) - { - return; - } - fail("Lookup should have been Failed as there is not such local DTD."); - } - - public void testWebXmlResolving() throws Exception - { - try - { - - javax.xml.parsers.SAXParserFactory factory = javax.xml.parsers.SAXParserFactory.newInstance(); - factory.setNamespaceAware(true); - javax.xml.parsers.SAXParser jaxpParser = factory.newSAXParser(); - org.xml.sax.XMLReader reader = jaxpParser.getXMLReader(); - - reader.setEntityResolver(service.getEntityResolver()); - - reader.parse(new InputSource(resourceStream("web.xml"))); - - } - catch (Exception e) - { - - fail("testWebXmlResolving() ERROR: " + e.toString()); - } - - } - -} diff --git a/exo.core.component.xml-processing/src/test/java/org/exoplatform/services/xml/transform/TestTemplates.java b/exo.core.component.xml-processing/src/test/java/org/exoplatform/services/xml/transform/TestTemplates.java deleted file mode 100644 index 48ddff267..000000000 --- a/exo.core.component.xml-processing/src/test/java/org/exoplatform/services/xml/transform/TestTemplates.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform; - -import org.exoplatform.container.StandaloneContainer; -import org.exoplatform.services.xml.BaseTest; -import org.exoplatform.services.xml.transform.trax.TRAXTemplatesService; - -/** - * @author Andrey Parfonov - * @version $Id: $ - */ -public class TestTemplates extends BaseTest -{ - - private TRAXTemplatesService traxTemplatesService; - - public void setUp() throws Exception - { - StandaloneContainer.setConfigurationPath("src/test/resources/conf/standalone/test-configuration.xml"); - StandaloneContainer container = StandaloneContainer.getInstance(); - traxTemplatesService = (TRAXTemplatesService)container.getComponentInstanceOfType(TRAXTemplatesService.class); - assertNotNull("traxTemplatesService", traxTemplatesService); - } - - public void testTemplates() - { - assertNotNull(traxTemplatesService.getTemplates("xslt1")); - } - -} diff --git a/exo.core.component.xml-processing/src/test/java/org/exoplatform/services/xml/transform/TestXsl.java b/exo.core.component.xml-processing/src/test/java/org/exoplatform/services/xml/transform/TestXsl.java deleted file mode 100644 index 667538cd4..000000000 --- a/exo.core.component.xml-processing/src/test/java/org/exoplatform/services/xml/transform/TestXsl.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (C) 2009 eXo Platform SAS. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.exoplatform.services.xml.transform; - -import org.exoplatform.container.StandaloneContainer; -import org.exoplatform.services.xml.BaseTest; -import org.exoplatform.services.xml.transform.trax.TRAXTemplates; -import org.exoplatform.services.xml.transform.trax.TRAXTransformer; -import org.exoplatform.services.xml.transform.trax.TRAXTransformerService; - -import java.io.*; - -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.stream.StreamSource; - -/** - * Created by the Exo Development team. - */ -public class TestXsl extends BaseTest -{ - private TRAXTransformerService traxService; - - public void setUp() throws Exception - { - StandaloneContainer.setConfigurationPath("src/test/resources/conf/standalone/test-configuration.xml"); - StandaloneContainer container = StandaloneContainer.getInstance(); - traxService = (TRAXTransformerService)container.getComponentInstanceOfType(TRAXTransformerService.class); - assertNotNull("traxService", traxService); - } - - public void testSimpleXslt() throws Exception - { - InputStream res = resourceStream("rss-in.xhtml"); - File outputFile = File.createTempFile("rss-out-", ".xml"); - outputFile.deleteOnExit(); - - assertTrue("Empty input file", res.available() > 0); - - // output file - OutputStream outputFileOutputStream = new FileOutputStream(outputFile); - - // get xsl - InputStream xslInputStream = resourceStream("html-url-rewite.xsl"); - assertNotNull("empty xsl", xslInputStream); - Source xslSource = new StreamSource(xslInputStream); - assertNotNull("get xsl source", xslSource); - - // init transformer - TRAXTransformer traxTransformer = traxService.getTransformer(xslSource); - assertNotNull("get transformer", traxTransformer); - - traxTransformer.initResult(new StreamResult(outputFileOutputStream)); - traxTransformer.transform(new StreamSource(res)); - - res.close(); - outputFileOutputStream.close(); - - // read the output file - FileInputStream outputFileInputStream = new FileInputStream(outputFile); - - assertTrue("Output is empty", outputFileInputStream.available() > 0); - outputFileInputStream.close(); - - } - - public void testXsltUseTemplates() throws Exception - { - InputStream res = resourceStream("rss-in.xhtml"); - - assertTrue("Empty input file", res.available() > 0); - - // output - ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream(); - - // get xsl - InputStream xslInputStream = resourceStream("html-url-rewite.xsl"); - assertNotNull("empty xsl", xslInputStream); - Source xslSource = new StreamSource(xslInputStream); - assertNotNull("get xsl source", xslSource); - - // init templates - TRAXTemplates traxTemplates = traxService.getTemplates(xslSource); - assertNotNull("get templates", traxTemplates); - - // get transformer - TRAXTransformer traxTransformer = traxTemplates.newTransformer(); - assertNotNull("get transformer", traxTransformer); - - // transform - traxTransformer.initResult(new StreamResult(byteOutputStream)); - traxTransformer.transform(new StreamSource(res)); - res.close(); - - assertTrue("Output is empty", byteOutputStream.size() > 0); - - // other transformer from same templates - - TRAXTransformer traxOtherTransformer = traxTemplates.newTransformer(); - assertNotNull("get Other transformer", traxOtherTransformer); - - res = resourceStream("rss-in.xhtml"); - - assertTrue("Empty input other file", res.available() > 0); - - ByteArrayOutputStream byteOtherOutputStream = new ByteArrayOutputStream(); - - traxOtherTransformer.initResult(new StreamResult(byteOtherOutputStream)); - traxOtherTransformer.transform(new StreamSource(res)); - res.close(); - assertTrue("Output other is empty", byteOutputStream.size() > 0); - - } - -} diff --git a/exo.core.component.xml-processing/src/test/resources/conf/standalone/test-configuration.xml b/exo.core.component.xml-processing/src/test/resources/conf/standalone/test-configuration.xml deleted file mode 100644 index 8c6af5b94..000000000 --- a/exo.core.component.xml-processing/src/test/resources/conf/standalone/test-configuration.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - org.exoplatform.services.log.LogConfigurationInitializer - org.exoplatform.services.log.LogConfigurationInitializer - - - logger - org.exoplatform.services.log.impl.BufferedLog4JLogger - - - configurator - org.exoplatform.services.log.impl.SimpleExoLogConfigurator - - - - - - org.exoplatform.services.xml.resolving.impl.XMLResolvingServiceImpl - - - add.resolving.table - addPlugin - org.exoplatform.services.xml.resolving.impl.AddXMLResolvingContextPlugin - - - dtd1 - - - - - - dtd2 - - - - - - - - - - - org.exoplatform.services.xml.transform.impl.trax.TRAXTransformerServiceImpl - - - org.exoplatform.services.xml.transform.impl.trax.TRAXTemplatesServiceImpl - - - add.xslschema - addPlugin - org.exoplatform.services.xml.transform.impl.trax.TRAXTemplatesLoaderPlugin - - - xsl-source-urls - - - - - - - - org.exoplatform.services.xml.transform.impl.EncodingMapImpl - - diff --git a/exo.core.component.xml-processing/src/test/resources/dtd-not-found.xml b/exo.core.component.xml-processing/src/test/resources/dtd-not-found.xml deleted file mode 100644 index 79b3b23f3..000000000 --- a/exo.core.component.xml-processing/src/test/resources/dtd-not-found.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - diff --git a/exo.core.component.xml-processing/src/test/resources/html-url-rewite.xsl b/exo.core.component.xml-processing/src/test/resources/html-url-rewite.xsl deleted file mode 100644 index 09da7429f..000000000 --- a/exo.core.component.xml-processing/src/test/resources/html-url-rewite.xsl +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - - - - url - - - - - - - - - - - - - - - - Parameter list: - portalURI=[ - - ] portletURI=[ - - ] param-name=[ - - ] portalContextPath =[ - - ] portalQueryString =[ - - ] paramNamespace =[ - - ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *begin**********Auto added fields*********[new url= - - - - *end**********Auto added fields********* - - - - - - - - - - - - - - - hidden - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - / - - - - - ? - - - & - - - - - = - - - - - - diff --git a/exo.core.component.xml-processing/src/test/resources/rss-in.html b/exo.core.component.xml-processing/src/test/resources/rss-in.html deleted file mode 100644 index 6f0730683..000000000 --- a/exo.core.component.xml-processing/src/test/resources/rss-in.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-Current News from Slashdot -
-
25,000-Ton Amphibious Spam Relay111timothy2003-12-17 19:53:00
Gloolabs Readies A Java-Based WiFi Audio Device193timothy2003-12-17 19:04:00
Microsoft's New Core OS Team Learning from Linux201CmdrTaco2003-12-17 18:16:00
3D Modelling From a Sketch134CmdrTaco2003-12-17 17:30:00
Server CE Database Development with .NET156timothy2003-12-17 16:30:00
City Of Austin Migrating To OpenOffice.org185timothy2003-12-17 15:32:00
Blockbuster Chief: End DVD Region Codes187timothy2003-12-17 14:38:00
55 Operating Systems On A PowerBook180timothy2003-12-17 13:43:00
(At Least) 100 Years Of Powered Human Flight126timothy2003-12-17 12:52:00
Israeli Gov't Begins Testing Mandrake Linux147timothy2003-12-17 09:20:00
- - diff --git a/exo.core.component.xml-processing/src/test/resources/rss-in.xhtml b/exo.core.component.xml-processing/src/test/resources/rss-in.xhtml deleted file mode 100644 index b750d3012..000000000 --- a/exo.core.component.xml-processing/src/test/resources/rss-in.xhtml +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
Current News -from Slashdot
-
25,000-Ton -Amphibious Spam Relay111timothy2003-12-17 19:53:00
Gloolabs Readies A -Java-Based WiFi Audio Device193timothy2003-12-17 19:04:00
Microsoft's New -Core OS Team Learning from Linux201CmdrTaco2003-12-17 18:16:00
3D Modelling From a -Sketch134CmdrTaco2003-12-17 17:30:00
Server CE Database -Development with .NET156timothy2003-12-17 16:30:00
City Of Austin -Migrating To OpenOffice.org185timothy2003-12-17 15:32:00
Blockbuster Chief: -End DVD Region Codes187timothy2003-12-17 14:38:00
55 Operating -Systems On A PowerBook180timothy2003-12-17 13:43:00
(At Least) 100 -Years Of Powered Human Flight126timothy2003-12-17 12:52:00
Israeli Gov't -Begins Testing Mandrake Linux147timothy2003-12-17 09:20:00
- - - diff --git a/exo.core.component.xml-processing/src/test/resources/test.policy b/exo.core.component.xml-processing/src/test/resources/test.policy deleted file mode 100644 index 0497820a2..000000000 --- a/exo.core.component.xml-processing/src/test/resources/test.policy +++ /dev/null @@ -1,11 +0,0 @@ -grant codeBase "@MAVEN_REPO@-"{ - permission java.security.AllPermission; -}; - -grant codeBase "@MAIN_CLASSES@-"{ - permission java.security.AllPermission; -}; - -grant codeBase "@TEST_CLASSES@-"{ - permission java.lang.RuntimePermission "accessClassInPackage.com.ibm.xtq.xml.xdm.ref"; -}; diff --git a/exo.core.component.xml-processing/src/test/resources/web-app_2_3.dtd b/exo.core.component.xml-processing/src/test/resources/web-app_2_3.dtd deleted file mode 100644 index 5e3ab01c0..000000000 --- a/exo.core.component.xml-processing/src/test/resources/web-app_2_3.dtd +++ /dev/null @@ -1,1063 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/exo.core.component.xml-processing/src/test/resources/web.xml b/exo.core.component.xml-processing/src/test/resources/web.xml deleted file mode 100644 index 074e553f3..000000000 --- a/exo.core.component.xml-processing/src/test/resources/web.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - HelloWorld - - This application is a portlet. It can not be used outside a portal. - This web.xml file is mandatory in each .par archive file. - - - - index.html - - - - portlet - /WEB-INF/tlds/portlet.tld - - diff --git a/pom.xml b/pom.xml index f83e5a49d..0f5f7e3b5 100644 --- a/pom.xml +++ b/pom.xml @@ -56,10 +56,7 @@ exo.core.component.security.core - exo.core.component.database - exo.core.component.script.groovy exo.core.component.organization.api - exo.core.component.xml-processing @@ -78,11 +75,6 @@ source-release zip - - io.meeds.core - exo.core.component.database - ${project.version} - io.meeds.core exo.core.component.organization.api @@ -93,16 +85,6 @@ exo.core.component.security.core ${project.version} - - io.meeds.core - exo.core.component.xml-processing - ${project.version} - - - io.meeds.core - exo.core.component.script.groovy - ${project.version} -