--- /dev/null
+/**
+ * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
+ *
+ * This library 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 library 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.
+ */
+
+package com.pentila.entSavoie.userProperties.service.persistence;
+
+import com.liferay.portal.NoSuchModelException;
+import com.liferay.portal.kernel.bean.BeanReference;
+import com.liferay.portal.kernel.cache.CacheRegistryUtil;
+import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
+import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
+import com.liferay.portal.kernel.dao.orm.FinderPath;
+import com.liferay.portal.kernel.dao.orm.Query;
+import com.liferay.portal.kernel.dao.orm.QueryPos;
+import com.liferay.portal.kernel.dao.orm.QueryUtil;
+import com.liferay.portal.kernel.dao.orm.Session;
+import com.liferay.portal.kernel.exception.SystemException;
+import com.liferay.portal.kernel.log.Log;
+import com.liferay.portal.kernel.log.LogFactoryUtil;
+import com.liferay.portal.kernel.portlet.PortletClassLoaderUtil;
+import com.liferay.portal.kernel.util.GetterUtil;
+import com.liferay.portal.kernel.util.InstanceFactory;
+import com.liferay.portal.kernel.util.OrderByComparator;
+import com.liferay.portal.kernel.util.PropsKeys;
+import com.liferay.portal.kernel.util.PropsUtil;
+import com.liferay.portal.kernel.util.StringBundler;
+import com.liferay.portal.kernel.util.StringPool;
+import com.liferay.portal.kernel.util.StringUtil;
+import com.liferay.portal.kernel.util.Validator;
+import com.liferay.portal.model.CacheModel;
+import com.liferay.portal.model.ModelListener;
+import com.liferay.portal.service.persistence.BatchSessionUtil;
+import com.liferay.portal.service.persistence.ResourcePersistence;
+import com.liferay.portal.service.persistence.UserPersistence;
+import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
+
+import com.pentila.entSavoie.userProperties.NoSuchInternalOauthException;
+import com.pentila.entSavoie.userProperties.model.InternalOauth;
+import com.pentila.entSavoie.userProperties.model.impl.InternalOauthImpl;
+import com.pentila.entSavoie.userProperties.model.impl.InternalOauthModelImpl;
+
+import java.io.Serializable;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * The persistence implementation for the internal oauth service.
+ *
+ * <p>
+ * Caching information and settings can be found in <code>portal.properties</code>
+ * </p>
+ *
+ * @author Amblard Mathieu - Barma Igor
+ * @see InternalOauthPersistence
+ * @see InternalOauthUtil
+ * @generated
+ */
+public class InternalOauthPersistenceImpl extends BasePersistenceImpl<InternalOauth>
+ implements InternalOauthPersistence {
+ /*
+ * NOTE FOR DEVELOPERS:
+ *
+ * Never modify or reference this class directly. Always use {@link InternalOauthUtil} to access the internal oauth persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
+ */
+ public static final String FINDER_CLASS_NAME_ENTITY = InternalOauthImpl.class.getName();
+ public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
+ ".List1";
+ public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
+ ".List2";
+ public static final FinderPath FINDER_PATH_FETCH_BY_TOKEN = new FinderPath(InternalOauthModelImpl.ENTITY_CACHE_ENABLED,
+ InternalOauthModelImpl.FINDER_CACHE_ENABLED,
+ InternalOauthImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchBytoken",
+ new String[] { String.class.getName() },
+ InternalOauthModelImpl.TOKEN_COLUMN_BITMASK);
+ public static final FinderPath FINDER_PATH_COUNT_BY_TOKEN = new FinderPath(InternalOauthModelImpl.ENTITY_CACHE_ENABLED,
+ InternalOauthModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBytoken",
+ new String[] { String.class.getName() });
+ public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(InternalOauthModelImpl.ENTITY_CACHE_ENABLED,
+ InternalOauthModelImpl.FINDER_CACHE_ENABLED,
+ InternalOauthImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
+ "findAll", new String[0]);
+ public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(InternalOauthModelImpl.ENTITY_CACHE_ENABLED,
+ InternalOauthModelImpl.FINDER_CACHE_ENABLED,
+ InternalOauthImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
+ "findAll", new String[0]);
+ public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(InternalOauthModelImpl.ENTITY_CACHE_ENABLED,
+ InternalOauthModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
+
+ /**
+ * Caches the internal oauth in the entity cache if it is enabled.
+ *
+ * @param internalOauth the internal oauth
+ */
+ public void cacheResult(InternalOauth internalOauth) {
+ EntityCacheUtil.putResult(InternalOauthModelImpl.ENTITY_CACHE_ENABLED,
+ InternalOauthImpl.class, internalOauth.getPrimaryKey(),
+ internalOauth);
+
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TOKEN,
+ new Object[] { internalOauth.getToken() }, internalOauth);
+
+ internalOauth.resetOriginalValues();
+ }
+
+ /**
+ * Caches the internal oauths in the entity cache if it is enabled.
+ *
+ * @param internalOauths the internal oauths
+ */
+ public void cacheResult(List<InternalOauth> internalOauths) {
+ for (InternalOauth internalOauth : internalOauths) {
+ if (EntityCacheUtil.getResult(
+ InternalOauthModelImpl.ENTITY_CACHE_ENABLED,
+ InternalOauthImpl.class, internalOauth.getPrimaryKey()) == null) {
+ cacheResult(internalOauth);
+ }
+ else {
+ internalOauth.resetOriginalValues();
+ }
+ }
+ }
+
+ /**
+ * Clears the cache for all internal oauths.
+ *
+ * <p>
+ * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
+ * </p>
+ */
+ @Override
+ public void clearCache() {
+ if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
+ CacheRegistryUtil.clear(InternalOauthImpl.class.getName());
+ }
+
+ EntityCacheUtil.clearCache(InternalOauthImpl.class.getName());
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ /**
+ * Clears the cache for the internal oauth.
+ *
+ * <p>
+ * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
+ * </p>
+ */
+ @Override
+ public void clearCache(InternalOauth internalOauth) {
+ EntityCacheUtil.removeResult(InternalOauthModelImpl.ENTITY_CACHE_ENABLED,
+ InternalOauthImpl.class, internalOauth.getPrimaryKey());
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+
+ clearUniqueFindersCache(internalOauth);
+ }
+
+ @Override
+ public void clearCache(List<InternalOauth> internalOauths) {
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+
+ for (InternalOauth internalOauth : internalOauths) {
+ EntityCacheUtil.removeResult(InternalOauthModelImpl.ENTITY_CACHE_ENABLED,
+ InternalOauthImpl.class, internalOauth.getPrimaryKey());
+
+ clearUniqueFindersCache(internalOauth);
+ }
+ }
+
+ protected void clearUniqueFindersCache(InternalOauth internalOauth) {
+ FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_TOKEN,
+ new Object[] { internalOauth.getToken() });
+ }
+
+ /**
+ * Creates a new internal oauth with the primary key. Does not add the internal oauth to the database.
+ *
+ * @param internalOauthId the primary key for the new internal oauth
+ * @return the new internal oauth
+ */
+ public InternalOauth create(long internalOauthId) {
+ InternalOauth internalOauth = new InternalOauthImpl();
+
+ internalOauth.setNew(true);
+ internalOauth.setPrimaryKey(internalOauthId);
+
+ return internalOauth;
+ }
+
+ /**
+ * Removes the internal oauth with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param internalOauthId the primary key of the internal oauth
+ * @return the internal oauth that was removed
+ * @throws com.pentila.entSavoie.userProperties.NoSuchInternalOauthException if a internal oauth with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalOauth remove(long internalOauthId)
+ throws NoSuchInternalOauthException, SystemException {
+ return remove(Long.valueOf(internalOauthId));
+ }
+
+ /**
+ * Removes the internal oauth with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param primaryKey the primary key of the internal oauth
+ * @return the internal oauth that was removed
+ * @throws com.pentila.entSavoie.userProperties.NoSuchInternalOauthException if a internal oauth with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public InternalOauth remove(Serializable primaryKey)
+ throws NoSuchInternalOauthException, SystemException {
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ InternalOauth internalOauth = (InternalOauth)session.get(InternalOauthImpl.class,
+ primaryKey);
+
+ if (internalOauth == null) {
+ if (_log.isWarnEnabled()) {
+ _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
+ }
+
+ throw new NoSuchInternalOauthException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ primaryKey);
+ }
+
+ return remove(internalOauth);
+ }
+ catch (NoSuchInternalOauthException nsee) {
+ throw nsee;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ @Override
+ protected InternalOauth removeImpl(InternalOauth internalOauth)
+ throws SystemException {
+ internalOauth = toUnwrappedModel(internalOauth);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ BatchSessionUtil.delete(session, internalOauth);
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+
+ clearCache(internalOauth);
+
+ return internalOauth;
+ }
+
+ @Override
+ public InternalOauth updateImpl(
+ com.pentila.entSavoie.userProperties.model.InternalOauth internalOauth,
+ boolean merge) throws SystemException {
+ internalOauth = toUnwrappedModel(internalOauth);
+
+ boolean isNew = internalOauth.isNew();
+
+ InternalOauthModelImpl internalOauthModelImpl = (InternalOauthModelImpl)internalOauth;
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ BatchSessionUtil.update(session, internalOauth, merge);
+
+ internalOauth.setNew(false);
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+
+ if (isNew || !InternalOauthModelImpl.COLUMN_BITMASK_ENABLED) {
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ EntityCacheUtil.putResult(InternalOauthModelImpl.ENTITY_CACHE_ENABLED,
+ InternalOauthImpl.class, internalOauth.getPrimaryKey(),
+ internalOauth);
+
+ if (isNew) {
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TOKEN,
+ new Object[] { internalOauth.getToken() }, internalOauth);
+ }
+ else {
+ if ((internalOauthModelImpl.getColumnBitmask() &
+ FINDER_PATH_FETCH_BY_TOKEN.getColumnBitmask()) != 0) {
+ Object[] args = new Object[] {
+ internalOauthModelImpl.getOriginalToken()
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TOKEN, args);
+
+ FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_TOKEN, args);
+
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TOKEN,
+ new Object[] { internalOauth.getToken() }, internalOauth);
+ }
+ }
+
+ return internalOauth;
+ }
+
+ protected InternalOauth toUnwrappedModel(InternalOauth internalOauth) {
+ if (internalOauth instanceof InternalOauthImpl) {
+ return internalOauth;
+ }
+
+ InternalOauthImpl internalOauthImpl = new InternalOauthImpl();
+
+ internalOauthImpl.setNew(internalOauth.isNew());
+ internalOauthImpl.setPrimaryKey(internalOauth.getPrimaryKey());
+
+ internalOauthImpl.setInternalOauthId(internalOauth.getInternalOauthId());
+ internalOauthImpl.setToken(internalOauth.getToken());
+ internalOauthImpl.setUrl(internalOauth.getUrl());
+ internalOauthImpl.setUserId(internalOauth.getUserId());
+ internalOauthImpl.setTimeMarker(internalOauth.getTimeMarker());
+
+ return internalOauthImpl;
+ }
+
+ /**
+ * Returns the internal oauth with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
+ *
+ * @param primaryKey the primary key of the internal oauth
+ * @return the internal oauth
+ * @throws com.liferay.portal.NoSuchModelException if a internal oauth with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public InternalOauth findByPrimaryKey(Serializable primaryKey)
+ throws NoSuchModelException, SystemException {
+ return findByPrimaryKey(((Long)primaryKey).longValue());
+ }
+
+ /**
+ * Returns the internal oauth with the primary key or throws a {@link com.pentila.entSavoie.userProperties.NoSuchInternalOauthException} if it could not be found.
+ *
+ * @param internalOauthId the primary key of the internal oauth
+ * @return the internal oauth
+ * @throws com.pentila.entSavoie.userProperties.NoSuchInternalOauthException if a internal oauth with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalOauth findByPrimaryKey(long internalOauthId)
+ throws NoSuchInternalOauthException, SystemException {
+ InternalOauth internalOauth = fetchByPrimaryKey(internalOauthId);
+
+ if (internalOauth == null) {
+ if (_log.isWarnEnabled()) {
+ _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + internalOauthId);
+ }
+
+ throw new NoSuchInternalOauthException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ internalOauthId);
+ }
+
+ return internalOauth;
+ }
+
+ /**
+ * Returns the internal oauth with the primary key or returns <code>null</code> if it could not be found.
+ *
+ * @param primaryKey the primary key of the internal oauth
+ * @return the internal oauth, or <code>null</code> if a internal oauth with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public InternalOauth fetchByPrimaryKey(Serializable primaryKey)
+ throws SystemException {
+ return fetchByPrimaryKey(((Long)primaryKey).longValue());
+ }
+
+ /**
+ * Returns the internal oauth with the primary key or returns <code>null</code> if it could not be found.
+ *
+ * @param internalOauthId the primary key of the internal oauth
+ * @return the internal oauth, or <code>null</code> if a internal oauth with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalOauth fetchByPrimaryKey(long internalOauthId)
+ throws SystemException {
+ InternalOauth internalOauth = (InternalOauth)EntityCacheUtil.getResult(InternalOauthModelImpl.ENTITY_CACHE_ENABLED,
+ InternalOauthImpl.class, internalOauthId);
+
+ if (internalOauth == _nullInternalOauth) {
+ return null;
+ }
+
+ if (internalOauth == null) {
+ Session session = null;
+
+ boolean hasException = false;
+
+ try {
+ session = openSession();
+
+ internalOauth = (InternalOauth)session.get(InternalOauthImpl.class,
+ Long.valueOf(internalOauthId));
+ }
+ catch (Exception e) {
+ hasException = true;
+
+ throw processException(e);
+ }
+ finally {
+ if (internalOauth != null) {
+ cacheResult(internalOauth);
+ }
+ else if (!hasException) {
+ EntityCacheUtil.putResult(InternalOauthModelImpl.ENTITY_CACHE_ENABLED,
+ InternalOauthImpl.class, internalOauthId,
+ _nullInternalOauth);
+ }
+
+ closeSession(session);
+ }
+ }
+
+ return internalOauth;
+ }
+
+ /**
+ * Returns the internal oauth where token = ? or throws a {@link com.pentila.entSavoie.userProperties.NoSuchInternalOauthException} if it could not be found.
+ *
+ * @param token the token
+ * @return the matching internal oauth
+ * @throws com.pentila.entSavoie.userProperties.NoSuchInternalOauthException if a matching internal oauth could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalOauth findBytoken(String token)
+ throws NoSuchInternalOauthException, SystemException {
+ InternalOauth internalOauth = fetchBytoken(token);
+
+ if (internalOauth == null) {
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("token=");
+ msg.append(token);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ if (_log.isWarnEnabled()) {
+ _log.warn(msg.toString());
+ }
+
+ throw new NoSuchInternalOauthException(msg.toString());
+ }
+
+ return internalOauth;
+ }
+
+ /**
+ * Returns the internal oauth where token = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
+ *
+ * @param token the token
+ * @return the matching internal oauth, or <code>null</code> if a matching internal oauth could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalOauth fetchBytoken(String token) throws SystemException {
+ return fetchBytoken(token, true);
+ }
+
+ /**
+ * Returns the internal oauth where token = ? or returns <code>null</code> if it could not be found, optionally using the finder cache.
+ *
+ * @param token the token
+ * @param retrieveFromCache whether to use the finder cache
+ * @return the matching internal oauth, or <code>null</code> if a matching internal oauth could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalOauth fetchBytoken(String token, boolean retrieveFromCache)
+ throws SystemException {
+ Object[] finderArgs = new Object[] { token };
+
+ Object result = null;
+
+ if (retrieveFromCache) {
+ result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_TOKEN,
+ finderArgs, this);
+ }
+
+ if (result instanceof InternalOauth) {
+ InternalOauth internalOauth = (InternalOauth)result;
+
+ if (!Validator.equals(token, internalOauth.getToken())) {
+ result = null;
+ }
+ }
+
+ if (result == null) {
+ StringBundler query = new StringBundler(2);
+
+ query.append(_SQL_SELECT_INTERNALOAUTH_WHERE);
+
+ if (token == null) {
+ query.append(_FINDER_COLUMN_TOKEN_TOKEN_1);
+ }
+ else {
+ if (token.equals(StringPool.BLANK)) {
+ query.append(_FINDER_COLUMN_TOKEN_TOKEN_3);
+ }
+ else {
+ query.append(_FINDER_COLUMN_TOKEN_TOKEN_2);
+ }
+ }
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ if (token != null) {
+ qPos.add(token);
+ }
+
+ List<InternalOauth> list = q.list();
+
+ result = list;
+
+ InternalOauth internalOauth = null;
+
+ if (list.isEmpty()) {
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TOKEN,
+ finderArgs, list);
+ }
+ else {
+ internalOauth = list.get(0);
+
+ cacheResult(internalOauth);
+
+ if ((internalOauth.getToken() == null) ||
+ !internalOauth.getToken().equals(token)) {
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_TOKEN,
+ finderArgs, internalOauth);
+ }
+ }
+
+ return internalOauth;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (result == null) {
+ FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_TOKEN,
+ finderArgs);
+ }
+
+ closeSession(session);
+ }
+ }
+ else {
+ if (result instanceof List<?>) {
+ return null;
+ }
+ else {
+ return (InternalOauth)result;
+ }
+ }
+ }
+
+ /**
+ * Returns all the internal oauths.
+ *
+ * @return the internal oauths
+ * @throws SystemException if a system exception occurred
+ */
+ public List<InternalOauth> findAll() throws SystemException {
+ return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
+ }
+
+ /**
+ * Returns a range of all the internal oauths.
+ *
+ * <p>
+ * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
+ * </p>
+ *
+ * @param start the lower bound of the range of internal oauths
+ * @param end the upper bound of the range of internal oauths (not inclusive)
+ * @return the range of internal oauths
+ * @throws SystemException if a system exception occurred
+ */
+ public List<InternalOauth> findAll(int start, int end)
+ throws SystemException {
+ return findAll(start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the internal oauths.
+ *
+ * <p>
+ * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
+ * </p>
+ *
+ * @param start the lower bound of the range of internal oauths
+ * @param end the upper bound of the range of internal oauths (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of internal oauths
+ * @throws SystemException if a system exception occurred
+ */
+ public List<InternalOauth> findAll(int start, int end,
+ OrderByComparator orderByComparator) throws SystemException {
+ FinderPath finderPath = null;
+ Object[] finderArgs = new Object[] { start, end, orderByComparator };
+
+ if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
+ (orderByComparator == null)) {
+ finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
+ finderArgs = FINDER_ARGS_EMPTY;
+ }
+ else {
+ finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
+ finderArgs = new Object[] { start, end, orderByComparator };
+ }
+
+ List<InternalOauth> list = (List<InternalOauth>)FinderCacheUtil.getResult(finderPath,
+ finderArgs, this);
+
+ if (list == null) {
+ StringBundler query = null;
+ String sql = null;
+
+ if (orderByComparator != null) {
+ query = new StringBundler(2 +
+ (orderByComparator.getOrderByFields().length * 3));
+
+ query.append(_SQL_SELECT_INTERNALOAUTH);
+
+ appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
+ orderByComparator);
+
+ sql = query.toString();
+ }
+ else {
+ sql = _SQL_SELECT_INTERNALOAUTH;
+ }
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ if (orderByComparator == null) {
+ list = (List<InternalOauth>)QueryUtil.list(q, getDialect(),
+ start, end, false);
+
+ Collections.sort(list);
+ }
+ else {
+ list = (List<InternalOauth>)QueryUtil.list(q, getDialect(),
+ start, end);
+ }
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (list == null) {
+ FinderCacheUtil.removeResult(finderPath, finderArgs);
+ }
+ else {
+ cacheResult(list);
+
+ FinderCacheUtil.putResult(finderPath, finderArgs, list);
+ }
+
+ closeSession(session);
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * Removes the internal oauth where token = ? from the database.
+ *
+ * @param token the token
+ * @return the internal oauth that was removed
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalOauth removeBytoken(String token)
+ throws NoSuchInternalOauthException, SystemException {
+ InternalOauth internalOauth = findBytoken(token);
+
+ return remove(internalOauth);
+ }
+
+ /**
+ * Removes all the internal oauths from the database.
+ *
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeAll() throws SystemException {
+ for (InternalOauth internalOauth : findAll()) {
+ remove(internalOauth);
+ }
+ }
+
+ /**
+ * Returns the number of internal oauths where token = ?.
+ *
+ * @param token the token
+ * @return the number of matching internal oauths
+ * @throws SystemException if a system exception occurred
+ */
+ public int countBytoken(String token) throws SystemException {
+ Object[] finderArgs = new Object[] { token };
+
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_TOKEN,
+ finderArgs, this);
+
+ if (count == null) {
+ StringBundler query = new StringBundler(2);
+
+ query.append(_SQL_COUNT_INTERNALOAUTH_WHERE);
+
+ if (token == null) {
+ query.append(_FINDER_COLUMN_TOKEN_TOKEN_1);
+ }
+ else {
+ if (token.equals(StringPool.BLANK)) {
+ query.append(_FINDER_COLUMN_TOKEN_TOKEN_3);
+ }
+ else {
+ query.append(_FINDER_COLUMN_TOKEN_TOKEN_2);
+ }
+ }
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ if (token != null) {
+ qPos.add(token);
+ }
+
+ count = (Long)q.uniqueResult();
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (count == null) {
+ count = Long.valueOf(0);
+ }
+
+ FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_TOKEN,
+ finderArgs, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Returns the number of internal oauths.
+ *
+ * @return the number of internal oauths
+ * @throws SystemException if a system exception occurred
+ */
+ public int countAll() throws SystemException {
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
+ FINDER_ARGS_EMPTY, this);
+
+ if (count == null) {
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(_SQL_COUNT_INTERNALOAUTH);
+
+ count = (Long)q.uniqueResult();
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (count == null) {
+ count = Long.valueOf(0);
+ }
+
+ FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
+ FINDER_ARGS_EMPTY, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Initializes the internal oauth persistence.
+ */
+ public void afterPropertiesSet() {
+ String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
+ com.liferay.util.service.ServiceProps.get(
+ "value.object.listener.com.pentila.entSavoie.userProperties.model.InternalOauth")));
+
+ if (listenerClassNames.length > 0) {
+ try {
+ List<ModelListener<InternalOauth>> listenersList = new ArrayList<ModelListener<InternalOauth>>();
+
+ for (String listenerClassName : listenerClassNames) {
+ listenersList.add((ModelListener<InternalOauth>)InstanceFactory.newInstance(
+ PortletClassLoaderUtil.getClassLoader(),
+ listenerClassName, (Class<?>[])null, (Object[])null));
+ }
+
+ listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
+ }
+ catch (Exception e) {
+ _log.error(e);
+ }
+ }
+ }
+
+ public void destroy() {
+ EntityCacheUtil.removeCache(InternalOauthImpl.class.getName());
+ FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
+ FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ @BeanReference(type = DashboardConfigPersistence.class)
+ protected DashboardConfigPersistence dashboardConfigPersistence;
+ @BeanReference(type = DashboardDefaultConfigPersistence.class)
+ protected DashboardDefaultConfigPersistence dashboardDefaultConfigPersistence;
+ @BeanReference(type = InternalOauthPersistence.class)
+ protected InternalOauthPersistence internalOauthPersistence;
+ @BeanReference(type = NotifyConfigPersistence.class)
+ protected NotifyConfigPersistence notifyConfigPersistence;
+ @BeanReference(type = UserContactPersistence.class)
+ protected UserContactPersistence userContactPersistence;
+ @BeanReference(type = UserInternalSSOPersistence.class)
+ protected UserInternalSSOPersistence userInternalSSOPersistence;
+ @BeanReference(type = UserMailSynchronisationPersistence.class)
+ protected UserMailSynchronisationPersistence userMailSynchronisationPersistence;
+ @BeanReference(type = UserMatchingPersistence.class)
+ protected UserMatchingPersistence userMatchingPersistence;
+ @BeanReference(type = UserMobileNotificationPersistence.class)
+ protected UserMobileNotificationPersistence userMobileNotificationPersistence;
+ @BeanReference(type = UserPropertiesPersistence.class)
+ protected UserPropertiesPersistence userPropertiesPersistence;
+ @BeanReference(type = UserRelationshipPersistence.class)
+ protected UserRelationshipPersistence userRelationshipPersistence;
+ @BeanReference(type = ResourcePersistence.class)
+ protected ResourcePersistence resourcePersistence;
+ @BeanReference(type = UserPersistence.class)
+ protected UserPersistence userPersistence;
+ private static final String _SQL_SELECT_INTERNALOAUTH = "SELECT internalOauth FROM InternalOauth internalOauth";
+ private static final String _SQL_SELECT_INTERNALOAUTH_WHERE = "SELECT internalOauth FROM InternalOauth internalOauth WHERE ";
+ private static final String _SQL_COUNT_INTERNALOAUTH = "SELECT COUNT(internalOauth) FROM InternalOauth internalOauth";
+ private static final String _SQL_COUNT_INTERNALOAUTH_WHERE = "SELECT COUNT(internalOauth) FROM InternalOauth internalOauth WHERE ";
+ private static final String _FINDER_COLUMN_TOKEN_TOKEN_1 = "internalOauth.token IS NULL";
+ private static final String _FINDER_COLUMN_TOKEN_TOKEN_2 = "internalOauth.token = ?";
+ private static final String _FINDER_COLUMN_TOKEN_TOKEN_3 = "(internalOauth.token IS NULL OR internalOauth.token = ?)";
+ private static final String _ORDER_BY_ENTITY_ALIAS = "internalOauth.";
+ private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No InternalOauth exists with the primary key ";
+ private static final String _NO_SUCH_ENTITY_WITH_KEY = "No InternalOauth exists with the key {";
+ private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = GetterUtil.getBoolean(PropsUtil.get(
+ PropsKeys.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE));
+ private static Log _log = LogFactoryUtil.getLog(InternalOauthPersistenceImpl.class);
+ private static InternalOauth _nullInternalOauth = new InternalOauthImpl() {
+ @Override
+ public Object clone() {
+ return this;
+ }
+
+ @Override
+ public CacheModel<InternalOauth> toCacheModel() {
+ return _nullInternalOauthCacheModel;
+ }
+ };
+
+ private static CacheModel<InternalOauth> _nullInternalOauthCacheModel = new CacheModel<InternalOauth>() {
+ public InternalOauth toEntityModel() {
+ return _nullInternalOauth;
+ }
+ };
+}
\ No newline at end of file