Search in sources :

Example 1 with JsonException

use of com.ibm.commons.util.io.json.JsonException in project org.openntf.xsp.jakartaee by OpenNTF.

the class TestBundleBeanResource method getBean.

private Map<String, Object> getBean(String base) throws JsonException {
    Client client = getAnonymousClient();
    WebTarget target = client.target(base + "/bean");
    Response response = target.request().get();
    String output = response.readEntity(String.class);
    try {
        Map<String, Object> obj = (Map<String, Object>) JsonParser.fromJson(JsonJavaFactory.instance, output);
        return obj;
    } catch (Exception e) {
        fail("Exception parsing JSON: " + output, e);
        return null;
    }
}
Also used : Response(jakarta.ws.rs.core.Response) WebTarget(jakarta.ws.rs.client.WebTarget) Client(jakarta.ws.rs.client.Client) Map(java.util.Map) JsonException(com.ibm.commons.util.io.json.JsonException)

Example 2 with JsonException

use of com.ibm.commons.util.io.json.JsonException in project org.openntf.nsfodp by OpenNTF.

the class StockComponentsServlet method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    resp.setBufferSize(0);
    // $NON-NLS-1$ //$NON-NLS-2$
    resp.setHeader("Content-Type", "text/json");
    ServletOutputStream os = resp.getOutputStream();
    try {
        if (componentInfo == null) {
            SharableRegistryImpl facesRegistry = new SharableRegistryImpl(getClass().getPackage().getName());
            // $NON-NLS-1$
            List<Object> libraries = ExtensionManager.findServices((List<Object>) null, LibraryServiceLoader.class, "com.ibm.xsp.Library");
            libraries.stream().filter(lib -> lib instanceof XspLibrary).map(XspLibrary.class::cast).map(lib -> new LibraryWrapper(lib.getLibraryId(), lib)).map(wrapper -> {
                SimpleRegistryProvider provider = new SimpleRegistryProvider();
                provider.init(wrapper);
                return provider;
            }).map(XspRegistryProvider::getRegistry).forEach(facesRegistry::addDepend);
            facesRegistry.refreshReferences();
            componentInfo = new JsonJavaObject();
            JsonArray defs = new JsonJavaArray();
            facesRegistry.findComponentDefs().stream().filter(FacesComponentDefinition::isTag).map(def -> {
                try {
                    JsonObject defObj = new JsonJavaObject();
                    // $NON-NLS-1$
                    defObj.putJsonProperty("namespaceUri", def.getNamespaceUri());
                    // $NON-NLS-1$
                    defObj.putJsonProperty("tagName", def.getTagName());
                    // $NON-NLS-1$
                    defObj.putJsonProperty("class", def.getJavaClass().getName());
                    // $NON-NLS-1$
                    defObj.putJsonProperty("since", def.getSince());
                    // $NON-NLS-1$
                    defObj.putJsonProperty("defaultPrefix", def.getFirstDefaultPrefix());
                    // $NON-NLS-1$
                    defObj.putJsonProperty("componentFamily", def.getComponentFamily());
                    // $NON-NLS-1$
                    defObj.putJsonProperty("componentType", def.getComponentType());
                    // $NON-NLS-1$
                    defObj.putJsonProperty("id", def.getId());
                    JsonArray facetNames = new JsonJavaArray();
                    for (String facetName : def.getFacetNames()) {
                        facetNames.add(facetName);
                    }
                    // $NON-NLS-1$
                    defObj.putJsonProperty("facetNames", facetNames);
                    FacesProperty defaultProp = def.getDefaultFacesProperty();
                    if (defaultProp != null) {
                        JsonObject defaultPropObj = new JsonJavaObject();
                        // $NON-NLS-1$
                        defaultPropObj.putJsonProperty("name", defaultProp.getName());
                        // $NON-NLS-1$
                        defaultPropObj.putJsonProperty("since", defaultProp.getSince());
                        // $NON-NLS-1$
                        defaultPropObj.putJsonProperty("class", defaultProp.getJavaClass().getName());
                        // $NON-NLS-1$
                        defaultPropObj.putJsonProperty("required", defaultProp.isRequired());
                        // $NON-NLS-1$
                        defaultPropObj.putJsonProperty("attribute", defaultProp.isAttribute());
                    }
                    JsonArray properties = new JsonJavaArray();
                    for (String propName : def.getPropertyNames()) {
                        FacesProperty prop = def.getProperty(propName);
                        JsonObject propObj = new JsonJavaObject();
                        // $NON-NLS-1$
                        propObj.putJsonProperty("name", propName);
                        // $NON-NLS-1$
                        propObj.putJsonProperty("class", prop.getJavaClass().getName());
                        // $NON-NLS-1$
                        propObj.putJsonProperty("since", prop.getSince());
                        // $NON-NLS-1$
                        propObj.putJsonProperty("required", prop.isRequired());
                        // $NON-NLS-1$
                        propObj.putJsonProperty("attribute", prop.isAttribute());
                        properties.add(propObj);
                    }
                    // $NON-NLS-1$
                    defObj.putJsonProperty("properties", properties);
                    return defObj;
                } catch (JsonException e) {
                    throw new RuntimeException(e);
                }
            }).forEach(defObj -> {
                try {
                    defs.add(defObj);
                } catch (JsonException e) {
                    throw new RuntimeException(e);
                }
            });
            // $NON-NLS-1$
            componentInfo.putJsonProperty("components", defs);
        }
        os.print(componentInfo.toString());
    } catch (Throwable e) {
        resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintWriter out = new PrintWriter(baos);
        e.printStackTrace(out);
        out.flush();
        os.println(LineDelimitedJsonProgressMonitor.message(// $NON-NLS-1$ //$NON-NLS-2$
        "type", // $NON-NLS-1$ //$NON-NLS-2$
        "error", // $NON-NLS-1$
        "stackTrace", // $NON-NLS-1$
        baos.toString()));
    }
}
Also used : PrintWriter(java.io.PrintWriter) JsonJavaObject(com.ibm.commons.util.io.json.JsonJavaObject) SharableRegistryImpl(com.ibm.xsp.registry.SharableRegistryImpl) ByteArrayOutputStream(java.io.ByteArrayOutputStream) HttpServlet(javax.servlet.http.HttpServlet) ServletException(javax.servlet.ServletException) JsonObject(com.ibm.commons.util.io.json.JsonObject) ExtensionManager(com.ibm.commons.extension.ExtensionManager) HttpServletResponse(javax.servlet.http.HttpServletResponse) SimpleRegistryProvider(com.ibm.xsp.registry.config.SimpleRegistryProvider) IOException(java.io.IOException) XspLibrary(com.ibm.xsp.library.XspLibrary) FacesProperty(com.ibm.xsp.registry.FacesProperty) LibraryServiceLoader(com.ibm.xsp.library.LibraryServiceLoader) List(java.util.List) HttpServletRequest(javax.servlet.http.HttpServletRequest) JsonJavaArray(com.ibm.commons.util.io.json.JsonJavaArray) JsonException(com.ibm.commons.util.io.json.JsonException) FacesComponentDefinition(com.ibm.xsp.registry.FacesComponentDefinition) ServletOutputStream(javax.servlet.ServletOutputStream) LineDelimitedJsonProgressMonitor(org.openntf.nsfodp.commons.LineDelimitedJsonProgressMonitor) JsonArray(com.ibm.commons.util.io.json.JsonArray) XspRegistryProvider(com.ibm.xsp.registry.config.XspRegistryProvider) LibraryWrapper(com.ibm.xsp.library.LibraryWrapper) JsonException(com.ibm.commons.util.io.json.JsonException) JsonJavaArray(com.ibm.commons.util.io.json.JsonJavaArray) LibraryWrapper(com.ibm.xsp.library.LibraryWrapper) ServletOutputStream(javax.servlet.ServletOutputStream) XspLibrary(com.ibm.xsp.library.XspLibrary) JsonObject(com.ibm.commons.util.io.json.JsonObject) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SharableRegistryImpl(com.ibm.xsp.registry.SharableRegistryImpl) JsonJavaObject(com.ibm.commons.util.io.json.JsonJavaObject) JsonArray(com.ibm.commons.util.io.json.JsonArray) FacesComponentDefinition(com.ibm.xsp.registry.FacesComponentDefinition) SimpleRegistryProvider(com.ibm.xsp.registry.config.SimpleRegistryProvider) JsonJavaObject(com.ibm.commons.util.io.json.JsonJavaObject) JsonObject(com.ibm.commons.util.io.json.JsonObject) FacesProperty(com.ibm.xsp.registry.FacesProperty) PrintWriter(java.io.PrintWriter)

