-
Notifications
You must be signed in to change notification settings - Fork 504
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
RESTWS-688: Enable installation of modules through rest calls #316
Conversation
Looks good 👍 |
Looks good:) |
Hello @malmike, why are the test failing? |
854de20
to
53da780
Compare
The tests pass, just the coverage that dropped by 0.1 |
53da780
to
05a94bf
Compare
05a94bf
to
3d8f3f6
Compare
Looks good now. |
return tempModule; | ||
} | ||
catch (MalformedURLException e) { | ||
throw new RuntimeException(e.getMessage()); |
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.
It is not good good to throw RuntimeException in this case. Throw an APIException
But also remember to pass on the original exception as the second parameter.
throw new RuntimeException(e.getMessage()); | ||
} | ||
catch (IOException e) { | ||
throw new RuntimeException(e.getMessage()); |
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.
Same here as above.
throw new RuntimeException(e.getMessage()); | ||
} | ||
finally { | ||
if (tempModule == null && moduleFile != 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.
Since it is moduleFile that you are deleting, isn't it enough to just check for it alone?
d6580a5
to
9bb73f2
Compare
@@ -109,17 +127,63 @@ public Object create(SimpleObject post, RequestContext context) throws ResponseE | |||
case UNLOAD: | |||
unloadModules(modules, servletContext); | |||
break; | |||
case INSTALL: | |||
Module module = installModule(modules, installUri, servletContext); | |||
List<Module> listModule = new ArrayList<Module>(); |
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 there any reason why you do not just call listModule.add(module)?
|
||
|
||
private Module installModule(Collection<Module> modules, String installUri, ServletContext servletContext) { | ||
List<Module> moduleList = new ArrayList<Module>(modules); |
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.
What happens if modules is empty?
File moduleFile = null; | ||
|
||
try { | ||
//Module existingModule = moduleFactoryWrapper.getModuleById(module.getModuleId()); |
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.
For the above, did you see this? https://wiki.openmrs.org/display/docs/Java+Conventions#JavaConventions-Donotcommentoutcode
JIRA TICKET NAME:
RESTWS-688: Enable installation of modules through rest calls
SUMMARY:
Currently a module could not be installed through a REST call. When a REST call is made the module is to be downloaded on to the server, loaded and started.