-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HSY download basket #74
Conversation
…st permissions for layers
Merged HSY development branches to HSY Oskari develop branch forked from Oskari master.
Replaces PR #55 |
|
||
if (OskariLayer.TYPE_WMS.equals(layerType)) { | ||
//HSY doesn't want GFI from basemaps. | ||
boolean isBaseMap = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about instead of this you modify https://github.com/oskariorg/oskari-server/blob/master/service-map/src/main/java/fi/nls/oskari/map/layer/formatters/LayerJSONFormatterWMS.java#L127 with
final JSONObject attrs = layer.getAttributes();
boolean disableGFI = false;
if(attrs != null) {
disableGFI = attrs.optBoolean(KEY_ISQUERYABLE);
}
JSONHelper.putValue(layerJson, KEY_ISQUERYABLE, !disableGFI && capabilities.optBoolean(KEY_ISQUERYABLE));
Then you would need to have { "isQueryable" : false } for the layer attributes instead of { "basemap" : true }. This would disable GFI requests on the frontend side automatically and the server code can be left as is? Similar logic should be done for arcgislayers. At least this needs be configurable somehow instead of always blocking for basemaps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't resist doing it for you: 3ffdac1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And a quick fix for the previous commit: 3e7a95d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
} else { | ||
} | ||
// else if (user.isGuest()) { | ||
// JSONHelper.putValue(permission, "publish", NO_PUBLICATION_PERMISSION); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
import fi.nls.oskari.wfs.WFSLayerConfigurationServiceIbatisImpl; | ||
|
||
@OskariActionRoute("SaveMultipleFeatures") | ||
public class SaveMultipleFeaturesHandler extends ActionHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be extended to function with multiple features https://github.com/oskariorg/oskari-server/blob/master/control-base/src/main/java/fi/nls/oskari/control/feature/SaveFeatureHandler.java Instead of creating a new handler that basically does the same thing. Also I would much prefer constructing the XML with a libraryor at least a template file instead of string concatenation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File removed
} | ||
} | ||
if (allUpdatesSuccess) { | ||
ResponseHelper.writeResponse(params, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty response for success? Maybe find a better output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File removed
if (allUpdatesSuccess) { | ||
ResponseHelper.writeResponse(params, ""); | ||
} else { | ||
ResponseHelper.writeResponse(params, "Exception"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should throw ActionException wrapping the original exception or an ActionParamsException if stacktrace will not give any help debugging the issue. This is not proper output for exception handling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File removed
* Created by markokuo on 6.10.2015. | ||
*/ | ||
public class ZipDownloadDetails { | ||
private String FileName = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use lowercase first letter for variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -0,0 +1,86 @@ | |||
package downloadbasket.actions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe run an autoformat on the file so indentation is not all over the place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add some comments on the class. What does this action route do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatted & commented.
import downloadbasket.helpers.SendDownloadDetailsToEmailThread; | ||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some comments what does this action route do. Maybe find a better name as well? Downloading "all" seems a bit confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments and changed name.
} | ||
in.close(); | ||
|
||
JSONObject jsoni = new JSONObject(html); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the variable name describing the content? html in JSON?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
while ((inputLine = in.readLine()) != null) { | ||
html += inputLine; | ||
} | ||
in.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move close() to finally statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can actually do this with less code and respecting layer credentials with:
HttpURLConnection con = IOHelper.getConnection(url, user, pass);
con.setRequestProperty("Accept-Charset", "UTF-8");
final String data = IOHelper.readString(con, "UTF-8");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
final JSONArray data = new JSONArray(); | ||
|
||
OskariLayerService mapLayerService = new OskariLayerServiceIbatisImpl(); | ||
OskariLayer oskariLayer = mapLayerService.find(params.getHttpParam(PARAM_URL)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should URL be ID?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
OskariLayer oskariLayer = mapLayerService.find(params.getHttpParam(PARAM_URL)); | ||
|
||
if(oskariLayer != null){ | ||
FINAL_WMS_URL = oskariLayer.getUrl(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't set class scope variables between request. Concurrent requests will be a nightmare. Use a local variable and pass it around instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
* Created by markokuo on 6.10.2015. | ||
*/ | ||
public class LoadZipDetails { | ||
private String GetFeatureInfoRequest = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use lowercase variable names here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
Not sure if you are done with the changes yet or still working on this, but can you add some comments to the properties-list in the description? Like what do they mean/control and any advice on what values one might want to use. What is the difference between oskari.wfs.download.email.message and oskari.wfs.download.email.message.datadescription. Is oskari.wfs.download.email.datadescription_link some text that's used as link-text or is it some url and does some link need a prefix (oskari.wfs.download.link.url.prefix) and why? What's the difference between Can "cropping" only occur on a namespace defined here oskari.wfs.cropping.namespace? What is configured by oskari.wfs.service.url and is there some reason it shouldn't be as a layer in oskari_maplayer database table? What do these configure: oskari.wfs.download.folder.name and oskari.wfs.download.normal.way.downloads? |
error-checking moved to SendDownloadDetailsToEmailThread, fixed zipdetail-files, JUnit-tests now working
zipdetail -files fixed, JUnit-tests work, error-checking in DownloadServices moved to SendDownloadDetailsToEmailThread, run-method splitted as well
to SendDownloadDetailsToEmailThread, fixed zipDetails-files, JUnit-tests work now, split run-method
ldz.setUserEmail(userDetails.getString("email")); | ||
ldz.setLanguage(this.locale.getLanguage()); | ||
ldz.setDownloadNormalWay(normalDownloads.isBboxCropping(croppingMode, croppingLayer)); | ||
OskariLayerService mapLayerService = new OskariLayerServiceIbatisImpl(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't create multiple instances of OskariLayerServiceIbatisImpl
, definitely not inside a loop
|
||
private static final String PARAM_DOWNLOAD_DETAILS = "downloadDetails"; | ||
private static final String PARAM_USER_DETAILS = "userDetails"; | ||
OskariLayerService mapLayerService; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field should be private
try { | ||
JSONObject userDetails = new JSONObject(strUserDetails); | ||
JSONArray ddArray = new JSONArray(downloadDetails); | ||
mapLayerService = new OskariLayerServiceIbatisImpl(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be initialized only once for this ActionHandler in an overridden version of the init() function (https://github.com/oskariorg/oskari-server/blob/develop/service-control/src/main/java/fi/nls/oskari/control/ActionHandler.java#L31-L36)
* Send download details email service (thread). | ||
*/ | ||
public class SendDownloadDetailsToEmailThread implements Runnable { | ||
OskariLayerService mapLayerService; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these fields should be private (and probably final as well)
Looks good for merging. |
Can you still add some more detail in the description about what this does and what bundles need to be started for the frontend? You can link to the docs in the frontend repository. Also you can just list the properties once without class references and just tell what they mean. In general tell us how to use this functionality. |
Tried with the zip-download from oskari.org and the following extra configuration in oskari-ext.properties:
I also added the code for the functionality as dependency to the webapp-map:
Notes:
I feel this needs some more documentation about the layers that are assumed like some WFS-layers I suppose. I tried it with the OSM worldwide WMS-layer and eventually got to a point where the frontend said that I have mail. I got a mail (formatting could be changed a bit to add spaces between sentences and removing the additional "link" text/fix the download url) :
I did get a new file 095478da-276c-4448-b99c-c7a63863322b.zip in the configured download folder "C:/Temp", but I guess there needs to be something that would serve the file to the user. Like an nginx or Apache with a static resource folder to serve content from the configured download folder "C:/Temp". The zip is empty and the server log had this:
Not really sure what went wrong. Probably that I used WMS-layers (the ones included in the sample app) or some misconfiguration. Final thoughts: For properties I would suggest that:
|
Download Basket (download-basket) adds the functionality of downloading vector data layers in Oskari platform. Layer cropping functionalities included.
Front end bundle configuration guide: http://oskari.org/api/bundles#1.44.1/framework/download-basket
Dowload Basket also uses properties-files for custom configurations. Examples below.
Properties-files:
oskari.wfs.download.folder.name: The physical path to system where downloaded zip-files should be saved, for example /server/temp/. Cron-based auto-delete recommended, not included. A link to a generated zip-archive will work as long as the file exists
oskari.wfs.download.normal.way.downloads: Cropping mode parameter for WFS requests, for example "rectangle"
oskari.wfs.download.smtp.host: The address of smtp-server, for example "localhost"
oskari.wfs.download.smtp.port: The port of smtp-server, for example "9999"
oskari.wfs.download.email.from: The "from"-field of download basket's return e-mail, for example "noreply@company.com"
oskari.wfs.download.email.subject: The subject of download basket's return e-mail, for example "Company's download service"
oskari.wfs.download.email.header: The header of download basket's return e-mail, for example "Hello,"
oskari.wfs.download.email.message: Main e-mail message that contains the download link, for example "The data is now ready for download in: link"
oskari.wfs.download.email.footer: The footer of download basket's return e-mail, for example "The download URL is valid for 10 days"
oskari.wfs.download.email.message.datadescription: A description of the datadescription_link, for example "Metadata here:"
oskari.wfs.download.email.datadescription_link: A link to the metadata page of the operator. URL has to be valid, and it does not require a prefix word. Example "http://company.com/opendata"
oskari.wfs.download.link.url.prefix: Example: "http://localhost:9999/
oskari.wfs.cropping.namespace: A GeoServer-namespace that contains the data that can be used for cropping of the layers, for example 'cropping_areas:municipal_areas' ("cropping_areas" -workspace in GeoServer that contains polygon layers such as "municipal_areas", "provincial_areas", "states" etc.)
oskari.wfs.service.url: URL for GeoServer, when user is trying to download cropped data, for example http://localhost:9999/geoserver/wfs
oskari.wfs.error.message: Message that indicates the user that an error has occurred, for example "The service is experiencing problems, please try again later" and "This error report was generated automatically by the system"
oskari.wfs.download.error.report.support.email: E-mail address of operator's support center, for example "support@company.com"
oskari.wfs.download.error.report.subject: Topic for error report e-mail for admin, for example "Error has occurred in the download service"
Includes automatic migration to add the functionality to system default and users appsetups for the sample application. It's skipped by default, but can be activated by adding this to oskari-ext.properties (note that the sample-module must be included in db.additional.modules-property):