Example 3 with JsonException

use of com.ibm.commons.util.io.json.JsonException in project org.openntf.domino by OpenNTF.

the class Document method toJson.

@Override
public String toJson(final boolean compact) {
    StringWriter sw = new StringWriter();
    JsonWriter jw = new JsonWriter(sw, compact);
    try {
        jw.startObject();
        jw.outStringProperty("@unid", getUniversalID());
        jw.outStringProperty("@noteid", getNoteID());
        jw.outStringProperty("@replicaid", getParentDatabase().getReplicaID());
        jw.outStringProperty("@metaversalid", getMetaversalID());
        try {
            jw.outStringProperty("@created", getCreated().toGMTISO());
            jw.outStringProperty("@lastmodified", getLastModified().toGMTISO());
            jw.outStringProperty("@lastaccessed", getLastAccessed().toGMTISO());
        } catch (Exception e) {
            DominoUtils.handleException(e, "Exception trying to index Dates.");
        }
        Set<String> keys = keySet();
        for (String key : keys) {
            Item currItem = getFirstItem(key);
            // A beer to anyone who can work out how this could happen, except for the person who identified it!
            if (null != currItem) {
                Type itemType = currItem.getTypeEx();
                try {
                    if (itemType == Type.ATTACHMENT) {
                        jw.outProperty(key, "ATTACHMENT");
                    } else if (itemType == Type.AUTHORS || itemType == Type.READERS || itemType == Type.NAMES || itemType == Type.TEXT || itemType == Type.NUMBERS) {
                        Vector<Object> values = currItem.getValues();
                        if (values.size() == 1) {
                            jw.outProperty(key, values.elementAt(0));
                        } else {
                            jw.outProperty(key, values);
                        }
                    } else if (itemType == Type.DATETIMES) {
                        Vector<DateTime> values = currItem.getValueDateTimeArray();
                        if (values.size() == 1) {
                            jw.outProperty(key, values.get(0).toGMTISO());
                        } else {
                            jw.outProperty(key, TypeUtils.toStrings(values));
                        }
                    } else if (itemType == Type.EMBEDDEDOBJECT) {
                        jw.outProperty(key, "EMBEDDED_OBJECT");
                    } else if (itemType == Type.RICHTEXT) {
                        RichTextItem rtItem = (RichTextItem) currItem;
                        jw.outProperty(key, rtItem.getUnformattedText());
                    } else if (itemType == Type.MIME_PART) {
                        MIMEEntity mimeEntity = currItem.getMIMEEntity();
                        if (mimeEntity != null) {
                            jw.outProperty(key, mimeEntity.getContentAsText());
                        } else {
                            jw.outProperty(key, "MIME_PART null");
                        }
                    }
                } catch (Exception e) {
                    DominoUtils.handleException(e, this);
                    // NTF - temporary
                    e.printStackTrace();
                }
            }
            // if (currItem.getMIMEEntity() == null) {
            // jw.outProperty(key, currItem.getText());
            // } else {
            // String abstractedText = currItem.abstractText(0, false, false);
            // if (null == abstractedText) {
            // jw.outProperty(key, "**MIME ITEM, VALUE CANNOT BE DECODED TO JSON**");
            // } else {
            // jw.outProperty(key, abstractedText);
            // }
            // }
            // Now output attachments
            jw.outProperty("@attachments", getAttachmentNames());
        }
        jw.endObject();
        jw.flush();
    } catch (IOException e) {
        DominoUtils.handleException(e, this);
        return null;
    } catch (JsonException e) {
        DominoUtils.handleException(e, this);
        return null;
    }
    return sw.toString();
}
Also used : JsonException(com.ibm.commons.util.io.json.JsonException) IOException(java.io.IOException) JsonWriter(com.ibm.commons.util.io.json.util.JsonWriter) OpenNTFNotesException(org.openntf.domino.exceptions.OpenNTFNotesException) JsonException(com.ibm.commons.util.io.json.JsonException) DocumentWriteAccessException(org.openntf.domino.exceptions.DocumentWriteAccessException) DataNotCompatibleException(org.openntf.domino.exceptions.DataNotCompatibleException) UserAccessException(org.openntf.domino.exceptions.UserAccessException) NotesException(lotus.domino.NotesException) DominoNonSummaryLimitException(org.openntf.domino.exceptions.DominoNonSummaryLimitException) IOException(java.io.IOException) ItemNotFoundException(org.openntf.domino.exceptions.ItemNotFoundException) DateTime(org.openntf.domino.DateTime) RichTextItem(org.openntf.domino.RichTextItem) Item(org.openntf.domino.Item) Type(org.openntf.domino.Item.Type) MIMEEntity(org.openntf.domino.MIMEEntity) StringWriter(java.io.StringWriter) RichTextItem(org.openntf.domino.RichTextItem) Vector(java.util.Vector) ItemVector(org.openntf.domino.iterators.ItemVector)

