public void create(SSOToken token,String objName,Map attrs) throws SMSException, SSOException {
  if (objName == null || objName.length() == 0 || attrs == null) {
    throw new IllegalArgumentException("SMSFlatFileObject.create: " + "One or more arguments is null or empty");
  }
  String objKey=objName.toLowerCase();
  String filepath=null;
  mRWLock.readRequest();
  try {
    filepath=mNameMap.getProperty(objKey);
    if (filepath != null) {
      String errmsg="SMSFlatFileObject.create: object " + objName + " already exists in "+ filepath;
      mDebug.error(errmsg);
      throw new ServiceAlreadyExistsException(errmsg);
    }
  }
  finally {
    mRWLock.readDone();
  }
  mRWLock.writeRequest();
  try {
    filepath=mNameMap.getProperty(objKey);
    if (filepath != null) {
      String errmsg="SMSFlatFileObject.create: object " + objName + " already exists in "+ filepath;
      mDebug.error(errmsg);
      throw new ServiceAlreadyExistsException(errmsg);
    }
    filepath=getAttrFile(objName);
    File filehandle=new File(filepath);
    File parentDir=filehandle.getParentFile();
    if (parentDir.isDirectory()) {
      String errmsg="SMSFlatFileObject.create: object " + objName + " directory "+ parentDir.getPath()+ " exists before create!";
      mDebug.error(errmsg);
      throw new ServiceAlreadyExistsException(errmsg);
    }
    Set sunserviceids=null;
    Set sunxmlkeyvals=null;
    Properties props=new Properties();
    Set keys=attrs.keySet();
    if (keys != null) {
      for (Iterator i=keys.iterator(); i.hasNext(); ) {
        String key=(String)i.next();
        Set vals=(Set)attrs.get(key);
        if (key.equalsIgnoreCase(SMSEntry.ATTR_SERVICE_ID)) {
          sunserviceids=vals;
        }
 else         if (key.equalsIgnoreCase(SMSEntry.ATTR_XML_KEYVAL)) {
          sunxmlkeyvals=vals;
        }
        props.put(key,toValString(vals));
      }
    }
    try {
      if (!parentDir.mkdirs()) {
        String errmsg="SMSFlatFileObject.create: object " + objName + ": Could not create directory "+ parentDir.getPath();
        mDebug.error(errmsg);
        throw new SMSException(errmsg);
      }
      try {
        if (!filehandle.createNewFile()) {
          String errmsg="SMSFlatFileObject.create: object " + objName + ": Could not create file "+ filepath;
          mDebug.error(errmsg);
          throw new SMSException(errmsg);
        }
      }
 catch (      IOException e) {
        String errmsg="SMSFlatFileObject.create: object " + objName + " IOException encountered when creating file "+ filehandle.getPath()+ ". Exception: "+ e.getMessage();
        mDebug.error("SMSFlatFileObject.create",e);
        throw new SMSException(errmsg);
      }
      saveProperties(props,filehandle,objName);
      if (sunserviceids != null && !sunserviceids.isEmpty()) {
        createSunServiceIdFiles(parentDir,sunserviceids);
      }
      if (sunxmlkeyvals != null && !sunxmlkeyvals.isEmpty()) {
        createSunXmlKeyValFiles(parentDir,sunxmlkeyvals);
      }
      mNameMap.setProperty(objKey,filepath);
      saveProperties(mNameMap,mNameMapHandle,null);
    }
 catch (    SMSException e) {
      deleteDir(parentDir);
      mNameMap.remove(objKey);
      throw e;
    }
  }
  finally {
    mRWLock.writeDone();
  }
}

public void create ( SSOToken token , String objName , Map attrs ) throws SMSException , SSOException { if ( objName == null || objName . length ( ) == 0 || attrs == null ) { throw new IllegalArgumentException ( "SMSFlatFileObject.create: " + "One or more arguments is null or empty" ) ; } String objKey = objName . toLowerCase ( ) ; String filepath = null ; mRWLock . readRequest ( ) ; try { filepath = mNameMap . getProperty ( objKey ) ; if ( filepath != null ) { String errmsg = "SMSFlatFileObject.create: object " + objName + " already exists in " + filepath ; mDebug . error ( errmsg ) ; throw new ServiceAlreadyExistsException ( errmsg ) ; } } finally { mRWLock . readDone ( ) ; } mRWLock . writeRequest ( ) ; try { filepath = mNameMap . getProperty ( objKey ) ; if ( filepath != null ) { String errmsg = "SMSFlatFileObject.create: object " + objName + " already exists in " + filepath ; mDebug . error ( errmsg ) ; throw new ServiceAlreadyExistsException ( errmsg ) ; } filepath = getAttrFile ( objName ) ; File filehandle = new File ( filepath ) ; File parentDir = filehandle . getParentFile ( ) ; if ( parentDir . isDirectory ( ) ) { String errmsg = "SMSFlatFileObject.create: object " + objName + " directory " + parentDir . getPath ( ) + " exists before create!" ; mDebug . error ( errmsg ) ; throw new ServiceAlreadyExistsException ( errmsg ) ; } Set sunserviceids = null ; Set sunxmlkeyvals = null ; Properties props = new Properties ( ) ; Set keys = attrs . keySet ( ) ; if ( keys != null ) { for ( Iterator i = keys . iterator ( ) ; i . hasNext ( ) ; ) { String key = ( String ) i . next ( ) ; Set vals = ( Set ) attrs . get ( key ) ; if ( key . equalsIgnoreCase ( SMSEntry . ATTR_SERVICE_ID ) ) { sunserviceids = vals ; } else if ( key . equalsIgnoreCase ( SMSEntry . ATTR_XML_KEYVAL ) ) { sunxmlkeyvals = vals ; } props . put ( key , toValString ( vals ) ) ; } } try { if ( ! parentDir . mkdirs ( ) ) { String errmsg = "SMSFlatFileObject.create: object " + objName + ": Could not create directory " + parentDir . getPath ( ) ; mDebug . error ( errmsg ) ; throw new SMSException ( errmsg ) ; } try { if ( ! filehandle . createNewFile ( ) ) { String errmsg = "SMSFlatFileObject.create: object " + objName + ": Could not create file " + filepath ; mDebug . error ( errmsg ) ; throw new SMSException ( errmsg ) ; } } catch ( IOException e ) { String errmsg = "SMSFlatFileObject.create: object " + objName + " IOException encountered when creating file " + filehandle . getPath ( ) + ". Exception: " + e . getMessage ( ) ; mDebug . error ( "SMSFlatFileObject.create" , e ) ; throw new SMSException ( errmsg ) ; } saveProperties ( props , filehandle , objName ) ; if ( sunserviceids != null && ! sunserviceids . isEmpty ( ) ) { createSunServiceIdFiles ( parentDir , sunserviceids ) ; } if ( sunxmlkeyvals != null && ! sunxmlkeyvals . isEmpty ( ) ) { createSunXmlKeyValFiles ( parentDir , sunxmlkeyvals ) ; } mNameMap . setProperty ( objKey , filepath ) ; saveProperties ( mNameMap , mNameMapHandle , null ) ; } catch ( SMSException e ) { deleteDir ( parentDir ) ; mNameMap . remove ( objKey ) ; throw e ; } } finally { mRWLock . writeDone ( ) ; } }
creates the configuration object . creates the directory for the object and the attributes properties file with the given attributes .
