Changeset 376

Show
Ignore:
Timestamp:
01/28/07 19:53:48 (6 years ago)
Author:
lmajano
Message:

Ticket #88, #89
Solved.

Location:
coldbox/trunk/src/system
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • coldbox/trunk/src/system/beans/datasourceBean.cfc

    r362 r376  
    99 
    1010Modification History: 
    11  
     1101/28/2007 - Added the alias property and solved the java contract with correct arg. 
    1212-----------------------------------------------------------------------> 
    1313<cfcomponent name="datasourceBean" hint="I model a datasource connection setting." output="false"> 
     
    1717                variables.instance = structnew(); 
    1818                variables.instance.name = ""; 
     19                variables.instance.alias = ""; 
    1920                variables.instance.dbtype = ""; 
    2021                variables.instance.username = ""; 
     
    5253         
    5354        <cffunction name="setname" access="public" return="void" output="false" hint="Set name of the datasource, this maps to the Coldfusion datasource name"> 
    54           <cfargument name="value" type="string" > 
    55           <cfset variables.instance.name=arguments.value > 
     55          <cfargument name="name" type="string" required="true"> 
     56          <cfset variables.instance.name=arguments.name > 
    5657        </cffunction> 
    5758         
     
    6465        <!--- ************************************************************* ---> 
    6566         
     67        <cffunction name="setalias" access="public" return="void" output="false" hint="Set alias of the datasource, this is used for reference to the structure."> 
     68          <cfargument name="alias" type="string" required="true"> 
     69          <cfset variables.instance.alias=arguments.alias > 
     70        </cffunction> 
     71         
     72        <!--- ************************************************************* ---> 
     73         
     74        <cffunction name="getalias" access="public" return="string" output="false" hint="Get the alias"> 
     75          <cfreturn variables.instance.name > 
     76        </cffunction> 
     77         
     78        <!--- ************************************************************* ---> 
     79         
    6680        <cffunction name="setDBType" access="public" return="void" output="false" hint="Set DBType"> 
    67           <cfargument name="value" type="string" > 
    68           <cfset variables.instance.dbtype=arguments.value > 
     81          <cfargument name="dbtype" type="string" required="true"> 
     82          <cfset variables.instance.dbtype=arguments.dbtype > 
    6983        </cffunction> 
    7084         
     
    7892         
    7993        <cffunction name="setUsername" access="public" return="void" output="false" hint="Set Username"> 
    80           <cfargument name="value" type="string" > 
    81           <cfset variables.instance.Username=arguments.value > 
     94          <cfargument name="Username" type="string" required="true"> 
     95          <cfset variables.instance.Username=arguments.Username > 
    8296        </cffunction> 
    8397         
     
    91105         
    92106        <cffunction name="setPassword" access="public" return="void" output="false" hint="Set Password"> 
    93           <cfargument name="value" type="string" > 
    94           <cfset variables.instance.Password=arguments.value > 
     107          <cfargument name="Password" type="string" required="true" > 
     108          <cfset variables.instance.Password=arguments.Password > 
    95109        </cffunction> 
    96110         
  • coldbox/trunk/src/system/config/config.xsd

    r371 r376  
    5858                                                                        <xs:enumeration value="onInvalidEvent"/>         
    5959                                                                        <xs:enumeration value="HandlerCaching" /> 
     60                                                                        <xs:enumeration value="IOCFramework" /> 
     61                                                                        <xs:enumeration value="IOCDefinitionFile" /> 
    6062                                                                </xs:restriction> 
    6163                                                        </xs:simpleType> 
     
    294296                </xs:annotation> 
    295297                <xs:complexType> 
     298                        <xs:attribute name="alias" type="xs:string" use="required"> 
     299                                <xs:annotation> 
     300                                        <xs:documentation>The alias of the registered datasource, for use in your application.</xs:documentation> 
     301                                </xs:annotation> 
     302                        </xs:attribute> 
    296303                        <xs:attribute name="name" type="xs:string" use="required"> 
    297304                                <xs:annotation> 
  • coldbox/trunk/src/system/plugins/XMLParser.cfc

    r371 r376  
    292901/17/2007 - fixed Bug #83, failure to set handler invocation path if / as first char 
    303001/18/2007 - Preparing for new event registration system. 
     3101/26/2007 - Datasource Alias and error checking Ticket #88, #89 
    3132-----------------------------------------------------------------------> 
    3233<cfcomponent name="XMLParser" 
     
    440441                                for(i=1;i lte ArrayLen(DatasourcesNodes); i=i+1){ 
    441442                                        DSNStruct = structNew(); 
    442                                         StructInsert(DSNStruct,"Name", Trim(DatasourcesNodes[i].XMLAttributes["name"])); 
    443                                         StructInsert(DSNStruct,"DBType", Trim(DatasourcesNodes[i].XMLAttributes["dbtype"])); 
    444                                         StructInsert(DSNStruct,"Username", Trim(DatasourcesNodes[i].XMLAttributes["username"])); 
    445                                         StructInsert(DSNStruct,"Password", Trim(DatasourcesNodes[i].XMLAttributes["password"])); 
     443                                         
     444                                        //Required Entries 
     445                                        if ( not structKeyExists(DatasourcesNodes[i].XMLAttributes, "Alias") or len(Trim(DatasourcesNodes[i].XMLAttributes["Alias"])) eq 0 ) 
     446                                                throw("This datasource entry's alias cannot be blank","","Framework.plugins.XMLParser.ConfigXMLParsingException"); 
     447                                        else 
     448                                                StructInsert(DSNStruct,"Alias", Trim(DatasourcesNodes[i].XMLAttributes["Alias"])); 
     449                                        if ( not structKeyExists(DatasourcesNodes[i].XMLAttributes, "Name") or len(Trim(DatasourcesNodes[i].XMLAttributes["Name"])) eq 0 ) 
     450                                                throw("This datasource entry's name cannot be blank","","Framework.plugins.XMLParser.ConfigXMLParsingException"); 
     451                                        else 
     452                                                StructInsert(DSNStruct,"Name", Trim(DatasourcesNodes[i].XMLAttributes["Name"])); 
     453                                         
     454                                        //Optional Entries. 
     455                                        if ( structKeyExists(DatasourcesNodes[i].XMLAttributes, "dbtype") ) 
     456                                                StructInsert(DSNStruct,"DBType", Trim(DatasourcesNodes[i].XMLAttributes["dbtype"])); 
     457                                        else 
     458                                                StructInsert(DSNStruct,"DBType",""); 
     459                                        if ( structKeyExists(DatasourcesNodes[i].XMLAttributes, "Username") ) 
     460                                                StructInsert(DSNStruct,"Username", Trim(DatasourcesNodes[i].XMLAttributes["username"])); 
     461                                        else 
     462                                                StructInsert(DSNStruct,"Username",""); 
     463                                        if ( structKeyExists(DatasourcesNodes[i].XMLAttributes, "password") ) 
     464                                                StructInsert(DSNStruct,"Password", Trim(DatasourcesNodes[i].XMLAttributes["password"])); 
     465                                        else 
     466                                                StructInsert(DSNStruct,"Password",""); 
     467                                         
    446468                                        //Insert to structure 
    447                                         if ( not structKeyExists(DatasourcesStruct,DSNStruct.name) ) 
    448                                                 StructInsert(DatasourcesStruct, DSNStruct.name , DSNStruct); 
    449                                         else 
    450                                                 throw("The datasource name: #dsnStruct.name# has already been declared.","","Framework.plugins.XMLParser.ConfigXMLParsingException"); 
     469                                        if ( not structKeyExists(DatasourcesStruct,DSNStruct.Alias) ) 
     470                                                StructInsert(DatasourcesStruct, DSNStruct.Alias , DSNStruct); 
     471                                        else 
     472                                                throw("The datasource alias: #dsnStruct.Alias# has already been declared.","","Framework.plugins.XMLParser.ConfigXMLParsingException"); 
    451473                                } 
    452474                        } 
  • coldbox/trunk/src/system/util/actioncontroller.cfc

    r373 r376  
    161610/10/2006 - Mail settings updated. 
    171712/08/2006 - Refactored. 
     1801/28/2006 - Datasource Alias resolved. 
    1819-----------------------------------------------------------------------> 
    1920<cfcomponent name="actioncontroller" hint="This is the action controller cfc. Method implementations are done here for sharing between plugin and event handler controllers." output="false" extends="coldbox.system.controller"> 
     
    168169        <cffunction name="getDatasource" access="public" output="false" returnType="any" hint="I will return to you a datasourceBean according to the name of the datasource you wish to get from the configstruct (config.xml)"> 
    169170                <!--- ************************************************************* ---> 
    170                 <cfargument name="name" type="string" hint="The name of the datasource to get from the configstruct (name property in the config.xml)"> 
     171                <cfargument name="alias" type="string" hint="The alias of the datasource to get from the configstruct (alias property in the config.xml)"> 
    171172                <!--- ************************************************************* ---> 
    172173                <cfscript> 
     
    177178                } 
    178179                //Try to get the correct datasource. 
    179                 if ( structKeyExists(datasources, arguments.name) ){ 
    180                         return getPlugin("beanFactory").create("coldbox.system.beans.datasourceBean").init(datasources[arguments.name]); 
     180                if ( structKeyExists(datasources, arguments.alias) ){ 
     181                        return getPlugin("beanFactory").create("coldbox.system.beans.datasourceBean").init(datasources[arguments.alias]); 
    181182                } 
    182183                else{ 
    183                         throw("The datasource: #arguments.name# is not defined.","","Framework.actioncontroller.DatasourceNotFoundException"); 
     184                        throw("The datasource: #arguments.alias# is not defined.","","Framework.actioncontroller.DatasourceNotFoundException"); 
    184185                } 
    185186                </cfscript>