Example 4 with JsonException

use of com.ibm.commons.util.io.json.JsonException in project org.openntf.domino by OpenNTF.

the class SearchResource method getSearchObject.

@SuppressWarnings("unchecked")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getSearchObject(@Context final UriInfo uriInfo, @PathParam(Routes.NAMESPACE) final String namespace, @Context final Request request) throws JsonException, IOException {
    @SuppressWarnings("rawtypes") DFramedTransactionalGraph graph = this.getGraph(namespace);
    ParamMap pm = Parameters.toParamMap(uriInfo);
    StringWriter sw = new StringWriter();
    JsonGraphWriter writer = new JsonGraphWriter(sw, graph, pm, false, true, false);
    Date lastModified = new Date();
    boolean getLastMod = false;
    try {
        if (pm.get(Parameters.ID) != null) {
            List<String> ids = pm.get(Parameters.ID);
            if (ids.size() == 0) {
                writer.outNull();
            } else if (ids.size() == 1) {
                String id = ids.get(0).trim();
                NoteCoordinate nc = null;
                if (id.startsWith("E")) {
                    nc = ViewEntryCoordinate.Utils.getViewEntryCoordinate(id);
                } else if (id.startsWith("V")) {
                    nc = ViewEntryCoordinate.Utils.getViewEntryCoordinate(id);
                } else {
                    nc = NoteCoordinate.Utils.getNoteCoordinate(id);
                    getLastMod = true;
                }
                Object elem = graph.getElement(nc, null);
                if (elem == null) {
                    throw new WebApplicationException(ErrorHelper.createErrorResponse("Graph element not found for id " + id, Response.Status.NOT_FOUND));
                }
                if (elem instanceof DVertexFrame && getLastMod) {
                    lastModified = ((DVertexFrame) elem).getModified();
                }
                if (elem instanceof DEdgeFrame && getLastMod) {
                    lastModified = ((DEdgeFrame) elem).getModified();
                }
                writer.outObject(elem);
            } else {
                List<Value> valueResults = null;
                List<RichTextReference> rtRefResults = null;
                for (String id : ids) {
                    NoteCoordinate nc = NoteCoordinate.Utils.getNoteCoordinate(id.trim());
                    Object rawterm = graph.getElement(nc, null);
                    // System.out.println("TEMP DEBUG got a " + DGraphUtils.getInterfaceList(rawterm) + " from id " + nc);
                    Term term = null;
                    if (rawterm instanceof Term) {
                        term = (Term) rawterm;
                    } else {
                    // System.out.println("TEMP DEBUG didn't get a Term!");
                    }
                    List<Value> values = term.getValues();
                    // System.out.println("TEMP DEBUG found " + values.size()  + " values for term " + term.getValue() + " in a " + values.getClass().getName());
                    List<RichTextReference> rtRefs = term.getRichTextReferences();
                    // System.out.println("TEMP DEBUG found " + rtRefs.size()  + " rtrefs for term " + term.getValue() + " in a " + rtRefs.getClass().getName());
                    if (valueResults == null) {
                        valueResults = values;
                    } else {
                        valueResults.retainAll(values);
                    // System.out.println("TEMP DEBUG retained " + valueResults.size()  + " values for term " + term.getValue());
                    }
                    if (rtRefResults == null) {
                        rtRefResults = rtRefs;
                    } else {
                        rtRefResults.retainAll(rtRefs);
                    // System.out.println("TEMP DEBUG retained " + rtRefResults.size()  + " rtrefs for term " + term.getValue());
                    }
                }
                List<Object> combinedResults = new ArrayList<Object>();
                combinedResults.addAll(valueResults);
                combinedResults.addAll(rtRefResults);
                writer.outArrayLiteral(combinedResults);
            }
        } else if (pm.getKeys() != null) {
            Class<?> type = Term.class;
            DKeyResolver resolver = graph.getKeyResolver(type);
            List<CharSequence> keys = pm.getKeys();
            if (keys.size() == 0) {
                writer.outNull();
            } else {
                List<Value> valueResults = null;
                List<RichTextReference> rtRefResults = null;
                String key = URLDecoder.decode(String.valueOf(keys.get(0)), "UTF-8");
                String[] array = key.split(" ");
                for (String cur : array) {
                    NoteCoordinate nc = resolver.resolveKey(type, cur);
                    Object rawterm = graph.getElement(nc, null);
                    Term term = null;
                    if (rawterm instanceof Term) {
                        term = (Term) rawterm;
                    } else {
                    }
                    List<Value> values = term.getValues();
                    List<RichTextReference> rtRefs = term.getRichTextReferences();
                    if (valueResults == null) {
                        valueResults = values;
                    } else {
                        valueResults.retainAll(values);
                    }
                    if (rtRefResults == null) {
                        rtRefResults = rtRefs;
                    } else {
                        rtRefResults.retainAll(rtRefs);
                    }
                }
                List<Object> combinedResults = new ArrayList<Object>();
                combinedResults.addAll(valueResults);
                combinedResults.addAll(rtRefResults);
                writer.outArrayLiteral(combinedResults);
            }
            graph.rollback();
        } else {
            // MultivaluedMap<String, String> mvm = uriInfo.getQueryParameters();
            Map<String, Object> jsonMap = new LinkedHashMap<String, Object>();
            jsonMap.put("namespace", namespace);
            jsonMap.put("status", "active");
            writer.outObject(jsonMap);
        }
    } catch (UserAccessException uae) {
        return ErrorHelper.createErrorResponse("User " + Factory.getSession(SessionType.CURRENT).getEffectiveUserName() + " is not authorized to access this resource", Response.Status.UNAUTHORIZED);
    } catch (KeyNotFoundException knfe) {
        ResponseBuilder rb = Response.noContent();
        return rb.build();
    } catch (Exception e) {
        throw new WebApplicationException(ErrorHelper.createErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
    }
    String jsonEntity = sw.toString();
    ResponseBuilder berg = getBuilder(jsonEntity, lastModified, true, request);
    Response response = berg.build();
    return response;
}
Also used : ParamMap(org.openntf.domino.rest.service.Parameters.ParamMap) WebApplicationException(javax.ws.rs.WebApplicationException) JsonGraphWriter(org.openntf.domino.rest.json.JsonGraphWriter) DFramedTransactionalGraph(org.openntf.domino.graph2.impl.DFramedTransactionalGraph) StringWriter(java.io.StringWriter) ArrayList(java.util.ArrayList) List(java.util.List) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) NoteCoordinate(org.openntf.domino.big.NoteCoordinate) DKeyResolver(org.openntf.domino.graph2.DKeyResolver) Term(org.openntf.domino.graph2.builtin.search.Term) UserAccessException(org.openntf.domino.exceptions.UserAccessException) Date(java.util.Date) UserAccessException(org.openntf.domino.exceptions.UserAccessException) KeyNotFoundException(org.openntf.domino.graph2.impl.DEdgeEntryList.KeyNotFoundException) IOException(java.io.IOException) JsonException(com.ibm.commons.util.io.json.JsonException) WebApplicationException(javax.ws.rs.WebApplicationException) DVertexFrame(org.openntf.domino.graph2.builtin.DVertexFrame) Response(javax.ws.rs.core.Response) DEdgeFrame(org.openntf.domino.graph2.builtin.DEdgeFrame) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ParamMap(org.openntf.domino.rest.service.Parameters.ParamMap) KeyNotFoundException(org.openntf.domino.graph2.impl.DEdgeEntryList.KeyNotFoundException) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with JsonException

