Package com.opensymphony.user.provider.file

Source Code of com.opensymphony.user.provider.file.FileProfileProvider

/*
* Copyright (c) 2002-2003 by OpenSymphony
* All rights reserved.
*/
package com.opensymphony.user.provider.file;

import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.module.propertyset.PropertySetManager;

import com.opensymphony.user.Entity;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;


/**
* Following properties are <b>required</b>:
* <ul>
* <li><b>storeFile</b> - the absolute path to the store file
(<i>ex:c:\properties.store</i>)</li>
* </ul>
*/
public class FileProfileProvider implements com.opensymphony.user.provider.ProfileProvider {
    //~ Static fields/initializers /////////////////////////////////////////////

    protected static final Log log = LogFactory.getLog(FileProfileProvider.class);
   
  protected FilePropertySetCache propertySetCache;

    //~ Methods ////////////////////////////////////////////////////////////////

    public PropertySet getPropertySet(String name) {
        if (!propertySetCache.propertySets.containsKey(name)) {
            return null;
        }

        return (PropertySet) propertySetCache.propertySets.get(name);
    }

    public boolean create(String name) {
        if (propertySetCache.propertySets.containsKey(name)) {
            return false;
        }

        PropertySet propertySet = PropertySetManager.getInstance("serializable", null);
        propertySetCache.propertySets.put(name, propertySet);

        return propertySetCache.store();
    }

    public void flushCaches() {
    propertySetCache.store();
    }

    public boolean handles(String name) {
        return propertySetCache.propertySets.containsKey(name);
    }

    public boolean init(Properties properties) {
        return true;
    }

    public List list() {
    return Collections.unmodifiableList(new ArrayList(propertySetCache.propertySets.keySet()));
    }

    public boolean load(String name, Entity.Accessor accessor) {
        return true;
    }

    public boolean remove(String name) {
        boolean rv = propertySetCache.propertySets.remove(name) != null;

        return rv && propertySetCache.store();
    }

    public boolean store(String name, Entity.Accessor accessor) {
        return propertySetCache.store();
    }
}
TOP

Related Classes of com.opensymphony.user.provider.file.FileProfileProvider

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.