From do-not-reply at jboss.org Fri Sep 23 04:06:00 2011 Content-Type: multipart/mixed; boundary="===============0364691804273594415==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: exo-jcr-commits at lists.jboss.org Subject: [exo-jcr-commits] exo-jcr SVN: r4953 - core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exoplatform/services/organization/hibernate. Date: Fri, 23 Sep 2011 04:05:59 -0400 Message-ID: <201109230805.p8N85xZ5021364@svn01.web.mwc.hst.phx2.redhat.com> --===============0364691804273594415== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: tolusha Date: 2011-09-23 04:05:58 -0400 (Fri, 23 Sep 2011) New Revision: 4953 Removed: core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exopla= tform/services/organization/hibernate/HibernateUserListAccess.java core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exopla= tform/services/organization/hibernate/SimpleHibernateUserListAccess.java Log: EXOJCR-1492: Impove the method MembershipHandler.findAllMembershipsByGroup Deleted: core/trunk/exo.core.component.organization.jdbc/src/main/java/org/= exoplatform/services/organization/hibernate/HibernateUserListAccess.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exopl= atform/services/organization/hibernate/HibernateUserListAccess.java 2011-09= -23 08:03:43 UTC (rev 4952) +++ core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exopl= atform/services/organization/hibernate/HibernateUserListAccess.java 2011-09= -23 08:05:58 UTC (rev 4953) @@ -1,137 +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. - */ -/** - * = - */ -/* - * Copyright (C) 2003-2009 eXo Platform SAS. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see. - */ -package org.exoplatform.services.organization.hibernate; - -import org.exoplatform.commons.utils.ListAccess; -import org.exoplatform.services.database.HibernateService; -import org.exoplatform.services.organization.User; -import org.hibernate.Session; - -import java.util.HashMap; -import java.util.Map; - -/** - * Created by The eXo Platform SAS. - * = - * @author Anatoliy= Bazko - * @version $Id: HibernateUserListAccess.java 111 2008-11-11 11:11:11Z $ - */ -public abstract class HibernateUserListAccess implements ListAccess -{ - - /** - * The Hibernate Service. - */ - protected HibernateService service; - - /** - * Find query string. - */ - protected String findQuery; - - /** - * Count query string. - */ - protected String countQuery; - - /** - * Binded fields. - */ - protected Map binding; - - /** - * HibernateUserListAccess constructor. - * = - * @param service - * The Hibernate Service. - * @param findQuery - * Find query string - * @param countQuery - * Count query string - */ - public HibernateUserListAccess(HibernateService service, String findQue= ry, String countQuery) - { - this.service =3D service; - this.findQuery =3D findQuery; - this.countQuery =3D countQuery; - this.binding =3D new HashMap(); - } - - /** - * HibernateUserListAccess constructor. - * = - * @param service - * The Hibernate Service. - * @param findQuery - * Find query string - * @param countQuery - * Count query string - * @param binding - * Binded fields - */ - public HibernateUserListAccess(HibernateService service, String findQue= ry, String countQuery, - Map binding) - { - this.service =3D service; - this.findQuery =3D findQuery; - this.countQuery =3D countQuery; - this.binding =3D binding; - } - - /** - * {@inheritDoc} - */ - public int getSize() throws Exception - { - Session session =3D service.openSession(); - return getSize(session); - } - - /** - * {@inheritDoc} - */ - public User[] load(int index, int length) throws Exception, IllegalArgu= mentException - { - Session session =3D service.openSession(); - return load(session, index, length); - } - - protected abstract User[] load(Session session, int index, int length) = throws Exception; - - protected abstract int getSize(Session session) throws Exception; -} Deleted: core/trunk/exo.core.component.organization.jdbc/src/main/java/org/= exoplatform/services/organization/hibernate/SimpleHibernateUserListAccess.j= ava =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exopl= atform/services/organization/hibernate/SimpleHibernateUserListAccess.java 2= 011-09-23 08:03:43 UTC (rev 4952) +++ core/trunk/exo.core.component.organization.jdbc/src/main/java/org/exopl= atform/services/organization/hibernate/SimpleHibernateUserListAccess.java 2= 011-09-23 08:05:58 UTC (rev 4953) @@ -1,171 +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. - */ -/** - * = - */ -/* - * Copyright (C) 2003-2009 eXo Platform SAS. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License - * as published by the Free Software Foundation; either version 3 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see. - */ -package org.exoplatform.services.organization.hibernate; - -import org.exoplatform.commons.utils.SecurityHelper; -import org.exoplatform.services.database.HibernateService; -import org.exoplatform.services.organization.User; -import org.hibernate.Query; -import org.hibernate.Session; - -import java.security.PrivilegedAction; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * Created by The eXo Platform SAS. - * = - * @author Anatoliy= Bazko - * @version $Id: SimpliHibernateUserListAccess.java 111 2008-11-11 11:11:1= 1Z $ - */ -public class SimpleHibernateUserListAccess extends HibernateUserListAccess -{ - - /** - * SimpliHibernateUserListAccess constructor. - * = - * @param service - * The Hibernate Service. - * @param findQuery - * Find query string - * @param countQuery - * Count query string - */ - public SimpleHibernateUserListAccess(HibernateService service, String f= indQuery, String countQuery) - { - super(service, findQuery, countQuery); - } - - /** - * SimpliHibernateUserListAccess constructor. - * = - * @param service - * The Hibernate Service. - * @param findQuery - * Find query string - * @param countQuery - * Count query string - * @param binding - * Binded fields - */ - public SimpleHibernateUserListAccess(HibernateService service, String f= indQuery, String countQuery, - Map binding) - { - super(service, findQuery, countQuery, binding); - } - - /** - * {@inheritDoc} - */ - @Override - protected int getSize(final Session session) throws Exception - { - Query query =3D SecurityHelper.doPrivilegedAction(new PrivilegedActi= on() - { - public Query run() - { - return session.createQuery(countQuery); - } - }); - = - bindFields(query); - - List l =3D query.list(); - Number count =3D (Number)l.get(0); - - return count.intValue(); - } - - /** - * {@inheritDoc} - */ - @Override - protected User[] load(final Session session, int index, int length) thr= ows Exception - { - if (index < 0) - throw new IllegalArgumentException("Illegal index: index must be = a positive number"); - - if (length < 0) - throw new IllegalArgumentException("Illegal length: length must b= e a positive number"); - - User[] users =3D new User[length]; - - Query query =3D SecurityHelper.doPrivilegedAction(new PrivilegedActi= on() - { - public Query run() - { - return session.createQuery(findQuery); - } - }); - bindFields(query); - - Iterator results =3D query.iterate(); - for (int p =3D 0, counter =3D 0; counter < length; p++) - { - if (!results.hasNext()) - throw new IllegalArgumentException( - "Illegal index or length: sum of the index and the length c= annot be greater than the list size"); - - Object result =3D results.next(); - - if (p >=3D index) - { - users[counter++] =3D (User)result; - } - } - - return users; - } - - /** - * BindFields. - * = - * @param query - * Query - */ - private void bindFields(Query query) - { - for (Entry entry : binding.entrySet()) - { - query.setParameter(entry.getKey(), entry.getValue()); - } - } - -} --===============0364691804273594415==--