@@ -0,0 +1,2766 @@
+package fi.nls.oskari.control.view;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.json.JSONException;%0A%0Aimport com.fasterxml.jackson.core.JsonFactory;%0Aimport com.fasterxml.jackson.core.JsonGenerator;%0A%0Aimport fi.nls.oskari.annotation.OskariActionRoute;%0Aimport fi.nls.oskari.control.ActionException;%0Aimport fi.nls.oskari.control.ActionParameters;%0Aimport fi.nls.oskari.domain.map.view.View;%0Aimport fi.nls.oskari.map.view.ViewService;%0Aimport fi.nls.oskari.map.view.ViewServiceIbatisImpl;%0Aimport fi.nls.oskari.service.ServiceException;%0Aimport fi.nls.oskari.util.ResponseHelper;%0A%0A@OskariActionRoute(%22GetSystemDefaultViews%22)%0Apublic class GetSystemDefaultViews %7B%0A%0A    private static final JsonFactory JSONF = new JsonFactory();%0A%0A    private ViewService viewService;%0A%0A    public void init() %7B%0A        viewService = new ViewServiceIbatisImpl();%0A    %7D%0A%0A    public void handleAction(ActionParameters params) throws ActionException %7B%0A        List%3CLong%3E viewIds = getDefaultViewIds();%0A        List%3CView%3E views = getViews(viewIds);%0A        ByteArrayOutputStream baos = new ByteArrayOutputStream();%0A        writeResponseJSON(views, baos);%0A        ResponseHelper.writeResponse(params, 200, ResponseHelper.CONTENT_TYPE_JSON_UTF8, baos);%0A    %7D%0A%0A    private List%3CLong%3E getDefaultViewIds() throws ActionException %7B%0A        try %7B%0A            return viewService.getSystemDefaultViewIds();%0A        %7D catch (ServiceException e) %7B%0A            throw new ActionException(e.getMessage(), e);%0A        %7D%0A%0A    %7D%0A%0A    private List%3CView%3E getViews(List%3CLong%3E viewIds) %7B%0A        List%3CView%3E views = new ArrayList%3C%3E(viewIds.size());%0A        for (long viewId : viewIds) %7B%0A            views.add(viewService.getViewWithConf(viewId));%0A        %7D%0A        return views;%0A    %7D%0A%0A    private void writeResponseJSON(List%3CView%3E views, OutputStream out) throws ActionException %7B%0A        try (JsonGenerator json = JSONF.createGenerator(out)) %7B%0A            json.writeStartArray();%0A            for (View view : views) %7B%0A                writeView(view, json);%0A            %7D%0A            json.writeEndArray();%0A        %7D catch (JSONException %7C IOException e) %7B%0A            throw new ActionException(e.getMessage(), e);%0A        %7D%0A%0A    %7D%0A%0A    private void writeView(View view, JsonGenerator json) throws JSONException, IOException %7B%0A        String uuid = view.getUuid();%0A        String srsName = view.getBundleByName(%22mapfull%22)%0A                .getConfigJSON()%0A                .getJSONObject(%22mapConfig%22)%0A                .getString(%22srsName%22);%0A%0A        json.writeStartObject();%0A        json.writeStringField(%22uuid%22, uuid);%0A        json.writeStringField(%22srsName%22, srsName);%0A        json.writeEndObject();%0A    %7D%0A%0A%7D%0A

Add ActionHandler for getting systems default views