
org.ow2.bonita.identity.impl.PersistentIdentityService Maven / Gradle / Ivy
/**
* Copyright (C) 2007 Bull S. A. S.
* Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
* 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
* version 2.1 of the License.
* 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.
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
* Floor, Boston, MA 02110-1301, USA.
**/
package org.ow2.bonita.identity.impl;
import java.io.File;
import java.io.FileNotFoundException;
import org.ow2.bonita.identity.CommitException;
/**
* @author "Pierre Vigneras"
* @date Nov 27, 2007
*/
public abstract class PersistentIdentityService extends InMemoryIdentityService {
protected final File file;
public PersistentIdentityService(final File file, boolean create) throws FileNotFoundException {
if (file == null) {
throw new IllegalArgumentException("File is null!");
}
this.file = file;
if (file.exists()) {
sync();
} else if (create) {
flush();
} else {
throw new FileNotFoundException("Can't find file: "
+ file.getAbsolutePath());
}
}
// /*
// * (non-Javadoc)
// *
// * @see
// org.ow2.bonita.identity.IdentityServiceOp#createGroup(org.ow2.bonita.identity.GroupOp)
// */
// public Object createGroup(final GroupOp parent) {
// try {
// return super.createGroup(parent);
// } finally {
// flush();
// }
// }
//
// public Object createUser() {
// try {
// return super.createUser();
// } finally {
// flush();
// }
// }
//
// public boolean modifyGroup(GroupOp group) {
// try {
// return super.modifyGroup(group);
// } finally {
// flush();
// }
// }
//
// public boolean modifyUser(UserOp user) {
// try {
// return super.modifyUser(user);
// } finally {
// flush();
// }
// }
//
// public Collection getAllGroups() {
// sync();
// return super.getAllGroups();
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.ow2.bonita.identity.IdentityServiceOp#getAllUsers()
// */
// public Collection getAllUsers() {
// sync();
// return super.getAllUsers();
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.ow2.bonita.identity.IdentityServiceOp#getGroup(java.lang.Object)
// */
// public GroupOp getGroup(Object id) {
// sync();
// return super.getGroup(id);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see org.ow2.bonita.identity.IdentityServiceOp#getUser(java.lang.Object)
// */
// public UserOp getUser(Object id) {
// sync();
// return super.getUser(id);
// }
//
// /*
// * (non-Javadoc)
// *
// * @see
// org.ow2.bonita.identity.IdentityServiceOp#setMembership(org.ow2.bonita.identity.UserOp,
// * org.ow2.bonita.identity.GroupOp)
// */
// public void setMembership(UserOp user, GroupOp group) {
// try {
// super.setMembership(user, group);
// } finally {
// flush();
// }
// }
protected abstract void flush();
protected abstract void sync();
public void commit() throws CommitException {
flush();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy