APISonar


org.sakaiproject.entitybroker.entityprovider.extension.Formats.XML

> org > sakaiproject > entitybroker > entityprovider > extension > Formats > XML
org APIs sakaiproject APIs entitybroker APIs entityprovider APIs extension APIs Formats APIs XML APIs

Example 1
public void testFormatAndOutputEntity() {
        // test no provider
        String reference = TestData.REF4;
        OutputStream output = new ByteArrayOutputStream();
        String format = Formats.XML;

        try {
            entityBroker.formatAndOutputEntity(reference, format, null, output, null);
            fail("Should have died");
        } catch (UnsupportedOperationException e) {
            assertNotNull(e.getMessage());
        }
    }
Example 2
public void testTranslateInputToEntity() {
        // test no provider
        String reference = TestData.SPACE6;
        String format = Formats.XML;
        InputStream input = new ByteArrayInputStream( makeUTF8Bytes("<"+TestData.PREFIX6+"><stuff>TEST</stuff><number>5</number></"+TestData.PREFIX6+">") );
        try {
            entityBroker.translateInputToEntity(reference, format, input, null);
            Assert.fail("Should have died");
        } catch (UnsupportedOperationException e) {
            Assert.assertNotNull(e.getMessage());
        }
    }
Example 3
public void setTranscoder(Transcoder transcoder) {
        if (transcoder == null) {
            throw new IllegalArgumentException("transcoder cannot be null");
        }
        if (transcoders == null) {
            getTranscoder(Formats.XML);
        }
        String format = transcoder.getHandledFormat();
        if (format != null && transcoder != null) {
            transcoders.put(format, transcoder);
        }
    }
Example 4
public void testSetResponseEncoding() {
      EntityHttpServletResponse res = new EntityHttpServletResponse();

      RequestUtils.setResponseEncoding(Formats.XML, res);
      assertEquals(Formats.UTF_8, res.getCharacterEncoding());
      assertEquals(Formats.XML_MIME_TYPE, res.getContentType());
   }
Example 5
public String handleRedirects(String matchedTemplate, String incomingURL,
         String[] incomingSegments, Map<String, String> values) {
      String redirectURL = null;
      if (matchedTemplate.equals(templates[0])) {
         redirectURL = values.get(EntityView.PREFIX) + EntityView.SEPARATOR 
            + "siteuser?site=" + values.get("siteId") + "&user=" + values.get("userId");
      } else if (matchedTemplate.equals(templates[1])) {
         redirectURL = "http://caret.cam.ac.uk/?prefix=" + values.get(EntityView.PREFIX) + "&thing=" + values.get("thing");
      } else if (matchedTemplate.equals(templates[2])) {
         redirectURL = values.get(EntityView.PREFIX) + EntityView.SEPARATOR 
            + values.get(EntityView.ID) + EntityView.PERIOD + Formats.XML;
      }
      return redirectURL;
   }