/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: SMSEnhancedFlatFileObject.java,v 1.8 2008/06/25 05:44:08 qcheng Exp $
*
*/
/*
* Portions Copyrighted [2011] [ForgeRock AS]
*/
/**
* This is an enhancement of <code>SMSEnhancedFlatFileObject</code> where
* we modified the implementation to avoid hitting the file name length
* limitation on Windows Operating System.
*
* Under the base directory of the datastore, there shall be a XML file,
* DirectoryTree.xml which contains information on the nodes ofnthe
* directory tree. The attribute properties on these nodes are also
* stored under the base directory. The name of this property file is
* the hash of the distinguished name of the node.
*/
/**
* Constructor for SMSEnhancedFlatFileObject.
*/
public SMSEnhancedFlatFileObject()
throws SMSException {
initialize();
eventManager = new FlatFileEventManager(this);
}
/**
* Loads the dirrectory mapper, create it if it doesn't exist.
**/
synchronized void loadMapper()
throws SMSException
{
if (fileHandle.isFile()) {
if (!fileHandle.canRead()) {
"SMSEnhancedFlatFileObject.initialize: cannot read file " +
throw new SMSException(errmsg);
}
} else {
try {
} catch (IOException e) {
"cannot create file, " + fileName +
". Exception " + e.getMessage();
throw new SMSException(errmsg);
} catch (SecurityException e) {
"cannot create file, " + fileName +
". Exception " + e.getMessage();
throw new SMSException(errmsg);
}
try {
} catch (SSOException e) {
// not possible
} catch (ServiceAlreadyExistsException e) {
}
}
}
throws SMSException
{
try {
}
} catch (IOException e) {
throw new SMSException(
"SMSEnhancedFlatFileObject.parseDirectoryTreeXML, Exception" +
e.getMessage());
} catch (Exception e) {
throw new SMSException(
"SMSEnhancedFlatFileObject.parseDirectoryTreeXML, Exception" +
e.getMessage());
} finally {
try {
} catch (IOException e) {
//ignored
}
}
try {
} catch (IOException e) {
//ignored
}
}
}
}
private void saveDirectoryTree()
throws SMSException
{
try {
} catch (FileNotFoundException ex) {
throw new SMSException(
"SMSEnhancedFlatFileObject.saveDirectoryTree, Exception" +
ex.getMessage());
} catch (IOException ex) {
throw new SMSException(
"SMSEnhancedFlatFileObject.saveDirectoryTree, Exception" +
ex.getMessage());
} finally {
try {
} catch (IOException ex) {
//ignored
}
}
try {
} catch (IOException ex) {
//ignored
}
}
}
}
/**
* Real routine to get sub entries, used by subEntries() and
* schemaSubEntries().
*
* @throws ServiceNotFoundException if the configuration object is
* not found.
* @throws SchemaException if a sub directory name is not in the
* expected "ou=..." format.
*/
boolean isSubConfig,
int numOfEntries,
boolean sortResults,
boolean ascendingOrder
) throws SMSException {
try {
objName + " : not found in objects map.";
throw new ServiceNotFoundException(errmsg);
}
// Create file filter for filter and sid filter.
// Create set for return, use sorted set if sortResults is true.
if (sortResults) {
} else {
subentries = new CaseInsensitiveHashSet();
}
// Set all entries that match filter, and that match
// sunserviceid/sunxmlkeyvalye if sidFilter was not null.
int numEntriesAdded = 0;
boolean done = false;
if (!accept) {
}
if (accept) {
"SMSEnhancedFlatFileObject.getSubEntries: "+
"Invalid sub entry name found: " + nodeDN;
throw new SchemaException(errmsg);
}
// stop if number of entries requested has been reached.
// if sort results, need to get the whole list first.
(numEntriesAdded == numOfEntries);
}
}
subentries.remove(l);
}
}
} finally {
}
return subentries;
}
boolean isSubConfig
) {
// filter also needs to be encoded since the file names
// are encoded.
if (isSubConfig) {
} else {
}
}
return sidNodeFilter;
}
/**
* Reads in attributes of a configuration object.
*
* @return A Map with the coniguration object's attributes or null if the
* configuration object does not exist or no attributes are found.
*
* @param token Ignored argument. Access check is assumed to have
* occurred before reaching this method.
* @param objName Name of the configuration object, expected to be a dn.
*
* @throws SMSException if an IO error occurred during the read.
* @throws SchemaException if a format error occurred while reading the
* attributes properties file.
* @throws IllegalArgumentException if objName argument is null or empty.
*/
throws SMSException, SSOException {
// check args
throw new IllegalArgumentException(
"SMSEnhancedFlatFileObject.read: object name is null or empty."
);
}
try {
// check if object exists.
if (mDebug.messageEnabled()) {
objName + " not found.");
}
} else {
// Read in file as properties.
if (filehandle.exists()) {
try {
} catch (ServiceNotFoundException e) {
// props will be null if object does not exist and
// this func subsequently returns null
}
}
// convert each value string to a Set.
attrMap = new CaseInsensitiveHashMap();
while (keys.hasMoreElements()) {
}
}
}
}
}
finally {
}
return attrMap;
}
/**
* Creates the configuration object. Creates the directory for the
* object and the attributes properties file with the given attributes.
*
* @param token Ignored argument. Access check is assumed to have
* occurred before reaching this method.
* @param objName Name of the configuration object to create. Name is
* expected to be a dn.
* @param attrs Map of attributes for the object.
*
* @throws IllegalArgumentException if the objName or attrs argument is
* null or empty.
* @throws ServiceAlreadyExistsException if the configuration object
* already exists.
* @throws SMSException if an IO error occurred while creating the
* configuration object.
*/
throws SMSException, SSOException {
throw new IllegalArgumentException(
"SMSEnhancedFlatFileObject.create: " +
"One or more arguments is null or empty");
}
try {
throw new ServiceAlreadyExistsException(errmsg);
}
} finally {
}
// Now Create the object.
throw new ServiceAlreadyExistsException(errmsg);
}
try {
/*
* Put attrs into in properties format, replacing any percent's
* with %25 and commas with %2C in the values.
*/
// there's no need for case insensitive properties here since
// we are not reading from it.
}
}
}
try {
try {
if (!attrFile.createNewFile()) {
"SMSEnhancedFlatFileObject.create: object " +
throw new SMSException(errmsg);
}
} catch (IOException e) {
"SMSEnhancedFlatFileObject.create: object " +
objName + " IOException encountered when creating file "
throw new SMSException(errmsg);
}
// write the attributes properties file.
throw new SMSException(
"parent not found for node name=" + objName);
}
} catch (SMSException e) {
try {
} catch (SecurityException se) {
//ignored
}
throw e;
}
} finally {
}
}
/**
* Modifies the attributes for the given configuration object.
*
* @param token Ignored argument. Access check is assumed to have
* occurred before reaching this method.
* @param objName Name of the configuration object to modify. Name is
* expected to be a dn.
* @param mods Array of attributes to modify.
*
* @throws IllegalArgumentException if objName or mods argument is null or
* empty, or if an error was encountered getting attributes from the
* mods argument.
* @throws ServiceNotFoundException if the attributes properties file
* for the configuration object is not found.
* @throws SchemaException if a format error occurred while reading in the
* existing attributes properties file.
* @throws SMSException if an IO error occurred while reading or writing
* to the attributes properties file.
*/
throws SMSException, SSOException {
) {
throw new IllegalArgumentException(
"SMSEnhancedFlatFileObject.modify: "+
"One or more arguments is null or empty");
}
try {
objName + " not found.";
throw new ServiceNotFoundException(errmsg);
}
} finally {
}
try {
objName + " not found.";
throw new ServiceNotFoundException(errmsg);
}
objName + " not found.";
throw new ServiceNotFoundException(errmsg);
}
if (!filehandle.isFile()) {
"SMSEnhancedFlatFileObject.modify: Attributes file for " +
throw new ServiceNotFoundException(errmsg);
}
// Read in attributes in existing file first.
// Replace modification items in attributes properties
}
/*
* save attributes properties file
* sunserviceid's are never modified so don't worry about
* renaming them in modify().
**/
if (newSunXMLKeyValue != null) {
if (!hasSunXmlKeyValue) {
}
}
} finally {
}
}
/**
* Deletes the configuration object and all objects below it.
*
* @param token Ignored argument. Access check is assumed to have
* occurred before reaching this method.
* @param objName Name of the configuration object to delete. Name is
* expected to be a dn.
*
* @throws IllegalArgumentException if objName argument is null or empty.
* @throws SMSException if any files for or under the configuration object
* could not be removed.
*/
throws SMSException, SSOException {
throw new IllegalArgumentException(
"SMSEnhancedFlatFileObject.delete: object name is null or empty.");
}
try {
}
} finally {
}
}
/**
* Returns <code>ture</code> if the configuration object exists.
*
* @param token Ignored argument. Access check is assumed to have
* occurred before reaching this method.
* @param objName Name of the configuration object to check.
* @return <code>true>/code> if the configuration object exists.
* @throws IllegalArgumentException if objName is null or empty.
*/
boolean exists = false;
throw new IllegalArgumentException(
"SMSEnhancedFlatFileObject.entryExists: "+
"One or more arguments is null or empty.");
}
try {
} finally {
}
return exists;
}
/**
* @return a String representing the name of this class.
*/
return ("SMSEnhancedFlatFileObject");
}
/**
* Delete sunxmlkeyvalue files under the given node.
*/
throws SMSException {
}
}
/**
* Creates sunxmlkeyvalue files with the given values under the
* given directory. sunxmlkeyvalue files are created so searching
* for realms does not have to read in every attribute properrties
* file and look for the sunxmlkeyvalue attribute. we just need to look
* for sub directories with the sunxmlkeyvalue file.
*/
private void createSunXmlKeyValFiles(
) throws SMSException {
}
}
/**
* Creates sunserviceid files with the given values under the
* given directory. sunserviceid files are created so getting
* schemasubentries does not have to read in every attribute properrties
* file and look for the serviceid attribute. we just need to look
* for sub directories with the sunserviceid file.
*/
private void createSunServiceIdFiles(
) throws SMSException {
}
}
private void createLookupFiles(
) throws SMSException {
}
}
/**
* Register a listener.
*/
throws SMSException, SSOException {
}
/**
* De-Register a listener.
*/
}
}