/** * Copyright (c) 2000-present 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.liferay.sync.engine.service; import com.liferay.sync.engine.model.ModelListener; import com.liferay.sync.engine.model.SyncUser; import com.liferay.sync.engine.service.persistence.SyncUserPersistence; import java.sql.SQLException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author Dennis Ju */ public class SyncUserService { public static void deleteSyncUser(long syncUserId) { try { _syncUserPersistence.deleteById(syncUserId); } catch (SQLException sqle) { if (_logger.isDebugEnabled()) { _logger.debug(sqle.getMessage(), sqle); } } } public static SyncUser fetchSyncUser(long syncAccountId) { try { return _syncUserPersistence.fetchBySyncAccountId(syncAccountId); } catch (SQLException sqle) { if (_logger.isDebugEnabled()) { _logger.debug(sqle.getMessage(), sqle); } return null; } } public static SyncUserPersistence getSyncUserPersistence() { if (_syncUserPersistence != null) { return _syncUserPersistence; } try { _syncUserPersistence = new SyncUserPersistence(); return _syncUserPersistence; } catch (SQLException sqle) { if (_logger.isDebugEnabled()) { _logger.debug(sqle.getMessage(), sqle); } return null; } } public static void registerModelListener( ModelListener<SyncUser> modelListener) { _syncUserPersistence.registerModelListener(modelListener); } public static void unregisterModelListener( ModelListener<SyncUser> modelListener) { _syncUserPersistence.unregisterModelListener(modelListener); } public static SyncUser update(SyncUser syncUser) { try { _syncUserPersistence.createOrUpdate(syncUser); return syncUser; } catch (SQLException sqle) { if (_logger.isDebugEnabled()) { _logger.debug(sqle.getMessage(), sqle); } return null; } } private static final Logger _logger = LoggerFactory.getLogger( SyncUserService.class); private static SyncUserPersistence _syncUserPersistence = getSyncUserPersistence(); }