Package org.apache.olingo.odata2.api.exception

Examples of org.apache.olingo.odata2.api.exception.MessageReference


        switch (uriInfo.getUriType()) {
        case URI4:
        case URI5:
            // simple property
            final List<EdmProperty> simplePropertyPath = uriInfo.getPropertyPath();
            final EdmProperty simpleProperty = simplePropertyPath.get(simplePropertyPath.size() - 1);
            responseContentType = simpleProperty.getMimeType();
            if (uriInfo.isValue()) {
                response = EntityProvider.writePropertyValue(simpleProperty, content);
                responseContentType = ContentType.TEXT_PLAIN_CS_UTF_8.toString();
            } else {
                response = EntityProvider.writeProperty(getContentType(), simpleProperty, content);
            }
            break;

        case URI3:
            // complex property
            final List<EdmProperty> complexPropertyPath = uriInfo.getPropertyPath();
            final EdmProperty complexProperty = complexPropertyPath.get(complexPropertyPath.size() - 1);
            response = EntityProvider.writeProperty(responseContentType, complexProperty, content);
            break;

        case URI7A:
            // $links with 0..1 cardinality property
View Full Code Here


            // $count
            try {
                final String stringCount = new String(EntityProvider.readBinary(content), ContentType.CHARSET_UTF_8);
                response = (T) Long.valueOf(stringCount);
            } catch (UnsupportedEncodingException e) {
                throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED, e);
            }
            break;

        case URI1:
        case URI6B:
View Full Code Here

            break;

        case URI7A:
            // $links with 0..1 cardinality property
            final EdmEntitySet targetLinkEntitySet = uriInfo.getTargetEntitySet();
            EntityProviderWriteProperties linkProperties =
                EntityProviderWriteProperties.serviceRoot(new URI(serviceUri + SEPARATOR)).build();
            @SuppressWarnings("unchecked")
            final Map<String, Object> linkMap = (Map<String, Object>) content;
            response = EntityProvider.writeLink(responseContentType, targetLinkEntitySet, linkMap, linkProperties);
            break;

        case URI7B:
            // $links with * cardinality property
            final EdmEntitySet targetLinksEntitySet = uriInfo.getTargetEntitySet();
            EntityProviderWriteProperties linksProperties =
                EntityProviderWriteProperties.serviceRoot(new URI(serviceUri + SEPARATOR)).build();
            @SuppressWarnings("unchecked")
            final List<Map<String, Object>> linksMap = (List<Map<String, Object>>) content;
            response = EntityProvider.writeLinks(responseContentType, targetLinksEntitySet, linksMap, linksProperties);
            break;

        case URI1:
        case URI2:
        case URI6A:
        case URI6B:
            // Entity
            final EdmEntitySet targetEntitySet = uriInfo.getTargetEntitySet();
            EntityProviderWriteProperties properties =
                EntityProviderWriteProperties.serviceRoot(new URI(serviceUri + SEPARATOR)).build();
            @SuppressWarnings("unchecked")
            final Map<String, Object> objectMap = (Map<String, Object>) content;
            response = EntityProvider.writeEntry(responseContentType, targetEntitySet, objectMap, properties);
            break;
View Full Code Here

    @Test
    public void testReadEntry() throws Exception {
        final TestOlingo2ResponseHandler<ODataEntry> responseHandler = new TestOlingo2ResponseHandler<ODataEntry>();

        olingoApp.read(edm, TEST_MANUFACTURER, null, responseHandler);
        ODataEntry entry = responseHandler.await();
        LOG.info("Single Entry:  {}", prettyPrint(entry));

        responseHandler.reset();

        olingoApp.read(edm, TEST_CAR, null, responseHandler);
        entry = responseHandler.await();
        LOG.info("Single Entry:  {}", prettyPrint(entry));

        responseHandler.reset();
        final Map<String, String> queryParams = new HashMap<String, String>();
        queryParams.put(SystemQueryOption.$expand.toString(), CARS);

        olingoApp.read(edm, TEST_MANUFACTURER, queryParams, responseHandler);

        ODataEntry entryExpanded = responseHandler.await();
        LOG.info("Single Entry with expanded Cars relation:  {}", prettyPrint(entryExpanded));
    }
