33import de .rwth .idsg .steve .service .ChargePointService12_Client ;
44import de .rwth .idsg .steve .service .ChargePointService15_Client ;
55import de .rwth .idsg .steve .service .ChargePointService16_Client ;
6+ import de .rwth .idsg .steve .web .dto .ocpp .ChangeConfigurationParams ;
67import de .rwth .idsg .steve .web .dto .ocpp .ConfigurationKeyEnum ;
8+ import de .rwth .idsg .steve .web .dto .ocpp .GetConfigurationParams ;
79import org .springframework .beans .factory .annotation .Autowired ;
810import org .springframework .beans .factory .annotation .Qualifier ;
911import org .springframework .stereotype .Controller ;
1012import org .springframework .ui .Model ;
13+ import org .springframework .validation .BindingResult ;
14+ import org .springframework .web .bind .annotation .ModelAttribute ;
1115import org .springframework .web .bind .annotation .RequestMapping ;
1216import org .springframework .web .bind .annotation .RequestMethod ;
1317
18+ import javax .validation .Valid ;
19+ import java .util .Collections ;
1420import java .util .Map ;
1521
1622/**
@@ -58,10 +64,15 @@ protected void setCommonAttributes(Model model) {
5864 model .addAttribute ("opVersion" , "v1.6" );
5965 }
6066
67+ /**
68+ * Starting with OCPP 1.6 the configuration keys can be read-only or read-write. This method was returning all
69+ * read-write keys, which was the case with older OCPP versions. So, it does not meet the needs anymore and should
70+ * not be used.
71+ */
72+ @ Deprecated
6173 @ Override
6274 protected Map <String , String > getConfigurationKeys () {
63- // TODO: will fix/change this later.
64- return ConfigurationKeyEnum .OCPP_15_MAP ;
75+ return Collections .emptyMap ();
6576 }
6677
6778 @ Override
@@ -75,7 +86,38 @@ protected String getPrefix() {
7586 }
7687
7788 // -------------------------------------------------------------------------
78- // Http methods (GET)
89+ // Old Http methods with changed logic
90+ // -------------------------------------------------------------------------
91+
92+ @ RequestMapping (value = GET_CONF_PATH , method = RequestMethod .GET )
93+ public String getGetConf (Model model ) {
94+ setCommonAttributes (model );
95+ model .addAttribute (PARAMS , new GetConfigurationParams ());
96+ model .addAttribute ("ocppConfKeys" , ConfigurationKeyEnum .OCPP_16_MAP_R );
97+ return getPrefix () + GET_CONF_PATH ;
98+ }
99+
100+ @ RequestMapping (value = CHANGE_CONF_PATH , method = RequestMethod .GET )
101+ public String getChangeConf (Model model ) {
102+ setCommonAttributes (model );
103+ model .addAttribute (PARAMS , new ChangeConfigurationParams ());
104+ model .addAttribute ("ocppConfKeys" , ConfigurationKeyEnum .OCPP_16_MAP_RW );
105+ return getPrefix () + CHANGE_CONF_PATH ;
106+ }
107+
108+ @ RequestMapping (value = GET_CONF_PATH , method = RequestMethod .POST )
109+ public String postGetConf (@ Valid @ ModelAttribute (PARAMS ) GetConfigurationParams params ,
110+ BindingResult result , Model model ) {
111+ if (result .hasErrors ()) {
112+ setCommonAttributes (model );
113+ model .addAttribute ("ocppConfKeys" , ConfigurationKeyEnum .OCPP_16_MAP_R );
114+ return getPrefix () + GET_CONF_PATH ;
115+ }
116+ return REDIRECT_TASKS_PATH + getClient15 ().getConfiguration (params );
117+ }
118+
119+ // -------------------------------------------------------------------------
120+ // New Http methods (GET)
79121 // -------------------------------------------------------------------------
80122
81123 @ RequestMapping (value = GET_COMPOSITE_PATH , method = RequestMethod .GET )
0 commit comments