Skip to content

Commit

Permalink
SYNCT-262: Changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
areklalo committed Jan 11, 2019
1 parent d49a1b4 commit 009fa38
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 45 deletions.
Expand Up @@ -379,4 +379,7 @@ public static String getEventHandlerName() {
SyncConstants.ATOMFEED_EVENT_HANDLER);
}

public static boolean parentInstanceUriIsEmpty() {
return StringUtils.isBlank(SyncUtils.getParentBaseUrl(null));
}
}
Expand Up @@ -18,13 +18,8 @@ public void validate(SyncConfiguration syncConfiguration, Errors errors) {
if (StringUtils.isBlank(syncConfiguration.getGeneral().getLocalInstanceId())) {
errors.addErrorCode(ERROR_CODE);
}
if (parentInstanceUriIsEmpty()) {
if (SyncUtils.parentInstanceUriIsEmpty()) {
errors.addErrorCode(PARENT_URI_ERROR);
}
}

private boolean parentInstanceUriIsEmpty() {
return StringUtils.isBlank(SyncUtils.getParentBaseUrl(null));
}

}
Expand Up @@ -46,16 +46,11 @@ public String controller(@RequestParam(value = RETRY_LOG_UUID) String messageUui
}

private String buildAuditListUri(Integer backPageIndex) {
if (backPageIndex == null) {
backPageIndex = 1;
}
return AUDIT_LIST_PAGE + "?pageIndex=" + backPageIndex;
return AUDIT_LIST_PAGE + "?pageIndex=" + (backPageIndex == null ? 1 : backPageIndex);
}

private String buildNewMessageUri(Integer backPageIndex, AuditMessage message) {
if (backPageIndex == null) {
backPageIndex = 1;
}
return AUDIT_PAGE + "?messageUuid=" + message.getUuid() + "&backPageIndex=" + backPageIndex;
return AUDIT_PAGE + "?messageUuid=" + message.getUuid() + "&backPageIndex=" +
(backPageIndex == null ? 1 : backPageIndex);
}
}
@@ -1,6 +1,5 @@
package org.openmrs.module.sync2.page.controller;

import org.apache.commons.lang.StringUtils;
import org.openmrs.module.sync2.api.utils.SyncUtils;
import org.openmrs.module.uicommons.util.InfoErrorMessageUtil;
import org.openmrs.ui.framework.UiUtils;
Expand Down Expand Up @@ -29,14 +28,10 @@ public class Sync2PageController {
* @param ui injected the UiUtils object
*/
public void controller(PageModel model, HttpSession session, UiUtils ui) {
boolean emptyURI = parentInstanceUriIsEmpty();
boolean emptyURI = SyncUtils.parentInstanceUriIsEmpty();
model.addAttribute(ATTRIBUTE_EMPTY_URI, emptyURI);
if (emptyURI) {
InfoErrorMessageUtil.flashErrorMessage(session, ui.message(PARENT_URI_ERROR));
}
}

private boolean parentInstanceUriIsEmpty() {
return StringUtils.isBlank(SyncUtils.getParentBaseUrl(null));
}
}
Expand Up @@ -34,10 +34,7 @@ public String get(ModelMap model,
model.addAttribute(SyncMessageUtils.SUCCESS_MESSAGE, success);
model.addAttribute(SyncMessageUtils.ALERT_MESSAGE_MODEL, alertMessage);

if (backPageIndex == null) {
backPageIndex = 1;
}
model.addAttribute("pageIndex", backPageIndex);
model.addAttribute("pageIndex", backPageIndex == null ? 1: backPageIndex);
return "/module/sync2/sync2AuditList";
}

Expand Down
Expand Up @@ -9,7 +9,6 @@
*/
package org.openmrs.module.sync2.web.controller;

import org.apache.commons.lang.StringUtils;
import org.openmrs.module.sync2.SyncConstants;
import org.openmrs.module.sync2.SyncMessageUtils;
import org.openmrs.module.sync2.api.exceptions.SyncValidationException;
Expand Down Expand Up @@ -57,7 +56,7 @@ public void manage(ModelMap model,
model.addAttribute(SyncMessageUtils.SUCCESS_MESSAGE, success);
model.addAttribute(SyncMessageUtils.ALERT_MESSAGE_MODEL, alertMessage);

boolean emptyURI = parentInstanceUriIsEmpty();
boolean emptyURI = SyncUtils.parentInstanceUriIsEmpty();
model.addAttribute(ATTRIBUTE_EMPTY_URI, emptyURI);
if (emptyURI) {
SyncMessageUtils.errorMessage(model, PARENT_URI_ERROR);
Expand Down Expand Up @@ -115,8 +114,4 @@ private String getFirstErrorCode(Errors errors) {
return errors.getErrorsCodes().get(SyncConstants.ZERO);
}

private boolean parentInstanceUriIsEmpty() {
return StringUtils.isBlank(SyncUtils.getParentBaseUrl(null));
}

}
Expand Up @@ -54,16 +54,11 @@ public String retry(ModelMap model,
}

private String buildAuditListUri(Integer backPageIndex) {
if (backPageIndex == null) {
backPageIndex = 1;
}
return AUDIT_LIST_PAGE + "?pageIndex=" + backPageIndex;
return AUDIT_LIST_PAGE + "?pageIndex=" + (backPageIndex == null ? 1 : backPageIndex);
}

private String buildNewMessageUri(Integer backPageIndex, AuditMessage message) {
if (backPageIndex == null) {
backPageIndex = 1;
}
return AUDIT_PAGE + "?messageUuid=" + message.getUuid() + "&backPageIndex=" + backPageIndex;
return AUDIT_PAGE + "?messageUuid=" + message.getUuid() + "&backPageIndex=" +
(backPageIndex == null ? 1 : backPageIndex);
}
}
Expand Up @@ -73,12 +73,8 @@ public ResponseEntity<SimpleObject> resolve(@RequestParam("conflictUuid") String
}

private String buildResolutionUrl(AuditMessage conflictMessage, String auditBackPage, Integer backPageIndex) {
if (StringUtils.isBlank(auditBackPage)) {
auditBackPage = DEFAULT_PAGE;
}
if (backPageIndex == null || backPageIndex < 1) {
backPageIndex = 1;
}
return auditBackPage + "?" + MESSAGE_UUID + conflictMessage.getUuid() + BACK_PAGE_INDEX + backPageIndex;
return (StringUtils.isBlank(auditBackPage) ? DEFAULT_PAGE : auditBackPage) +
"?" + MESSAGE_UUID + conflictMessage.getUuid() +
BACK_PAGE_INDEX + (backPageIndex == null ? 1 : backPageIndex);
}
}

0 comments on commit 009fa38

Please sign in to comment.