Created
July 26, 2011 14:33
-
-
Save axeda/1106904 to your computer and use it in GitHub Desktop.
Retrieving list of Models
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.axeda.drm.sdk.Context; | |
| import com.axeda.drm.sdk.user.User; | |
| import com.axeda.drm.sdk.device.*; | |
| import com.axeda.drm.sdk.model.*; | |
| import com.axeda.common.sdk.jdbc.StringQuery; | |
| import java.util.*; | |
| import groovy.xml.MarkupBuilder | |
| import org.custommonkey.xmlunit.* | |
| import com.axeda.common.sdk.id.Identifier; | |
| def writer | |
| def xml | |
| try { | |
| String username = parameters.username | |
| Context ctx = Context.create(username); | |
| ModelFinder mf = new ModelFinder(ctx); | |
| List dList = mf.findAll(); | |
| Context.create(); | |
| writer = new StringWriter() | |
| xml = new MarkupBuilder(writer) | |
| xml.Response() { | |
| for (d in dList) Model('name': d.getName()); | |
| } | |
| } catch (Exception ex) { | |
| writer = new StringWriter() | |
| xml = new MarkupBuilder(writer) | |
| xml.Response() { | |
| Fault { | |
| Code('Groovy Exception') | |
| Message(ex.getMessage()) | |
| StringWriter sw = new StringWriter(); | |
| PrintWriter pw = new PrintWriter(sw); | |
| ex.printStackTrace(pw); | |
| Detail(sw.toString()) | |
| } | |
| } | |
| } | |
| //logger.info(writer.toString()); | |
| return ['Content-Type': 'text/xml', 'Content': writer.toString()] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment