@@ -67,13 +67,11 @@ angularAPP.controller('CreateConnectorCtrl', function ($scope, $rootScope, $http
6767
6868 flatValuesArray = $scope . formValuesPerSection . split ( '\n' ) ;
6969 config = NewConnectorFactory . getJSONConfigFlat ( flatValuesArray ) ;
70- //console.log(flatValuesArray);
71- // var classname = $scope.connector.class;
70+
71+ // Make sure the ' classname' is a valid one - as it can crash the connect services
7272 var classname = flatValuesArray . find ( function ( p ) {
73- //console.log(p.indexOf("connector.class"));
7473 return ( p . indexOf ( "connector.class=" ) == 0 )
7574 } ) . split ( 'connector.class=' ) . join ( '' ) ;
76- //console.log("classname is -> " + classname);
7775 if ( classname != $scope . connector . class ) {
7876 console . log ( "error in classname -> " + classname ) ;
7977 var errors = { errors : [ 'Classname "' + $scope . connector . class + '" is not defined' ] } ;
@@ -97,13 +95,22 @@ angularAPP.controller('CreateConnectorCtrl', function ($scope, $rootScope, $http
9795 //STEP 2: Get errors if any
9896 $scope . validConfig = '' ;
9997 var validConnectorConfigKeys = [ ] ;
98+ var requiredConfigKeys = [ ] ;
10099 angular . forEach ( data . configs , function ( config ) {
100+ //console.log("c-> " + config.value.name);
101+ //console.log(config);
101102 if ( config . value . errors . length > 0 ) {
102103 errorConfigs . push ( config . value ) ;
103104 $log . info ( config . value . name + ' : ' + config . value . errors [ 0 ] ) ;
104105 }
106+ //console.log("config.value -> ");
107+ if ( config . definition . required == true ) {
108+ requiredConfigKeys . push ( config . value . name ) ;
109+ }
110+ //console.log("Required/compulsory config keys: " + requiredConfigKeys);
105111 validConnectorConfigKeys . push ( config . value . name ) ;
106112 } ) ;
113+ //console.log("validConnectorConfigKeys -> " + validConnectorConfigKeys);
107114 angular . forEach ( flatValuesArray , function ( propertyLine ) {
108115 if ( propertyLine . length > 0 ) {
109116 if ( ( propertyLine . indexOf ( "=" ) == - 1 ) | ( propertyLine . length < 3 ) ) {
@@ -125,6 +132,20 @@ angularAPP.controller('CreateConnectorCtrl', function ($scope, $rootScope, $http
125132 }
126133 }
127134 } ) ;
135+ // Now check the other way around. Whether a required property is not set
136+ angular . forEach ( requiredConfigKeys , function ( requiredKey ) {
137+ var x = flatValuesArray . find ( function ( p ) {
138+ var result = ( p . indexOf ( requiredKey ) == 0 ) ;
139+ console . log ( result + " " + p ) ;
140+ return result
141+ } ) ;
142+ //console.log("x " + requiredKey + " " + x)
143+ if ( x == undefined ) {
144+ var errors = { errors : [ 'Required config "' + requiredKey + '" is not there' ] } ;
145+ errorConfigs . push ( errors ) ;
146+ } ;
147+ } ) ;
148+
128149 if ( errorConfigs == 0 ) {
129150 $scope . validConfig = constants . VIEW_MESSAGE_CONNECTOR_VALID ;
130151 $scope . curlCommand = NewConnectorFactory . getCurlCommand ( flatValuesArray ) ;
@@ -143,13 +164,12 @@ angularAPP.controller('CreateConnectorCtrl', function ($scope, $rootScope, $http
143164 console.log(flatKeysUsed);
144165 console.log(errorConfigs);
145166 */
146- } , function ( data , reason ) {
167+ } ,
168+ function error ( data , reason ) {
147169 $log . error ( 'Failure : ' + data ) ;
148170 deferred . reject ( data ) ;
149-
150171 } ) ;
151172 return deferred . promise ;
152-
153173 }
154174
155175 $scope . validateConnector = function ( ) {
0 commit comments