View Full Code Here

        // create entry to update
        final TestOlingo2ResponseHandler<ODataEntry> entryHandler = new TestOlingo2ResponseHandler<ODataEntry>();

        olingoApp.create(edm, MANUFACTURERS, getEntityData(), entryHandler);

        ODataEntry createdEntry = entryHandler.await();
        LOG.info("Created Entry:  {}", prettyPrint(createdEntry));

        Map<String, Object> data = getEntityData();
        @SuppressWarnings("unchecked")
        Map<String, Object> address = (Map<String, Object>) data.get(ADDRESS);

        data.put("Name", "MyCarManufacturer Renamed");
        address.put("Street", "Main Street");
        final TestOlingo2ResponseHandler<HttpStatusCodes> statusHandler =
            new TestOlingo2ResponseHandler<HttpStatusCodes>();

        olingoApp.update(edm, TEST_CREATE_MANUFACTURER, data, statusHandler);
        statusHandler.await();

        statusHandler.reset();
        data.put("Name", "MyCarManufacturer Patched");
        olingoApp.patch(edm, TEST_CREATE_MANUFACTURER, data, statusHandler);
        statusHandler.await();

        entryHandler.reset();
        olingoApp.read(edm, TEST_CREATE_MANUFACTURER, null, entryHandler);

        ODataEntry updatedEntry = entryHandler.await();
        LOG.info("Updated Entry successfully:  {}", prettyPrint(updatedEntry));

        statusHandler.reset();
        olingoApp.delete(TEST_CREATE_MANUFACTURER,  statusHandler);
View Full Code Here

        assertNotNull(responseParts.get(0).getBody());
        final ODataFeed feed = (ODataFeed) responseParts.get(1).getBody();
        assertNotNull(feed);
        LOG.info("Batch feed:  {}", prettyPrint(feed));

        ODataEntry dataEntry = (ODataEntry) responseParts.get(2).getBody();
        assertNotNull(dataEntry);
        LOG.info("Batch read entry:  {}", prettyPrint(dataEntry));

        dataEntry = (ODataEntry) responseParts.get(3).getBody();
        assertNotNull(dataEntry);
View Full Code Here

            } else if (value instanceof Calendar) {
                Calendar cal = (Calendar) value;
                value = SimpleDateFormat.getInstance().format(cal.getTime());
                b.append(value).append(NEW_LINE);
            } else if (value instanceof ODataDeltaFeed) {
                ODataDeltaFeed feed = (ODataDeltaFeed) value;
                List<ODataEntry> inlineEntries = feed.getEntries();
                b.append("{");
                for (ODataEntry oDataEntry : inlineEntries) {
                    value = prettyPrint(oDataEntry.getProperties(), level + 1);
                    b.append("\n[\n").append(value).append("\n],");
                }
View Full Code Here

    public void testReadFeed() throws Exception {
        final TestOlingo2ResponseHandler<ODataFeed> responseHandler = new TestOlingo2ResponseHandler<ODataFeed>();

        olingoApp.read(edm, MANUFACTURERS, null, responseHandler);

        final ODataFeed dataFeed = responseHandler.await();
        assertNotNull("Data feed", dataFeed);
        LOG.info("Entries:  {}", prettyPrint(dataFeed));
    }
View Full Code Here

        final List<Olingo2BatchResponse> responseParts = responseHandler.await(15, TimeUnit.MINUTES);
        assertEquals("Batch responses expected", 8, responseParts.size());

        assertNotNull(responseParts.get(0).getBody());
        final ODataFeed feed = (ODataFeed) responseParts.get(1).getBody();
        assertNotNull(feed);
        LOG.info("Batch feed:  {}", prettyPrint(feed));

        ODataEntry dataEntry = (ODataEntry) responseParts.get(2).getBody();
        assertNotNull(dataEntry);
View Full Code Here

    errorContext.setErrorCode(toHandleException.getCode());
  }

  private void enhanceContextWithMessageException(final ODataMessageException toHandleException) {
    errorContext.setErrorCode(toHandleException.getErrorCode());
    MessageReference messageReference = toHandleException.getMessageReference();
    Message localizedMessage = messageReference == null ? null : extractEntity(messageReference);
    if (localizedMessage != null) {
      errorContext.setMessage(localizedMessage.getText());
      errorContext.setLocale(localizedMessage.getLocale());
    }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.exception.MessageReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.