dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16605
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6350: updated MessageConvController to use Jackson to deserialize xml
------------------------------------------------------------
revno: 6350
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-03-22 15:46:01 +0100
message:
updated MessageConvController to use Jackson to deserialize xml
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MessageConversationController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Message.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/api/controller/MessageConversationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MessageConversationController.java 2012-03-19 17:23:02 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/MessageConversationController.java 2012-03-22 14:46:01 +0000
@@ -27,17 +27,17 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.ContextUtils;
import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulator;
-import org.hisp.dhis.api.view.Jaxb2Utils;
+import org.hisp.dhis.api.view.JacksonUtils;
import org.hisp.dhis.api.webdomain.Message;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.message.MessageConversation;
import org.hisp.dhis.message.MessageConversations;
import org.hisp.dhis.message.MessageService;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserService;
-import org.hisp.dhis.api.utils.ContextUtils;
-import org.hisp.dhis.common.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
@@ -46,7 +46,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.bind.JAXBException;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -74,17 +74,17 @@
public String getMessageConversations( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
MessageConversations messageConversations = new MessageConversations();
-
+
if ( params.isPaging() )
{
int total = messageService.getMessageConversationCount();
-
+
Pager pager = new Pager( params.getPage(), total );
messageConversations.setPager( pager );
-
+
List<MessageConversation> list = new ArrayList<MessageConversation>(
- messageService.getMessageConversations( pager.getPage(), pager.getPageSize() ) );
-
+ messageService.getMessageConversations( pager.getOffset(), pager.getPageSize() ) );
+
messageConversations.setMessageConversations( list );
}
else
@@ -115,6 +115,7 @@
}
model.addAttribute( "model", messageConversation );
+ model.addAttribute( "view", "detailed" );
return "message";
}
@@ -125,9 +126,9 @@
@RequestMapping( method = RequestMethod.POST, headers = {"Content-Type=application/xml, text/xml"} )
@PreAuthorize( "hasRole('ALL') or hasRole('F_SEND_MESSAGE')" )
- public void postMessageConversationXML( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws JAXBException
+ public void postMessageConversationXML( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws IOException
{
- Message message = Jaxb2Utils.unmarshal( Message.class, input );
+ Message message = JacksonUtils.fromXml( input, Message.class );
List<User> users = new ArrayList<User>( message.getUsers() );
message.getUsers().clear();
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Message.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Message.java 2012-03-12 14:27:51 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Message.java 2012-03-22 14:46:01 +0000
@@ -26,8 +26,19 @@
private Set<User> users = new HashSet<User>();
+ public Message()
+ {
+ }
+
+ public Message( String subject, String text )
+ {
+ this.subject = subject;
+ this.text = text;
+ }
+
@JsonProperty
@JsonView( {DetailedView.class} )
+ @JacksonXmlProperty
public String getSubject()
{
return subject;
@@ -40,6 +51,7 @@
@JsonProperty
@JsonView( {DetailedView.class} )
+ @JacksonXmlProperty
public String getText()
{
return text;