use of com.sun.identity.common.CaseInsensitiveProperties in project OpenAM by OpenRock.
the class SMSFlatFileObject method loadMapper.
/**
* Loads the name mapper, create it if it doesn't exist.
**/
protected void loadMapper() throws SMSException {
StringBuffer nameMapFilename = new StringBuffer(mRootDir);
nameMapFilename.append(File.separatorChar);
nameMapFilename.append(DEFAULT_NAMEMAP_FILENAME);
mNameMapHandle = new File(nameMapFilename.toString());
if (mNameMapHandle.isFile()) {
if (!mNameMapHandle.canRead()) {
String errmsg = "SMSFlatFileObject.initialize: cannot read file " + mNameMapHandle.getPath();
mDebug.error(errmsg);
throw new SMSException(errmsg);
}
mNameMap = loadProperties(mNameMapHandle, null);
} else {
try {
mNameMapHandle.createNewFile();
} catch (IOException e) {
String errmsg = "SMSFlatFileObject.initialize: " + "cannot create file, " + nameMapFilename + ". Exception " + e.getMessage();
mDebug.error(errmsg);
throw new SMSException(errmsg);
} catch (SecurityException e) {
String errmsg = "SMSFlatFileObject.initialize: " + "cannot create file " + nameMapFilename + ". Exception " + e.getMessage();
mDebug.error(errmsg);
throw new SMSException(errmsg);
}
mNameMap = new CaseInsensitiveProperties();
// create root dn if this is a new directory.
try {
create(null, mRootDN, new HashMap());
if (mDebug.messageEnabled()) {
mDebug.message("SMSFlatFileObject.initialize: " + "created SMS object for " + mRootDN);
}
} catch (SSOException e) {
// not possible
} catch (ServiceAlreadyExistsException e) {
if (mDebug.messageEnabled()) {
mDebug.message("SMSFlatFileObject.initialize: " + mRootDN + " already exists");
}
}
// also create ou=services this is a new directory.
try {
create(null, "ou=services," + mRootDN, new HashMap());
if (mDebug.messageEnabled()) {
mDebug.message("SMSFlatFileObject.initialize: " + "created SMS object for ou=services," + mRootDN);
}
} catch (SSOException e) {
// not possible
} catch (ServiceAlreadyExistsException e) {
if (mDebug.messageEnabled()) {
mDebug.message("SMSFlatFileObject.initialize: " + "ou=services," + mRootDN + " already exists");
}
}
}
}
use of com.sun.identity.common.CaseInsensitiveProperties in project OpenAM by OpenRock.
the class SMSFlatFileObjectBase method loadProperties.
/**
* Loads properties from the attribute file handle.
* @return Properties object of the configuration object.
* @throws ServiceNotFoundException if the attributes file is not found.
* @throws SMSException if an IO error occurred while reading the
* attributes properties file.
* @throws SchemaException if a format error occurred while reading the
* attributes properties file.
*/
protected Properties loadProperties(File filehandle, String objName) throws SMSException {
// read file contents into properties and
// form the attributes map to be returned from the properties.
FileInputStream fileistr = null;
try {
fileistr = new FileInputStream(filehandle);
Properties props = new CaseInsensitiveProperties();
props.load(fileistr);
return props;
} catch (FileNotFoundException e) {
String errmsg = "SMSFlatFileObject.loadProperties: " + objName + " File, " + filehandle.getPath() + e.getMessage();
mDebug.error("SMSFlatFileObject.loadProperties", e);
throw new ServiceNotFoundException(errmsg);
} catch (IOException e) {
String errmsg = "SMSFlatFileObject.loadProperties: " + objName + " File, " + filehandle.getPath() + e.getMessage();
mDebug.error("SMSFlatFileObject.loadProperties", e);
throw new ServiceNotFoundException(errmsg);
} catch (IllegalArgumentException e) {
String errmsg = "SMSFlatFileObject.loadProperties: " + objName + " File, " + filehandle.getPath() + e.getMessage();
mDebug.error("SMSFlatFileObject.loadProperties", e);
throw new ServiceNotFoundException(errmsg);
} finally {
if (fileistr != null) {
try {
fileistr.close();
} catch (IOException e) {
// ignored
}
}
}
}
Aggregations