Alexander Wels has posted comments on this change.

Change subject: userportal, webadmin: converted docs mapping files to properties
......................................................................


Patch Set 3:

(4 comments)

If we are going to generate #2 from somewhere else, couldn't we just generate a 
JSON file from whatever source we have? Which would sort eliminate the need for 
a servlet. I hadn't realized we wanted to generate the file when I suggested 
the servlet.

....................................................
File 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/servlet/JsonConverterServlet.java
Line 38:             engineLocalConfig.expandString(
Line 39:                     
config.getInitParameter(SOURCE_PROPERTIES_FILE).replaceAll("%\\{", "\\${"))
Line 40:         );
Line 41: 
Line 42:         File propertiesFile = new File(propertiesPath);
Just a thought, maybe we can move the code that generates the json object out 
into a utility class, that way it will be available to other places that might 
want to do something similar? Just a thought.
Line 43:         if (propertiesFile.exists() && propertiesFile.canRead()) {
Line 44:             Properties p = new Properties();
Line 45:             try {
Line 46:                 p.load(new FileInputStream(propertiesFile));


Line 42:         File propertiesFile = new File(propertiesPath);
Line 43:         if (propertiesFile.exists() && propertiesFile.canRead()) {
Line 44:             Properties p = new Properties();
Line 45:             try {
Line 46:                 p.load(new FileInputStream(propertiesFile));
Aren't we leaking a FileInputStream here? We should be able to use a Java 7 
construct here easily enough:

 try (FileInputStream fis = new FileInputStream(propertiesFile)) {
  p.load(fis)
  jsonToServe = mapper.writeValueAsString(p);
} catch (IOException e) {
  log.error("problem parsing properties file: " + 
propertiesFile.getAbsolutePath(), e);
}
Line 47:                 jsonToServe = mapper.writeValueAsString(p);
Line 48:             }
Line 49:             catch (IOException e) {
Line 50:                 log.error("problem parsing Properties file: " + 
propertiesFile.getAbsolutePath(), e);


Line 54: 
Line 55:     @Override
Line 56:     protected void doGet(HttpServletRequest request, 
HttpServletResponse response) throws ServletException, IOException {
Line 57:         if (jsonToServe != null) {
Line 58:             response.setContentType("application/json");
Maybe consider using a standard enum/lib for this like: 
http://docs.oracle.com/javaee/6/api/javax/ws/rs/core/MediaType.html
Line 59:             PrintStream printStream = new 
PrintStream(response.getOutputStream());
Line 60:             printStream.print(jsonToServe);
Line 61:         }
Line 62:         else {


....................................................
File 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/uicommon/DocumentationPathTranslator.java
Line 9: import com.google.gwt.json.client.JSONString;
Line 10: import com.google.gwt.json.client.JSONValue;
Line 11: 
Line 12: public class DocumentationPathTranslator {
Line 13:     private static Map<String, String> documentationPathMap;
I know people are not a big fan of GWT Dictionary, but I think this is the 
perfect example of where one should use a Dictionary.
Line 14: 
Line 15:     // GWT overlay for the JSON object containing the help mappings
Line 16:     private static class Mapping extends JavaScriptObject {
Line 17:         protected Mapping() {}


-- 
To view, visit http://gerrit.ovirt.org/20793
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I6b96d005684007125d5f3940abdbec25d4cae81f
Gerrit-PatchSet: 3
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Greg Sheremeta <[email protected]>
Gerrit-Reviewer: Alexander Wels <[email protected]>
Gerrit-Reviewer: Alon Bar-Lev <[email protected]>
Gerrit-Reviewer: Einav Cohen <[email protected]>
Gerrit-Reviewer: Greg Sheremeta <[email protected]>
Gerrit-Reviewer: Vojtech Szocs <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to