Search in sources :

Example 1 with EntityLookups

use of org.motechproject.mds.lookup.EntityLookups in project motech by motech.

the class EditableLookupsLoader method loadEntitiesLookups.

private List<EntityLookups> loadEntitiesLookups(Bundle bundle) {
    URL lookupsResource = getLookupsResource(bundle);
    if (lookupsResource == null) {
        return new ArrayList<>();
    }
    try (InputStream stream = lookupsResource.openStream()) {
        String lookupsJson = toLookupsJson(bundle, stream);
        List<EntityLookups> entitiesLookups = new ArrayList<>();
        if (!StringUtils.isBlank(lookupsJson)) {
            entitiesLookups.addAll(Arrays.asList(GSON.fromJson(lookupsJson, EntityLookups[].class)));
        }
        return entitiesLookups;
    } catch (JsonSyntaxException e) {
        throw new MalformedLookupsJsonException(bundle.getSymbolicName(), e);
    } catch (IOException e) {
        throw new LookupsJsonReadException(bundle.getSymbolicName(), e);
    }
}
Also used : MalformedLookupsJsonException(org.motechproject.mds.exception.loader.MalformedLookupsJsonException) JsonSyntaxException(com.google.gson.JsonSyntaxException) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) LookupsJsonReadException(org.motechproject.mds.exception.loader.LookupsJsonReadException) URL(java.net.URL) EntityLookups(org.motechproject.mds.lookup.EntityLookups)

Aggregations

JsonSyntaxException (com.google.gson.JsonSyntaxException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 LookupsJsonReadException (org.motechproject.mds.exception.loader.LookupsJsonReadException)1 MalformedLookupsJsonException (org.motechproject.mds.exception.loader.MalformedLookupsJsonException)1 EntityLookups (org.motechproject.mds.lookup.EntityLookups)1