dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #34792
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17845: minor fixes in controllers
------------------------------------------------------------
revno: 17845
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-12-30 18:28:02 +0100
message:
minor fixes in controllers
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IdentifiableObjectController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/InterpretationController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapLegendSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserController.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-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2014-12-30 16:05:57 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2014-12-30 17:28:02 +0000
@@ -76,7 +76,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.io.InputStream;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.ArrayList;
@@ -130,13 +129,13 @@
//--------------------------------------------------------------------------
@RequestMapping( method = RequestMethod.GET )
- public @ResponseBody RootNode getObjectList( @RequestParam Map<String, String> parameters,
- HttpServletResponse response, HttpServletRequest request )
+ public @ResponseBody RootNode getObjectList(
+ @RequestParam Map<String, String> rpParameters, HttpServletResponse response, HttpServletRequest request )
{
List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
List<String> filters = Lists.newArrayList( contextService.getParameterValues( "filter" ) );
- WebOptions options = new WebOptions( parameters );
+ WebOptions options = new WebOptions( rpParameters );
WebMetaData metaData = new WebMetaData();
Schema schema = getSchema();
@@ -222,7 +221,7 @@
}
postProcessEntities( entityList );
- postProcessEntities( entityList, options, parameters );
+ postProcessEntities( entityList, options, rpParameters );
if ( fields.contains( "access" ) )
{
@@ -237,7 +236,7 @@
rootNode.setDefaultNamespace( DxfNamespaces.DXF_2_0 );
rootNode.setNamespace( DxfNamespaces.DXF_2_0 );
- rootNode.getConfig().setInclusionStrategy( getInclusionStrategy( parameters.get( "inclusionStrategy" ) ) );
+ rootNode.getConfig().setInclusionStrategy( getInclusionStrategy( rpParameters.get( "inclusionStrategy" ) ) );
if ( pager != null )
{
@@ -256,8 +255,7 @@
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
public @ResponseBody RootNode getObject(
- @PathVariable( "uid" ) String pvUid,
- @RequestParam Map<String, String> parameters,
+ @PathVariable( "uid" ) String pvUid, @RequestParam Map<String, String> rpParameters,
HttpServletRequest request, HttpServletResponse response ) throws Exception
{
List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
@@ -268,25 +266,23 @@
fields.add( ":all" );
}
- return getObjectInternal( pvUid, parameters, filters, fields );
+ return getObjectInternal( pvUid, rpParameters, filters, fields );
}
@RequestMapping( value = "/{uid}/{property}", method = RequestMethod.GET )
public @ResponseBody RootNode getObjectProperty(
- @PathVariable( "uid" ) String pvUid,
- @PathVariable( "property" ) String pvProperty,
- @RequestParam Map<String, String> parameters, HttpServletRequest request, HttpServletResponse response ) throws Exception
+ @PathVariable( "uid" ) String pvUid, @PathVariable( "property" ) String pvProperty, @RequestParam Map<String, String> rpParameters,
+ HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- return getObjectInternal( pvUid, parameters, Lists.<String>newArrayList(), Lists.newArrayList( pvProperty + "[:all]" ) );
+ return getObjectInternal( pvUid, rpParameters, Lists.<String>newArrayList(), Lists.newArrayList( pvProperty + "[:all]" ) );
}
@RequestMapping( value = "/{uid}/{property}", method = { RequestMethod.PUT, RequestMethod.PATCH } )
public void updateObjectProperty(
- @PathVariable( "uid" ) String pvUid,
- @PathVariable( "property" ) String pvProperty,
- @RequestParam Map<String, String> parameters, HttpServletRequest request, HttpServletResponse response ) throws Exception
+ @PathVariable( "uid" ) String pvUid, @PathVariable( "property" ) String pvProperty, @RequestParam Map<String, String> rpParameters,
+ HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- WebOptions options = new WebOptions( parameters );
+ WebOptions options = new WebOptions( rpParameters );
List<T> entities = getEntity( pvUid, options );
if ( entities.isEmpty() )
@@ -389,7 +385,7 @@
//--------------------------------------------------------------------------
@RequestMapping( method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } )
- public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input )
+ public void postXmlObject( HttpServletRequest request, HttpServletResponse response )
throws Exception
{
if ( !aclService.canCreate( currentUserService.getCurrentUser(), getEntityClass() ) )
@@ -418,7 +414,7 @@
}
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input )
+ public void postJsonObject( HttpServletRequest request, HttpServletResponse response )
throws Exception
{
if ( !aclService.canCreate( currentUserService.getCurrentUser(), getEntityClass() ) )
@@ -451,14 +447,13 @@
//--------------------------------------------------------------------------
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = { MediaType.APPLICATION_XML_VALUE, MediaType.TEXT_XML_VALUE } )
- public void putXmlObject( HttpServletResponse response, HttpServletRequest request,
- @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ public void putXmlObject( @PathVariable( "uid" ) String pvUid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- List<T> objects = getEntity( uid );
+ List<T> objects = getEntity( pvUid );
if ( objects.isEmpty() )
{
- ContextUtils.notFoundResponse( response, getEntityName() + " does not exist: " + uid );
+ ContextUtils.notFoundResponse( response, getEntityName() + " does not exist: " + pvUid );
return;
}
@@ -468,7 +463,7 @@
}
T parsed = renderService.fromXml( request.getInputStream(), getEntityClass() );
- ((BaseIdentifiableObject) parsed).setUid( uid );
+ ((BaseIdentifiableObject) parsed).setUid( pvUid );
preUpdateEntity( parsed );
@@ -483,14 +478,13 @@
}
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE )
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request,
- @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ public void putJsonObject( @PathVariable( "uid" ) String pvUid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- List<T> objects = getEntity( uid );
+ List<T> objects = getEntity( pvUid );
if ( objects.isEmpty() )
{
- ContextUtils.notFoundResponse( response, getEntityName() + " does not exist: " + uid );
+ ContextUtils.notFoundResponse( response, getEntityName() + " does not exist: " + pvUid );
return;
}
@@ -500,7 +494,7 @@
}
T parsed = renderService.fromJson( request.getInputStream(), getEntityClass() );
- ((BaseIdentifiableObject) parsed).setUid( uid );
+ ((BaseIdentifiableObject) parsed).setUid( pvUid );
preUpdateEntity( parsed );
@@ -519,14 +513,13 @@
//--------------------------------------------------------------------------
@RequestMapping( value = "/{uid}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE )
- public void deleteObject( HttpServletResponse response, HttpServletRequest request,
- @PathVariable( "uid" ) String uid ) throws Exception
+ public void deleteObject( @PathVariable( "uid" ) String pvUid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- List<T> objects = getEntity( uid );
+ List<T> objects = getEntity( pvUid );
if ( objects.isEmpty() )
{
- ContextUtils.notFoundResponse( response, getEntityName() + " does not exist: " + uid );
+ ContextUtils.notFoundResponse( response, getEntityName() + " does not exist: " + pvUid );
return;
}
@@ -551,7 +544,8 @@
@PathVariable( "uid" ) String pvUid,
@PathVariable( "property" ) String pvProperty,
@PathVariable( "itemId" ) String pvItemId,
- @RequestParam Map<String, String> parameters, HttpServletResponse response ) throws Exception
+ @RequestParam Map<String, String> parameters,
+ HttpServletRequest request, HttpServletResponse response ) throws Exception
{
RootNode rootNode = getObjectInternal( pvUid, parameters, Lists.<String>newArrayList(), Lists.newArrayList( pvProperty + "[:all]" ) );
@@ -584,7 +578,8 @@
public void addCollectionItem(
@PathVariable( "uid" ) String pvUid,
@PathVariable( "property" ) String pvProperty,
- @PathVariable( "itemId" ) String pvItemId, HttpServletResponse response ) throws Exception
+ @PathVariable( "itemId" ) String pvItemId,
+ HttpServletRequest request, HttpServletResponse response ) throws Exception
{
List<T> objects = getEntity( pvUid );
@@ -650,7 +645,8 @@
public void deleteCollectionItem(
@PathVariable( "uid" ) String pvUid,
@PathVariable( "property" ) String pvProperty,
- @PathVariable( "itemId" ) String pvItemId, HttpServletResponse response ) throws Exception
+ @PathVariable( "itemId" ) String pvItemId,
+ HttpServletRequest request, HttpServletResponse response ) throws Exception
{
List<T> objects = getEntity( pvUid );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java 2014-11-26 12:43:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ChartController.java 2014-12-30 17:28:02 +0000
@@ -113,9 +113,9 @@
@Override
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postJsonObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- Chart chart = JacksonUtils.fromJson( input, Chart.class );
+ Chart chart = JacksonUtils.fromJson( request.getInputStream(), Chart.class );
mergeChart( chart );
@@ -126,7 +126,7 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ public void putJsonObject( @PathVariable( "uid" ) String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
Chart chart = chartService.getChart( uid );
@@ -136,7 +136,7 @@
return;
}
- Chart newChart = JacksonUtils.fromJson( input, Chart.class );
+ Chart newChart = JacksonUtils.fromJson( request.getInputStream(), Chart.class );
mergeChart( newChart );
@@ -147,7 +147,7 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
+ public void deleteObject( @PathVariable( "uid" ) String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
Chart chart = chartService.getChart( uid );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java 2014-11-11 12:51:06 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java 2014-12-30 17:28:02 +0000
@@ -80,9 +80,9 @@
@Override
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postJsonObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- Dashboard dashboard = JacksonUtils.fromJson( input, Dashboard.class );
+ Dashboard dashboard = JacksonUtils.fromJson( request.getInputStream(), Dashboard.class );
dashboardService.mergeDashboard( dashboard );
dashboardService.saveDashboard( dashboard );
@@ -92,17 +92,17 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ public void putJsonObject( @PathVariable( "uid" ) String pvUid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- Dashboard dashboard = dashboardService.getDashboard( uid );
+ Dashboard dashboard = dashboardService.getDashboard( pvUid );
if ( dashboard == null )
{
- ContextUtils.notFoundResponse( response, "Dashboard does not exist: " + uid );
+ ContextUtils.notFoundResponse( response, "Dashboard does not exist: " + pvUid );
return;
}
- Dashboard newDashboard = JacksonUtils.fromJson( input, Dashboard.class );
+ Dashboard newDashboard = JacksonUtils.fromJson( request.getInputStream(), Dashboard.class );
dashboard.setName( newDashboard.getName() ); // TODO Name only for now
@@ -111,14 +111,14 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE )
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid )
+ public void deleteObject( @PathVariable( "uid" ) String pvUid, HttpServletRequest request, HttpServletResponse response )
throws Exception
{
- List<Dashboard> objects = getEntity( uid );
+ List<Dashboard> objects = getEntity( pvUid );
if ( objects.isEmpty() )
{
- ContextUtils.conflictResponse( response, getEntityName() + " does not exist: " + uid );
+ ContextUtils.conflictResponse( response, getEntityName() + " does not exist: " + pvUid );
return;
}
@@ -131,8 +131,7 @@
}
@RequestMapping( value = "/{uid}/items", method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonItem( HttpServletResponse response, HttpServletRequest request,
- InputStream input, @PathVariable String uid ) throws Exception
+ public void postJsonItem( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
Dashboard dashboard = dashboardService.getDashboard( uid );
@@ -142,7 +141,7 @@
return;
}
- DashboardItem item = JacksonUtils.fromJson( input, DashboardItem.class );
+ DashboardItem item = JacksonUtils.fromJson( request.getInputStream(), DashboardItem.class );
dashboardService.mergeDashboardItem( item );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IdentifiableObjectController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IdentifiableObjectController.java 2014-11-11 12:51:06 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/IdentifiableObjectController.java 2014-12-30 17:28:02 +0000
@@ -39,7 +39,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.InputStream;
import java.util.List;
/**
@@ -67,25 +66,25 @@
}
@Override
- public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
- {
- throw new HttpRequestMethodNotSupportedException( "POST" );
- }
-
- @Override
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
- {
- throw new HttpRequestMethodNotSupportedException( "POST" );
- }
-
- @Override
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ public void postXmlObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( "POST" );
+ }
+
+ @Override
+ public void postJsonObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
+ {
+ throw new HttpRequestMethodNotSupportedException( "POST" );
+ }
+
+ @Override
+ public void putJsonObject( @PathVariable( "uid" ) String pvUid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
throw new HttpRequestMethodNotSupportedException( "PUT" );
}
@Override
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
+ public void deleteObject( @PathVariable( "uid" ) String pvUid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
throw new HttpRequestMethodNotSupportedException( "PUT" );
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/InterpretationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/InterpretationController.java 2014-11-24 12:30:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/InterpretationController.java 2014-12-30 17:28:02 +0000
@@ -246,7 +246,7 @@
}
@Override
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
+ public void deleteObject( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
Interpretation interpretation = interpretationService.getInterpretation( uid );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java 2014-11-25 11:51:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java 2014-12-30 17:28:02 +0000
@@ -31,7 +31,6 @@
import com.google.common.collect.Lists;
import org.hisp.dhis.acl.AclService;
import org.hisp.dhis.common.Pager;
-import org.hisp.dhis.webapi.webdomain.MessageConversation;
import org.hisp.dhis.dxf2.utils.JacksonUtils;
import org.hisp.dhis.hibernate.exception.DeleteAccessDeniedException;
import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
@@ -48,6 +47,7 @@
import org.hisp.dhis.user.UserGroupService;
import org.hisp.dhis.user.UserService;
import org.hisp.dhis.webapi.utils.ContextUtils;
+import org.hisp.dhis.webapi.webdomain.MessageConversation;
import org.hisp.dhis.webapi.webdomain.WebMetaData;
import org.hisp.dhis.webapi.webdomain.WebOptions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -64,7 +64,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -106,12 +105,12 @@
}
@Override
- public RootNode getObject( @PathVariable String uid, Map<String, String> parameters, HttpServletRequest request, HttpServletResponse response )
+ public RootNode getObject( @PathVariable String uid, Map<String, String> rpParameters, HttpServletRequest request, HttpServletResponse response )
throws Exception
{
org.hisp.dhis.message.MessageConversation messageConversation = messageService.getMessageConversation( uid );
- if( messageConversation == null )
+ if ( messageConversation == null )
{
response.setStatus( HttpServletResponse.SC_NOT_FOUND );
RootNode responseNode = new RootNode( "reply" );
@@ -119,12 +118,12 @@
return responseNode;
}
- if( !canReadMessageConversation( currentUserService.getCurrentUser(), messageConversation ) )
+ if ( !canReadMessageConversation( currentUserService.getCurrentUser(), messageConversation ) )
{
throw new AccessDeniedException( "Not authorized to access this conversation." );
}
- return super.getObject( uid, parameters, request, response );
+ return super.getObject( uid, rpParameters, request, response );
}
@Override
@@ -158,16 +157,16 @@
//--------------------------------------------------------------------------
@Override
- public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postXmlObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- MessageConversation messageConversation = JacksonUtils.fromXml( input, MessageConversation.class );
+ MessageConversation messageConversation = JacksonUtils.fromXml( request.getInputStream(), MessageConversation.class );
postObject( response, request, messageConversation );
}
@Override
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postJsonObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- MessageConversation messageConversation = JacksonUtils.fromJson( input, MessageConversation.class );
+ MessageConversation messageConversation = JacksonUtils.fromJson( request.getInputStream(), MessageConversation.class );
postObject( response, request, messageConversation );
}
@@ -378,15 +377,16 @@
/**
* Deletes a MessageConversation.
* Note that this is a HARD delete and therefore requires override authority for the current user.
+ *
* @param uid the uid of the MessageConversation to delete.
* @throws Exception
*/
@Override
@PreAuthorize( "hasRole('ALL') or hasRole('F_METADATA_IMPORT')" )
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable String uid )
+ public void deleteObject( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response )
throws Exception
{
- super.deleteObject( response, request, uid );
+ super.deleteObject( uid, request, response );
}
//--------------------------------------------------------------------------
@@ -410,7 +410,7 @@
return responseNode;
}
- if( !canModifyUserConversation( currentUserService.getCurrentUser(), user ) )
+ if ( !canModifyUserConversation( currentUserService.getCurrentUser(), user ) )
{
throw new DeleteAccessDeniedException( "Not authorized to modify user: " + user.getUid() );
@@ -451,7 +451,7 @@
User currentUser = currentUserService.getCurrentUser();
- User user = userUid == null ? currentUser : userService.getUser( userUid ) ;
+ User user = userUid == null ? currentUser : userService.getUser( userUid );
if ( user == null )
{
@@ -478,7 +478,7 @@
for ( org.hisp.dhis.message.MessageConversation mc : messageConversations )
{
- if( mc.remove( user ) )
+ if ( mc.remove( user ) )
{
messageService.updateMessageConversation( mc );
removed.addChild( new SimpleNode( "uid", mc.getUid() ) );
@@ -496,14 +496,14 @@
/**
* Determines whether the current user has permission to modify the given user in a MessageConversation.
- *
+ * <p/>
* The modification is either marking a conversation read/unread for the user or removing the user from the MessageConversation.
- *
+ * <p/>
* Since there are no per-conversation authorities provided the permission is given if the current user equals the user
* or if the current user has update-permission to User objects.
*
* @param currentUser the current user to check authorization for.
- * @param user the user to remove from a conversation.
+ * @param user the user to remove from a conversation.
* @return true if the current user is allowed to remove the user from a conversation, false otherwise.
*/
private boolean canModifyUserConversation( User currentUser, User user )
@@ -514,7 +514,7 @@
/**
* Determines whether the given user has permission to read the MessageConversation.
*
- * @param user the user to check permission for.
+ * @param user the user to check permission for.
* @param messageConversation the MessageConversation to access.
* @return true if the user can read the MessageConversation, false otherwise.
*/
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java 2014-11-26 12:43:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java 2014-12-30 17:28:02 +0000
@@ -97,9 +97,9 @@
@Override
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postJsonObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- ReportTable reportTable = JacksonUtils.fromJson( input, ReportTable.class );
+ ReportTable reportTable = JacksonUtils.fromJson( request.getInputStream(), ReportTable.class );
mergeReportTable( reportTable );
@@ -110,7 +110,7 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ public void putJsonObject( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
ReportTable reportTable = reportTableService.getReportTable( uid );
@@ -120,7 +120,7 @@
return;
}
- ReportTable newReportTable = JacksonUtils.fromJson( input, ReportTable.class );
+ ReportTable newReportTable = JacksonUtils.fromJson( request.getInputStream(), ReportTable.class );
mergeReportTable( newReportTable );
@@ -131,7 +131,7 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
+ public void deleteObject( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
ReportTable reportTable = reportTableService.getReportTable( uid );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java 2014-11-26 12:43:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventChartController.java 2014-12-30 17:28:02 +0000
@@ -104,9 +104,9 @@
@Override
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postJsonObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- EventChart eventChart = JacksonUtils.fromJson( input, EventChart.class );
+ EventChart eventChart = JacksonUtils.fromJson( request.getInputStream(), EventChart.class );
mergeEventChart( eventChart );
@@ -117,7 +117,7 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ public void putJsonObject( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
EventChart eventChart = eventChartService.getEventChart( uid );
@@ -127,7 +127,7 @@
return;
}
- EventChart newEventChart = JacksonUtils.fromJson( input, EventChart.class );
+ EventChart newEventChart = JacksonUtils.fromJson( request.getInputStream(), EventChart.class );
mergeEventChart( newEventChart );
@@ -138,7 +138,7 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
+ public void deleteObject( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
EventChart eventChart = eventChartService.getEventChart( uid );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java 2014-11-26 12:43:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/EventReportController.java 2014-12-30 17:28:02 +0000
@@ -84,9 +84,9 @@
@Override
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postJsonObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- EventReport report = JacksonUtils.fromJson( input, EventReport.class );
+ EventReport report = JacksonUtils.fromJson( request.getInputStream(), EventReport.class );
mergeEventReport( report );
@@ -97,7 +97,7 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ public void putJsonObject( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
EventReport report = eventReportService.getEventReport( uid );
@@ -107,7 +107,7 @@
return;
}
- EventReport newReport = JacksonUtils.fromJson( input, EventReport.class );
+ EventReport newReport = JacksonUtils.fromJson( request.getInputStream(), EventReport.class );
mergeEventReport( newReport );
@@ -118,7 +118,7 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
+ public void deleteObject( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
EventReport report = eventReportService.getEventReport( uid );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java 2014-11-26 12:43:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapController.java 2014-12-30 17:28:02 +0000
@@ -111,9 +111,9 @@
@Override
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postJsonObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- Map map = JacksonUtils.fromJson( input, Map.class );
+ Map map = JacksonUtils.fromJson( request.getInputStream(), Map.class );
mergeMap( map );
@@ -131,7 +131,7 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ public void putJsonObject( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
Map map = mappingService.getMap( uid );
@@ -150,7 +150,7 @@
mappingService.deleteMapView( view );
}
- Map newMap = JacksonUtils.fromJson( input, Map.class );
+ Map newMap = JacksonUtils.fromJson( request.getInputStream(), Map.class );
mergeMap( newMap );
@@ -173,7 +173,7 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
+ public void deleteObject( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
Map map = mappingService.getMap( uid );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapLegendSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapLegendSetController.java 2014-10-23 10:07:41 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapLegendSetController.java 2014-12-30 17:28:02 +0000
@@ -28,12 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.InputStream;
-import java.util.Iterator;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.hisp.dhis.dxf2.utils.JacksonUtils;
import org.hisp.dhis.mapping.MapLegend;
import org.hisp.dhis.mapping.MapLegendSet;
@@ -48,6 +42,10 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Iterator;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -62,9 +60,9 @@
@Override
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
@PreAuthorize( "hasRole('F_GIS_ADMIN') or hasRole('ALL')" )
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postJsonObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- MapLegendSet legendSet = JacksonUtils.fromJson( input, MapLegendSet.class );
+ MapLegendSet legendSet = JacksonUtils.fromJson( request.getInputStream(), MapLegendSet.class );
for ( MapLegend legend : legendSet.getMapLegends() )
{
@@ -79,7 +77,7 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
@PreAuthorize( "hasRole('F_GIS_ADMIN') or hasRole('ALL')" )
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ public void putJsonObject( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
MapLegendSet legendSet = mappingService.getMapLegendSet( uid );
@@ -98,7 +96,7 @@
mappingService.deleteMapLegend( legend );
}
- MapLegendSet newLegendSet = JacksonUtils.fromJson( input, MapLegendSet.class );
+ MapLegendSet newLegendSet = JacksonUtils.fromJson( request.getInputStream(), MapLegendSet.class );
for ( MapLegend legend : newLegendSet.getMapLegends() )
{
@@ -113,7 +111,7 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.DELETE )
@PreAuthorize( "hasRole('F_GIS_ADMIN') or hasRole('ALL')" )
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable( "uid" ) String uid ) throws Exception
+ public void deleteObject( @PathVariable String uid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
MapLegendSet legendSet = mappingService.getMapLegendSet( uid );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserController.java 2014-12-30 14:29:14 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserController.java 2014-12-30 17:28:02 +0000
@@ -28,14 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
-
-import java.io.InputStream;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import com.google.common.base.Optional;
+import com.google.common.collect.Lists;
import org.hisp.dhis.common.IdentifiableObjectUtils;
import org.hisp.dhis.common.Pager;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
@@ -66,8 +60,11 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
-import com.google.common.base.Optional;
-import com.google.common.collect.Lists;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -86,7 +83,7 @@
@Autowired
private UserGroupService userGroupService;
-
+
@Autowired
private CurrentUserService currentUserService;
@@ -95,10 +92,10 @@
@Autowired
private SystemSettingManager systemSettingManager;
-
+
@Autowired
private OrganisationUnitService organisationUnitService;
-
+
// -------------------------------------------------------------------------
// GET
// -------------------------------------------------------------------------
@@ -116,22 +113,22 @@
params.setInactiveSince( options.getDate( "inactiveSince" ) );
params.setSelfRegistered( options.isTrue( "selfRegistered" ) );
params.setInvitationStatus( UserInvitationStatus.fromValue( options.get( "invitationStatus" ) ) );
-
+
String ou = options.get( "ou" );
-
+
if ( ou != null )
{
- params.setOrganisationUnit( organisationUnitService.getOrganisationUnit( ou ) );
+ params.setOrganisationUnit( organisationUnitService.getOrganisationUnit( ou ) );
}
-
+
if ( options.isManage() )
{
params.setCanManage( true );
params.setAuthSubset( true );
}
-
+
int count = userService.getUserCount( params );
-
+
if ( options.hasPaging() )
{
Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
@@ -139,7 +136,7 @@
params.setFirst( pager.getOffset() );
params.setMax( pager.getPageSize() );
}
-
+
return userService.getUsers( params );
}
@@ -163,7 +160,7 @@
@Override
@RequestMapping( method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } )
- public void postXmlObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postXmlObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
User user = renderService.fromXml( request.getInputStream(), getEntityClass() );
@@ -171,13 +168,13 @@
{
return;
}
-
+
renderService.toXml( response.getOutputStream(), createUser( user, response ) );
}
@Override
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postJsonObject( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
User user = renderService.fromJson( request.getInputStream(), getEntityClass() );
@@ -185,12 +182,12 @@
{
return;
}
-
+
renderService.toJson( response.getOutputStream(), createUser( user, response ) );
}
@RequestMapping( value = INVITE_PATH, method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } )
- public void postXmlInvite( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postXmlInvite( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
User user = renderService.fromXml( request.getInputStream(), getEntityClass() );
@@ -198,12 +195,12 @@
{
return;
}
-
+
renderService.toXml( response.getOutputStream(), inviteUser( user, request, response ) );
}
@RequestMapping( value = INVITE_PATH, method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonInvite( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postJsonInvite( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
User user = renderService.fromJson( request.getInputStream(), getEntityClass() );
@@ -211,12 +208,12 @@
{
return;
}
-
+
renderService.toJson( response.getOutputStream(), inviteUser( user, request, response ) );
}
@RequestMapping( value = BULK_INVITE_PATH, method = RequestMethod.POST, consumes = { "application/xml", "text/xml" } )
- public void postXmlInvites( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postXmlInvites( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
Users users = renderService.fromXml( request.getInputStream(), Users.class );
@@ -227,7 +224,7 @@
return;
}
}
-
+
for ( User user : users.getUsers() )
{
inviteUser( user, request, response );
@@ -235,7 +232,7 @@
}
@RequestMapping( value = BULK_INVITE_PATH, method = RequestMethod.POST, consumes = "application/json" )
- public void postJsonInvites( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
+ public void postJsonInvites( HttpServletRequest request, HttpServletResponse response ) throws Exception
{
Users users = renderService.fromJson( request.getInputStream(), Users.class );
@@ -246,7 +243,7 @@
return;
}
}
-
+
for ( User user : users.getUsers() )
{
inviteUser( user, request, response );
@@ -259,14 +256,13 @@
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = { "application/xml", "text/xml" } )
- public void putXmlObject( HttpServletResponse response, HttpServletRequest request,
- @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ public void putXmlObject( @PathVariable( "uid" ) String pvUid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- List<User> users = getEntity( uid );
+ List<User> users = getEntity( pvUid );
if ( users.isEmpty() )
{
- ContextUtils.conflictResponse( response, getEntityName() + " does not exist: " + uid );
+ ContextUtils.conflictResponse( response, getEntityName() + " does not exist: " + pvUid );
return;
}
@@ -277,7 +273,7 @@
}
User parsed = renderService.fromXml( request.getInputStream(), getEntityClass() );
- parsed.setUid( uid );
+ parsed.setUid( pvUid );
if ( !userService.canAddOrUpdateUser( IdentifiableObjectUtils.getUids( parsed.getGroups() ) ) )
{
@@ -286,20 +282,19 @@
}
ImportTypeSummary summary = importService.importObject( currentUserService.getCurrentUser().getUid(), parsed, ImportStrategy.UPDATE );
-
+
renderService.toXml( response.getOutputStream(), summary );
}
@Override
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = "application/json" )
- public void putJsonObject( HttpServletResponse response, HttpServletRequest request,
- @PathVariable( "uid" ) String uid, InputStream input ) throws Exception
+ public void putJsonObject( @PathVariable( "uid" ) String pvUid, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- List<User> users = getEntity( uid );
+ List<User> users = getEntity( pvUid );
if ( users.isEmpty() )
{
- ContextUtils.conflictResponse( response, getEntityName() + " does not exist: " + uid );
+ ContextUtils.conflictResponse( response, getEntityName() + " does not exist: " + pvUid );
return;
}
@@ -310,8 +305,8 @@
}
User parsed = renderService.fromJson( request.getInputStream(), getEntityClass() );
- parsed.setUid( uid );
-
+ parsed.setUid( pvUid );
+
if ( !userService.canAddOrUpdateUser( IdentifiableObjectUtils.getUids( parsed.getGroups() ) ) )
{
ContextUtils.conflictResponse( response, "You must have permissions to create user, or ability to manage at least one user group for the user." );
@@ -319,7 +314,7 @@
}
ImportTypeSummary summary = importService.importObject( currentUserService.getCurrentUser().getUid(), parsed, ImportStrategy.UPDATE );
-
+
renderService.toJson( response.getOutputStream(), summary );
}
@@ -329,8 +324,8 @@
/**
* Validates whether the given user can be created.
- *
- * @param user the user.
+ *
+ * @param user the user.
* @param response the response.
*/
private boolean validateCreateUser( User user, HttpServletResponse response )
@@ -346,9 +341,9 @@
ContextUtils.conflictResponse( response, "You must have permissions to create user, or ability to manage at least one user group for the user." );
return false;
}
-
+
List<String> uids = IdentifiableObjectUtils.getUids( user.getGroups() );
-
+
for ( String uid : uids )
{
if ( !userGroupService.canAddOrRemoveMember( uid ) )
@@ -357,14 +352,14 @@
return false;
}
}
-
+
return true;
}
-
+
/**
* Creates a user.
*
- * @param user user object parsed from the POST request.
+ * @param user user object parsed from the POST request.
* @param response the response.
*/
private ImportSummary createUser( User user, HttpServletResponse response ) throws Exception
@@ -378,17 +373,17 @@
ImportTypeSummary summary = importService.importObject( currentUserService.getCurrentUser().getUid(), user, ImportStrategy.CREATE );
if ( summary.isStatus( ImportStatus.SUCCESS ) && summary.getImportCount().getImported() == 1 )
- {
+ {
userGroupService.addUserToGroups( user, IdentifiableObjectUtils.getUids( user.getGroups() ) );
}
return summary;
}
-
+
/**
* Validates whether a user can be invited / created.
- *
- * @param user the user.
+ *
+ * @param user the user.
* @param response the response.
*/
private boolean validateInviteUser( User user, HttpServletResponse response )
@@ -397,7 +392,7 @@
{
return false;
}
-
+
UserCredentials credentials = user.getUserCredentials();
if ( credentials == null )
@@ -405,9 +400,9 @@
ContextUtils.conflictResponse( response, "User credentials is not present" );
return false;
}
-
+
credentials.setUser( user );
-
+
List<UserAuthorityGroup> userRoles = userService.getUserRolesByUid( getUids( credentials.getUserAuthorityGroups() ) );
for ( UserAuthorityGroup role : userRoles )
@@ -418,22 +413,22 @@
return false;
}
}
-
+
String valid = securityService.validateInvite( user.getUserCredentials() );
-
+
if ( valid != null )
{
ContextUtils.conflictResponse( response, valid + ": " + user.getUserCredentials() );
return false;
}
-
+
return true;
}
-
+
/**
* Creates a user invitation and invites the user.
*
- * @param user user object parsed from the POST request.
+ * @param user user object parsed from the POST request.
* @param response the response.
*/
private ImportSummary inviteUser( User user, HttpServletRequest request, HttpServletResponse response ) throws Exception