← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20523: Added api/configuration get endpoint

 

------------------------------------------------------------
revno: 20523
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-10-06 16:23:01 +0200
message:
  Added api/configuration get endpoint
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConfigurationController.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/configuration/Configuration.java	2015-10-06 14:23:01 +0000
@@ -31,6 +31,8 @@
 import java.io.Serializable;
 
 import org.hisp.dhis.indicator.IndicatorGroup;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
@@ -39,6 +41,10 @@
 import org.hisp.dhis.user.UserAuthorityGroup;
 import org.hisp.dhis.user.UserGroup;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+
 /**
  * @author Lars Helge Overland
  */
@@ -125,7 +131,9 @@
     {
         this.id = id;
     }
-
+    
+    @JsonProperty
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getSystemId()
     {
         return systemId;
@@ -136,6 +144,9 @@
         this.systemId = systemId;
     }
 
+    @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public UserGroup getFeedbackRecipients()
     {
         return feedbackRecipients;
@@ -146,16 +157,22 @@
         this.feedbackRecipients = feedbackRecipients;
     }
 
+    @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public OrganisationUnitLevel getOfflineOrganisationUnitLevel()
+    {
+        return offlineOrganisationUnitLevel;
+    }
+    
     public void setOfflineOrganisationUnitLevel( OrganisationUnitLevel offlineOrganisationUnitLevel )
     {
         this.offlineOrganisationUnitLevel = offlineOrganisationUnitLevel;
     }
 
-    public OrganisationUnitLevel getOfflineOrganisationUnitLevel()
-    {
-        return offlineOrganisationUnitLevel;
-    }
-
+    @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public IndicatorGroup getInfrastructuralIndicators()
     {
         return infrastructuralIndicators;
@@ -166,6 +183,9 @@
         this.infrastructuralIndicators = infrastructuralIndicators;
     }
 
+    @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public DataElementGroup getInfrastructuralDataElements()
     {
         return infrastructuralDataElements;
@@ -176,6 +196,8 @@
         this.infrastructuralDataElements = infrastructuralDataElements;
     }
 
+    @JsonProperty
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public PeriodType getInfrastructuralPeriodType()
     {
         return infrastructuralPeriodType;
@@ -186,6 +208,9 @@
         this.infrastructuralPeriodType = infrastructuralPeriodType;
     }
 
+    @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public UserAuthorityGroup getSelfRegistrationRole()
     {
         return selfRegistrationRole;
@@ -196,6 +221,9 @@
         this.selfRegistrationRole = selfRegistrationRole;
     }
 
+    @JsonProperty
+    @JsonSerialize( as = BaseIdentifiableObject.class )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public OrganisationUnit getSelfRegistrationOrgUnit()
     {
         return selfRegistrationOrgUnit;
@@ -206,6 +234,8 @@
         this.selfRegistrationOrgUnit = selfRegistrationOrgUnit;
     }
 
+    @JsonProperty
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getRemoteServerUrl()
     {
         return remoteServerUrl;
@@ -216,6 +246,8 @@
         this.remoteServerUrl = remoteServerUrl;
     }
 
+    @JsonProperty
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getRemoteServerUsername()
     {
         return remoteServerUsername;

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConfigurationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConfigurationController.java	2015-10-02 15:18:05 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ConfigurationController.java	2015-10-06 14:23:01 +0000
@@ -73,6 +73,12 @@
     // Resources
     // -------------------------------------------------------------------------
 
+    @RequestMapping( method = RequestMethod.GET )
+    public String getConfiguration( Model model, HttpServletRequest request )
+    {
+        return setModel( model, configurationService.getConfiguration() );
+    }
+    
     @PreAuthorize( "hasRole('ALL') or hasRole('F_SYSTEM_SETTING')" )
     @ResponseStatus( value = HttpStatus.OK )
     @RequestMapping( value = "/systemId", method = RequestMethod.GET )
@@ -242,7 +248,6 @@
         configurationService.setConfiguration( config );
     }
 
-    @ResponseStatus( value = HttpStatus.OK )
     @RequestMapping( value = "/selfRegistrationOrgUnit", method = RequestMethod.GET )
     public String getSelfRegistrationOrgUnit( Model model, HttpServletRequest request )
     {
@@ -280,6 +285,12 @@
         configurationService.setConfiguration( config );
     }    
 
+    @RequestMapping( value = "/remoteServerUrl", method = RequestMethod.GET )
+    public String getRemoteServerUrl( Model model, HttpServletRequest request )
+    {
+        return setModel( model, configurationService.getConfiguration().getRemoteServerUrl() );
+    }
+    
     @PreAuthorize( "hasRole('ALL') or hasRole('F_SYSTEM_SETTING')" )
     @ResponseStatus( value = HttpStatus.OK )
     @RequestMapping( value = "/remoteServerUrl/{url}", method = RequestMethod.POST )
@@ -292,6 +303,12 @@
         configurationService.setConfiguration( config );
     }
 
+    @RequestMapping( value = "/remoteServerUsername", method = RequestMethod.GET )
+    public String getRemoteServerUsername( Model model, HttpServletRequest request )
+    {
+        return setModel( model, configurationService.getConfiguration().getRemoteServerUsername() );
+    }
+    
     @PreAuthorize( "hasRole('ALL') or hasRole('F_SYSTEM_SETTING')" )
     @ResponseStatus( value = HttpStatus.OK )
     @RequestMapping( value = "/remoteServerUsername/{username}", method = RequestMethod.POST )
@@ -323,7 +340,6 @@
     private String setModel( Model model, Object entity )
     {
         model.addAttribute( "model", entity );
-        model.addAttribute( "viewClass", "detailed" );
         return "config";
     }
 }