Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.io.IOException;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -182,7 +183,7 @@ public void getNewPackage(@RequestParam(required = false)
String key, Class<?> type, @RequestParam(required = false)
String ids, @RequestParam(required = false)
String uuids, @RequestParam(required = false)
Date modifiedSince, HttpServletResponse response) throws IOException, SerializationException {
Date modifiedSince,@RequestParam(required = false ,defaultValue ="false") boolean includeRetired, HttpServletResponse response) throws IOException, SerializationException {
if (Boolean.valueOf(Context.getAdministrationService()
.getGlobalProperty(MetadataSharingConsts.GP_ENABLE_ON_THE_FLY_PACKAGES, "false").trim())) {
String accessKey = Context.getAdministrationService()
Expand Down Expand Up @@ -226,7 +227,21 @@ public void getNewPackage(@RequestParam(required = false)
}
}
}
}
if (uuids == null && ids == null) {
List<Object> items = Handler.getItems(type, includeRetired, null, null, null);
if (items != null) {
Copy link
Copy Markdown
Member

@mozzy11 mozzy11 Oct 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you have to hard code the boolean includeRetired to true ? . i would think we could have it as a variable that has a default behaviour may be false
but can also optionally be configurable via the URL ie

http://localhost:8080/openmrs/ws/rest/metadatasharing/package/new.form?type=org.openmrs.Concept&modifiedSince=01/01/2012&IncludeRetired=True

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mozzy11 That makes sense...I will change to that...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mozzy11 How is this now?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya looks fine

for (Object item : items) {
if (modifiedSince == null) {
exporter.addItem(item);
} else {
if (OpenmrsUtil.compareWithNullAsEarliest(Handler.getDateChanged(item),
modifiedSince) > 0) {
exporter.addItem(item);
}
}
}
}
}
exporter.getPackage().setName("Package");
exporter.getPackage().setDescription(
"Contains " + exporter.getPackage().getItems().size() + " items of type " + type.getSimpleName());
Expand All @@ -237,7 +252,8 @@ public void getNewPackage(@RequestParam(required = false)
response.setHeader("Content-Disposition", "attachment; filename=\"metadata.zip\"");
MetadataZipper zipper = new MetadataZipper();
zipper.zipPackage(response.getOutputStream(), exporter.getExportedPackage().getSerializedPackage());
}
}
}
finally {
Context.removeProxyPrivilege(MetadataSharingConsts.MODULE_PRIVILEGE);
Context.removeProxyPrivilege(privilegeCompatibility.GET_CONCEPTS());
Expand All @@ -262,8 +278,8 @@ public void getNewPackageCompatibility(@RequestParam(required = false)
String key, Class<?> type, @RequestParam(required = false)
String ids, @RequestParam(required = false)
String uuids, @RequestParam(required = false)
Date modifiedSince, HttpServletResponse response) throws IOException, SerializationException {
getNewPackage(key, type, ids, uuids, modifiedSince, response);
Date modifiedSince,@RequestParam(required = false ,defaultValue ="false") boolean includeRetired, HttpServletResponse response) throws IOException, SerializationException {
getNewPackage(key, type, ids, uuids, modifiedSince,includeRetired, response);
}

private static void sendErrorResponseAfterDelay(HttpServletResponse response, int httpCode, String errorMessage)
Expand Down