use of com.ibm.commons.util.io.json.JsonException in project org.openntf.domino by OpenNTF.

the class TermsResource method getTermsObject.

@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getTermsObject(@Context final UriInfo uriInfo, @PathParam(Routes.NAMESPACE) final String namespace, @Context final Request request) throws JsonException, IOException {
    DFramedTransactionalGraph graph = this.getGraph(namespace);
    ParamMap pm = Parameters.toParamMap(uriInfo);
    StringWriter sw = new StringWriter();
    JsonGraphWriter writer = new JsonGraphWriter(sw, graph, pm, false, true, true);
    try {
        List<CharSequence> types = new ArrayList<CharSequence>();
        types.add("org.openntf.domino.graph2.builtin.search.Term");
        List<CharSequence> filterkeys = pm.getFilterKeys();
        List<CharSequence> filtervalues = pm.getFilterValues();
        List<CharSequence> partialkeys = pm.getPartialKeys();
        List<CharSequence> partialvalues = pm.getPartialValues();
        List<CharSequence> startskeys = pm.getStartsKeys();
        List<CharSequence> startsvalues = pm.getStartsValues();
        if (types.size() == 0) {
            writer.outNull();
        } else if (types.size() == 1) {
            CharSequence typename = types.get(0);
            Iterable<?> elements = null;
            if (filterkeys != null) {
                elements = graph.getFilteredElements(typename.toString(), filterkeys, filtervalues);
            } else if (partialkeys != null) {
                elements = graph.getFilteredElementsPartial(typename.toString(), partialkeys, partialvalues);
            } else if (startskeys != null) {
                elements = graph.getFilteredElementsStarts(typename.toString(), startskeys, startsvalues);
            } else {
                elements = graph.getElements(typename.toString());
            }
            if (elements instanceof FramedEdgeList) {
                List<?> result = sortAndLimitList((List<?>) elements, pm);
                writer.outArrayLiteral(result);
            } else if (elements instanceof FramedVertexList) {
                List<?> result = sortAndLimitList((List<?>) elements, pm);
                writer.outArrayLiteral(result);
            } else {
                List<Object> maps = new ArrayList<Object>();
                for (Object element : elements) {
                    maps.add(element);
                }
                writer.outArrayLiteral(maps);
            }
        } else {
            MixedFramedVertexList vresult = null;
            FramedEdgeList eresult = null;
            for (CharSequence typename : types) {
                Iterable<?> elements = null;
                if (filterkeys != null) {
                    elements = graph.getFilteredElements(typename.toString(), filterkeys, filtervalues);
                } else if (partialkeys != null) {
                    elements = graph.getFilteredElementsPartial(typename.toString(), partialkeys, partialvalues);
                } else if (startskeys != null) {
                    elements = graph.getFilteredElementsStarts(typename.toString(), startskeys, startsvalues);
                } else {
                    elements = graph.getElements(typename.toString());
                }
                if (elements instanceof FramedVertexList) {
                    if (vresult == null) {
                        vresult = new MixedFramedVertexList(graph, null, (FramedVertexList) elements);
                    } else {
                        vresult.addAll((List<?>) elements);
                    }
                } else if (elements instanceof FramedEdgeList) {
                    if (eresult == null) {
                        eresult = (FramedEdgeList) elements;
                    } else {
                        eresult.addAll((FramedEdgeList) elements);
                    }
                }
            }
            if (vresult != null) {
                List<?> result = sortAndLimitList(vresult, pm);
                writer.outArrayLiteral(result);
            }
            if (eresult != null) {
                List<?> result = sortAndLimitList(eresult, pm);
                writer.outArrayLiteral(result);
            }
        }
    } catch (UserAccessException uae) {
        throw new WebApplicationException(ErrorHelper.createErrorResponse(uae, Response.Status.UNAUTHORIZED));
    } catch (Exception e) {
        throw new WebApplicationException(ErrorHelper.createErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
    }
    String jsonEntity = sw.toString();
    ResponseBuilder berg = getBuilder(jsonEntity, new Date(), true, request);
    Response response = berg.build();
    return response;
}
Also used : ParamMap(org.openntf.domino.rest.service.Parameters.ParamMap) WebApplicationException(javax.ws.rs.WebApplicationException) JsonGraphWriter(org.openntf.domino.rest.json.JsonGraphWriter) ArrayList(java.util.ArrayList) DFramedTransactionalGraph(org.openntf.domino.graph2.impl.DFramedTransactionalGraph) MixedFramedVertexList(org.openntf.domino.graph2.annotations.MixedFramedVertexList) FramedEdgeList(org.openntf.domino.graph2.annotations.FramedEdgeList) FramedVertexList(org.openntf.domino.graph2.annotations.FramedVertexList) MixedFramedVertexList(org.openntf.domino.graph2.annotations.MixedFramedVertexList) UserAccessException(org.openntf.domino.exceptions.UserAccessException) UserAccessException(org.openntf.domino.exceptions.UserAccessException) IOException(java.io.IOException) JsonException(com.ibm.commons.util.io.json.JsonException) WebApplicationException(javax.ws.rs.WebApplicationException) Date(java.util.Date) Response(javax.ws.rs.core.Response) StringWriter(java.io.StringWriter) FramedEdgeList(org.openntf.domino.graph2.annotations.FramedEdgeList) ArrayList(java.util.ArrayList) FramedVertexList(org.openntf.domino.graph2.annotations.FramedVertexList) MixedFramedVertexList(org.openntf.domino.graph2.annotations.MixedFramedVertexList) List(java.util.List) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

JsonException (com.ibm.commons.util.io.json.JsonException)17 IOException (java.io.IOException)15 StringWriter (java.io.StringWriter)11 WebApplicationException (javax.ws.rs.WebApplicationException)11 UserAccessException (org.openntf.domino.exceptions.UserAccessException)11 JsonJavaObject (com.ibm.commons.util.io.json.JsonJavaObject)10 Date (java.util.Date)10 List (java.util.List)10 Response (javax.ws.rs.core.Response)10 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)10 JsonGraphWriter (org.openntf.domino.rest.json.JsonGraphWriter)9 ArrayList (java.util.ArrayList)8 CaseInsensitiveString (org.openntf.domino.types.CaseInsensitiveString)8 Produces (javax.ws.rs.Produces)7 DFramedTransactionalGraph (org.openntf.domino.graph2.impl.DFramedTransactionalGraph)7 ParamMap (org.openntf.domino.rest.service.Parameters.ParamMap)7 LinkedHashMap (java.util.LinkedHashMap)6 KeyNotFoundException (org.openntf.domino.graph2.impl.DEdgeEntryList.KeyNotFoundException)6 GET (javax.ws.rs.GET)5 JsonGraphFactory (org.openntf.domino.rest.json.JsonGraphFactory)5