package org.oskari.service.user;

import fi.nls.oskari.domain.User;
import fi.nls.oskari.service.OskariComponent;
import fi.nls.oskari.service.ServiceException;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.json.JSONObject;
import org.opengis.filter.Filter;

public abstract class UserLayerService extends OskariComponent {
    //public abstract void getLayers(User user) throws ServiceException;
    //public abstract void getLayer(String layerId, User user) throws ServiceException;
    public abstract boolean isUserContentLayer(String layerId);
    public abstract int getBaselayerId();
    public abstract int parseId(String layerId);
    public abstract JSONObject getOskariStyle(String layerId);
    /**
     * Assumes that layer permissions are checked elsewhere in the code with hasViewPermission() for example
     * @param layerId
     * @param bbox
     * @return
     */
    public abstract Filter getWFSFilter(String layerId, ReferencedEnvelope bbox);
    public SimpleFeatureCollection postProcess(SimpleFeatureCollection sfc) throws Exception {
        // do nothing, but allows overriding
        return sfc;
    }

    public abstract boolean hasViewPermission(String id, User user);
}
@@ -61,16 +61,116 @@
 n.User;%0A
+import fi.nls.oskari.domain.map.UserDataLayer;%0Aimport fi.nls.oskari.domain.map.wfs.WFSLayerOptions;%0A
 import f
@@ -207,16 +207,16 @@
 ponent;%0A
-
 import f
@@ -805,37 +805,40 @@
  layerId);%0A    p
-ublic
+rotected
  abstract JSONOb
@@ -835,51 +835,41 @@
 act 
-JSONObject getOskariStyle(String layerI
+UserDataLayer getLayer(int i
 d);%0A
+%0A
     
@@ -1294,16 +1294,16 @@
 %0A    %7D%0A%0A
-
     publ
@@ -1362,10 +1362,166 @@
 r user);
+%0A%0A    public WFSLayerOptions getWFSLayerOptions(String layerId) %7B%0A        int id = parseId(layerId);%0A        return getLayer(id).getWFSLayerOptions();%0A    %7D
 %0A%7D

add getWFSLayerOptions for UserLayerService