List of usage examples for javax.xml.bind Unmarshaller unmarshal
public Object unmarshal(javax.xml.stream.XMLEventReader reader) throws JAXBException;
From source file:org.jasig.portlet.campuslife.dao.ScreenScrapingService.java
/** * Deserialize a menu from the provided XML. * /* w w w . j a v a2s . c om*/ * @param xml * @return * @throws JAXBException */ protected T deserializeItem(String xml) throws JAXBException { final JAXBContext jc = JAXBContext.newInstance(getPackageName()); final Unmarshaller u = jc.createUnmarshaller(); @SuppressWarnings("unchecked") final T menu = (T) u.unmarshal(IOUtils.toInputStream(xml)); return menu; }
From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.GlobalSettingsWSDaoTest.java
private BlackboardGetServerConfigurationResponseCollection getServerConfigMock() throws JAXBException { final JAXBContext context = JAXBContext .newInstance(BlackboardGetServerConfigurationResponseCollection.class); final Unmarshaller unmarshaller = context.createUnmarshaller(); final BlackboardGetServerConfigurationResponseCollection result = (BlackboardGetServerConfigurationResponseCollection) unmarshaller .unmarshal(this.getClass().getResourceAsStream("/data/serverConfigurationResponse.xml")); return result; }
From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.RecordingWSDaoImplTest.java
private BlackboardListRecordingLongResponseCollection getSingleListOfRecordingLong() throws JAXBException { final JAXBContext context = JAXBContext.newInstance("com.elluminate.sas"); final Unmarshaller unmarshaller = context.createUnmarshaller(); BlackboardListRecordingLongResponseCollection response = (BlackboardListRecordingLongResponseCollection) unmarshaller .unmarshal(//from w ww.j a v a2 s. c o m this.getClass().getResourceAsStream("/data/singleListRecordingLongResponseCollection.xml")); return response; }
From source file:org.jasig.portlet.blackboardvcportlet.dao.ws.impl.RecordingWSDaoImplTest.java
private BlackboardListRecordingShortResponseCollection getSingleListOfRecordingShort() throws JAXBException { final JAXBContext context = JAXBContext.newInstance("com.elluminate.sas"); final Unmarshaller unmarshaller = context.createUnmarshaller(); BlackboardListRecordingShortResponseCollection response = (BlackboardListRecordingShortResponseCollection) unmarshaller .unmarshal(this.getClass() .getResourceAsStream("/data/singleListRecordingShortResponseCollection.xml")); return response; }
From source file:fr.cls.atoll.motu.api.rest.MotuRequest.java
/** * Gets the message as XML./*from w ww. jav a2 s .c om*/ * * @param in the in * * @return the message as XML * * @throws MotuRequestException the motu request exception */ public static Object getMessageAsXML(InputStream in) throws MotuRequestException { Object object = null; try { JAXBContext jc = JAXBContext.newInstance(MotuMsgConstant.MOTU_MSG_SCHEMA_PACK_NAME); Unmarshaller unmarshaller = jc.createUnmarshaller(); object = unmarshaller.unmarshal(in); } catch (Exception e) { throw new MotuRequestException("request reading error in getMessageAsXML", e); } if (object == null) { throw new MotuRequestException("Unable to load XML in getMessageAsXML (returned object is null)"); } try { in.close(); } catch (IOException io) { // Do nothing } return object; }
From source file:de.uni_potsdam.hpi.bpt.promnicat.importer.ibm.IBMModelImporter.java
public String parseIBMBPMN2Diagram(File xml) throws JAXBException, JSONException { JAXBContext context = JAXBContext.newInstance(Definitions.class); Unmarshaller unmarshaller = context.createUnmarshaller(); Definitions definitions = (Definitions) unmarshaller.unmarshal(xml); List<Diagram> diagrams = new ArrayList<Diagram>(); for (RootElement e : definitions.getRootElement()) { if (e instanceof de.hpi.bpmn2_0.model.Process) { de.hpi.bpmn2_0.model.Process p = (de.hpi.bpmn2_0.model.Process) e; String resourceId = "oryx-canvas123"; StencilType type = new StencilType("BPMNDiagram"); String stencilSetNs = "http://b3mn.org/stencilset/bpmn2.0#"; String url = "/oryx/stencilsets/bpmn2.0/bpmn2.0.json"; StencilSet stencilSet = new StencilSet(url, stencilSetNs); Diagram diagram = new Diagram(resourceId, type, stencilSet); setStandardBounds(diagram);//w w w .j a v a2 s . c o m // List<Shape> shapes = new ArrayList<Shape>(); Map<String, Shape> shapes = new HashMap<String, Shape>(); for (FlowElement flowElement : p.getFlowElement()) { Shape shape = new Shape(flowElement.getId()); setStandardBounds(shape); flowElement.toShape(shape); if (flowElement.getName() != null) { shape.getProperties().put("name", flowElement.getName()); } shapes.put(flowElement.getId(), shape); } for (FlowElement flowElement : p.getFlowElement()) { if (flowElement instanceof Edge) { Edge edge = (Edge) flowElement; if (edge.getSourceRef() != null) { Shape current = shapes.get(edge.getSourceRef().getId()); current.addOutgoing(new Shape(edge.getId())); shapes.get(edge.getId()).addIncoming(current); } } } diagram.getChildShapes().addAll(shapes.values()); diagrams.add(diagram); } } String parseModeltoString = JSONBuilder.parseModeltoString(diagrams.get(0)); // parseModeltoString = "{\"resourceId\":\"oryx-canvas123\",\"properties\":{\"name\":\"\",\"documentation\":\"\",\"auditing\":\"\",\"monitoring\":\"\",\"version\":\"\",\"author\":\"\",\"language\":\"English\",\"namespaces\":\"\",\"targetnamespace\":\"http://www.omg.org/bpmn20\",\"expressionlanguage\":\"http://www.w3.org/1999/XPath\",\"typelanguage\":\"http://www.w3.org/2001/XMLSchema\",\"creationdate\":\"\",\"modificationdate\":\"\"},\"stencil\":{\"id\":\"BPMNDiagram\"},\"childShapes\":[{\"resourceId\":\"oryx_7AD3C7F9-438D-4F61-9FBB-243027E573A9\",\"properties\":{\"name\":\"zrz\",\"documentation\":\"\",\"auditing\":\"\",\"monitoring\":\"\",\"categories\":\"\",\"startquantity\":1,\"completionquantity\":1,\"isforcompensation\":\"\",\"assignments\":\"\",\"callacitivity\":\"\",\"tasktype\":\"None\",\"implementation\":\"webService\",\"resources\":\"\",\"messageref\":\"\",\"operationref\":\"\",\"instantiate\":\"\",\"script\":\"\",\"script_language\":\"\",\"bgcolor\":\"#ffffcc\",\"looptype\":\"None\",\"testbefore\":\"\",\"loopcondition\":\"\",\"loopmaximum\":\"\",\"loopcardinality\":\"\",\"loopdatainput\":\"\",\"loopdataoutput\":\"\",\"inputdataitem\":\"\",\"outputdataitem\":\"\",\"behavior\":\"all\",\"complexbehaviordefinition\":\"\",\"completioncondition\":\"\",\"onebehavioreventref:\":\"signal\",\"nonebehavioreventref\":\"signal\",\"properties\":\"\",\"datainputset\":\"\",\"dataoutputset\":\"\"},\"stencil\":{\"id\":\"Task\"},\"childShapes\":[],\"outgoing\":[{\"resourceId\":\"oryx_F131DEFD-3632-4523-8A2A-18CCA592EA65\"}],\"bounds\":{\"lowerRight\":{\"x\":366,\"y\":163},\"upperLeft\":{\"x\":266,\"y\":83}},\"dockers\":[]},{\"resourceId\":\"oryx_FB713124-E16B-4325-9B87-AF7B91C21076\",\"properties\":{\"name\":\"zrz\",\"documentation\":\"\",\"auditing\":\"\",\"monitoring\":\"\",\"categories\":\"\",\"startquantity\":1,\"completionquantity\":1,\"isforcompensation\":\"\",\"assignments\":\"\",\"callacitivity\":\"\",\"tasktype\":\"None\",\"implementation\":\"webService\",\"resources\":\"\",\"messageref\":\"\",\"operationref\":\"\",\"instantiate\":\"\",\"script\":\"\",\"script_language\":\"\",\"bgcolor\":\"#ffffcc\",\"looptype\":\"None\",\"testbefore\":\"\",\"loopcondition\":\"\",\"loopmaximum\":\"\",\"loopcardinality\":\"\",\"loopdatainput\":\"\",\"loopdataoutput\":\"\",\"inputdataitem\":\"\",\"outputdataitem\":\"\",\"behavior\":\"all\",\"complexbehaviordefinition\":\"\",\"completioncondition\":\"\",\"onebehavioreventref:\":\"signal\",\"nonebehavioreventref\":\"signal\",\"properties\":\"\",\"datainputset\":\"\",\"dataoutputset\":\"\"},\"stencil\":{\"id\":\"Task\"},\"childShapes\":[],\"outgoing\":[],\"bounds\":{\"lowerRight\":{\"x\":511,\"y\":163},\"upperLeft\":{\"x\":411,\"y\":83}},\"dockers\":[]},{\"resourceId\":\"oryx_F131DEFD-3632-4523-8A2A-18CCA592EA65\",\"properties\":{\"name\":\"\",\"documentation\":\"\",\"auditing\":\"\",\"monitoring\":\"\",\"conditiontype\":\"None\",\"conditionexpression\":\"\",\"isimmediate\":\"\",\"showdiamondmarker\":\"\"},\"stencil\":{\"id\":\"SequenceFlow\"},\"childShapes\":[],\"outgoing\":[{\"resourceId\":\"oryx_FB713124-E16B-4325-9B87-AF7B91C21076\"}],\"bounds\":{\"lowerRight\":{\"x\":410.15625,\"y\":124},\"upperLeft\":{\"x\":366.84375,\"y\":122}},\"dockers\":[{\"x\":50,\"y\":40},{\"x\":50,\"y\":40}],\"target\":{\"resourceId\":\"oryx_FB713124-E16B-4325-9B87-AF7B91C21076\"}}],\"bounds\":{\"lowerRight\":{\"x\":1485,\"y\":1050},\"upperLeft\":{\"x\":0,\"y\":0}},\"stencilset\":{\"url\":\"/oryx//stencilsets/bpmn2.0/bpmn2.0.json\",\"namespace\":\"http://b3mn.org/stencilset/bpmn2.0#\"},\"ssextensions\":[]}"; // System.out.println(parseModeltoString); return parseModeltoString; }
From source file:eu.learnpad.core.impl.me.XwikiController.java
@Override public Feedbacks getFeedbacks(String modelSetId) throws LpRestExceptionImpl { // Now send the package's path to the importer for XWiki HttpClient httpClient = RestResource.getClient(); String uri = String.format("%s/learnpad/cw/bridge/%s/feedbacks", RestResource.REST_URI, modelSetId); GetMethod getMethod = new GetMethod(uri); getMethod.addRequestHeader("Accept", "application/xml"); try {/*from www . j a v a 2 s. c o m*/ httpClient.executeMethod(getMethod); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } InputStream feedbacksStream = null; try { feedbacksStream = getMethod.getResponseBodyAsStream(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Feedbacks feedbacks = null; try { JAXBContext jc = JAXBContext.newInstance(Feedbacks.class); Unmarshaller unmarshaller = jc.createUnmarshaller(); feedbacks = (Feedbacks) unmarshaller.unmarshal(feedbacksStream); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } return feedbacks; }
From source file:com.gdn.iam.spring.security.IamUserDetails.java
@Override protected UserDetails loadUserDetails(final Assertion assertion) { List<GrantedAuthority> grantedAuthorities = new ArrayList<>(); LOG.debug("user asssertion : {}", ToStringBuilder.reflectionToString(assertion)); boolean accountNonExpired = true; boolean credentialsNonExpired = true; boolean accountNonLocked = true; boolean enabled = true; for (String attribute : this.attributes) { String value = (String) assertion.getPrincipal().getAttributes().get(attribute); LOG.debug("value = {}", value); if (value != null) { LOG.debug("adding default authorization to user"); grantedAuthorities.add(new SimpleGrantedAuthority(ROLE_USER)); Unmarshaller unmarshaller = null; Session iamSession = null;//from w w w .j av a 2 s . c o m try { unmarshaller = context.createUnmarshaller(); iamSession = (Session) unmarshaller.unmarshal(new StringReader(value)); for (UserRole role : iamSession.getRoles()) { LOG.debug("adding {} authorization to user", role.getName().toUpperCase()); grantedAuthorities.add(new SimpleGrantedAuthority(role.getName().toUpperCase())); } } catch (Exception ex) { LOG.error("cannot generate user details", ex); } } } LOG.debug("accountNonExpired : {}, credentialsNonExpired : {}, accountNonLocked : {}, enabled : {}", new Object[] { accountNonExpired, credentialsNonExpired, accountNonLocked, enabled }); return new User(assertion.getPrincipal().getName().toLowerCase().trim(), NON_EXISTENT_PASSWORD_VALUE, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, grantedAuthorities); }
From source file:net.awired.visuwall.plugin.sonar.service.SonarService.java
private void createMetricList() { String metricUrl = url + "/api/metrics?format=xml"; try {/* w w w . ja v a 2s. c o m*/ InputStream xmlStream = new URL(metricUrl).openStream(); Unmarshaller unmarshaller = JAXBContext.newInstance(SonarMetrics.class).createUnmarshaller(); SonarMetrics sonarMetrics = SonarMetrics.class.cast(unmarshaller.unmarshal(xmlStream)); for (QualityMetric metric : sonarMetrics.metric) { qualityMetrics.put(metric.getKey(), metric); } } catch (MalformedURLException e) { LOG.error("url: " + metricUrl, e); throw new RuntimeException(e); } catch (IOException e) { LOG.error("url: " + metricUrl, e); throw new RuntimeException(e); } catch (JAXBException e) { LOG.error("url: " + metricUrl, e); throw new RuntimeException(e); } }
From source file:zerogame.info.javapay.web.MMIAPApiController.java
@RequestMapping(value = "mmiap", method = RequestMethod.POST, consumes = "application/xml") @ResponseBody/*from w w w .j a v a2s.co m*/ protected SyncAppOrderResp mmiap(@RequestBody String resultString, HttpServletRequest request, HttpServletResponse response, Map<String, Object> model) throws Exception { if (null == resultString || "".equals(resultString)) { response.setStatus(400); return null; } JAXBContext context = JAXBContext.newInstance(SyncAppOrderReq.class); Unmarshaller unmarshaller = context.createUnmarshaller(); SyncAppOrderReq result = (SyncAppOrderReq) unmarshaller .unmarshal(new ByteArrayInputStream(resultString.getBytes())); logger.info(String.format( "cmcc pay order MsgType=%s, Version=%s,OrderID=%s,CheckID=%s,TradeID=%s,Price=%s,ActionTime=%s," + "ActionID=%s,MSISDN=%s,FeeMSISDN=%s,AppID=%s,ProgramID=%s,PayCode=%s,TotalPrice=%s,SubsNumb=%s,SubsSeq=%s," + "ChannelID=%s,ExData=%s", result.getMsgType(), result.getVersion(), result.getOrderID(), result.getCheckID(), result.getTradeID(), result.getPrice(), result.getActionTime(), result.getActionID(), result.getMSISDN(), result.getFeeMSISDN(), result.getAppID(), result.getProgramID(), result.getPayCode(), result.getTotalPrice(), result.getSubsNumb(), result.getSubsSeq(), result.getChannelID(), result.getExData())); //log.info(JSONObject.fromObject(result).toString()); SyncAppOrderResp syncAppOrderResp = new SyncAppOrderResp(); syncAppOrderResp.setMsgType("SyncAppOrderResp"); syncAppOrderResp.setVersion("1.0.0"); String[] billNos = result.getExData().split("-"); String accountId = billNos[0]; String goodId = billNos[1]; Player player = userDao.getPlayer(CHANNEL_CMCC, accountId, "1"); if (player == null) { logger.warn("no user"); syncAppOrderResp.sethRet(1); return syncAppOrderResp; } PayOrder payorder = addPayOrder(player.getUin(), accountId, result.getOrderID(), goodId, Integer.valueOf(Integer.valueOf(result.getPrice()) / 100), CHANNEL_CMCC, Integer.valueOf("1"), PAY_ORDER_TYPE_COMMON, 0, player.getLevel(), player.getVip()); if (payorder == null) { logger.warn("add payorder fail!"); syncAppOrderResp.sethRet(1); return syncAppOrderResp; } MultiKeyCommands jedis = jedisPool.getResource(); jedis.publish("tap_hero_1_1", "{\"type\":101,\"uin\":\"" + String.valueOf(player.getUin()) + "\"}"); jedisPool.returnResource(jedis); syncAppOrderResp.sethRet(0); return syncAppOrderResp; }