use of org.motechproject.osgi.web.ModuleRegistrationData in project motech by motech.
the class ModuleController method getCriticalMessage.
@RequestMapping(value = "/module/critical/{moduleName}", method = RequestMethod.GET)
@ResponseBody
public String getCriticalMessage(@PathVariable String moduleName) {
String criticalMessage = null;
if (isNotBlank(moduleName)) {
ModuleRegistrationData data = uiFrameworkService.getModuleDataByAngular(moduleName);
if (null != data) {
criticalMessage = data.getCriticalMessage();
uiFrameworkService.moduleBackToNormal(moduleName);
}
}
return criticalMessage;
}
use of org.motechproject.osgi.web.ModuleRegistrationData in project motech by motech.
the class UIFrameworkServiceImpl method moduleBackToNormal.
@Override
public void moduleBackToNormal(String moduleName) {
ModuleRegistrationData moduleRegistrationData = getModuleData(moduleName);
if (moduleRegistrationData != null) {
moduleRegistrationData.setNeedsAttention(false);
moduleRegistrationData.setCriticalMessage("");
}
}
use of org.motechproject.osgi.web.ModuleRegistrationData in project motech by motech.
the class MenuBuilderTest method setUpMenu.
private void setUpMenu() {
HashMap<String, String> i18n = new HashMap<>();
List<String> angularModules = new ArrayList<>();
ModuleRegistrationData adminRegData = new ModuleRegistrationData("admin", "/admin", angularModules, i18n);
adminRegData.setRoleForAccess("adminPerm");
adminRegData.addSubMenu("#/log", "Log");
adminRegData.addSubMenu("#/settings", "Settings");
adminRegData.addSubMenu("#/manage", "manage.modules");
adminRegData.setNeedsAttention(true);
adminRegData.addAngularModule("admin");
adminRegData.setBundle(bundle);
ModuleRegistrationData wsRegData = new ModuleRegistrationData("web-security", "/ws", angularModules, i18n);
wsRegData.addSubMenu("#/roles", "Roles");
wsRegData.addSubMenu("#/users", "Users");
wsRegData.addAngularModule("webSecurity");
wsRegData.setBundle(bundle);
ModuleRegistrationData emailRegData = new ModuleRegistrationData("email", "/email", angularModules, i18n);
List<String> rolesForAccess = new ArrayList<>();
rolesForAccess.add("emailPerm");
rolesForAccess.add("otherPerm");
rolesForAccess.add("completlyOtherPerm");
emailRegData.setRoleForAccess(rolesForAccess);
emailRegData.addAngularModule("email");
emailRegData.setDefaultURL("/email/send");
emailRegData.setBundle(bundle);
ModuleRegistrationData schedulerRegData = new ModuleRegistrationData("scheduler", "/scheduler", angularModules, i18n);
schedulerRegData.setRoleForAccess("schedulerPerm");
schedulerRegData.setDefaultURL("/scheduler");
schedulerRegData.setBundle(bundle);
ModuleRegistrationData metricsRegData = new ModuleRegistrationData("metrics", "/metrics", angularModules, i18n);
metricsRegData.setDefaultURL("/metrics");
metricsRegData.setBundle(bundle);
ModuleRegistrationData outboxRegData = new ModuleRegistrationData("outbox", "outbox", null, i18n);
outboxRegData.setBundle(bundle);
ModuleRegistrations modules = new ModuleRegistrations();
modules.setModulesWithoutSubmenu(Arrays.asList(emailRegData, schedulerRegData, metricsRegData));
modules.setModulesWithSubMenu(Arrays.asList(adminRegData, wsRegData));
modules.setModulesWithoutUI(Arrays.asList(outboxRegData));
when(uiFrameworkService.getRegisteredModules()).thenReturn(modules);
}
use of org.motechproject.osgi.web.ModuleRegistrationData in project motech by motech.
the class ServerBundleIT method testUIFrameworkService.
@Test
public void testUIFrameworkService() throws IOException, InterruptedException {
final ModuleRegistrationData registrationData = new ModuleRegistrationData("testUIFrameworkService", "/testUIFrameworkService");
uiFrameworkService.registerModule(registrationData);
assertEquals(registrationData, uiFrameworkService.getModuleData(registrationData.getModuleName()));
}
use of org.motechproject.osgi.web.ModuleRegistrationData in project motech by motech.
the class MenuBuilder method buildMenu.
/**
* Builds the menu for the given user. Modules are retrieved from {@code UIFrameworkService} and filtered
* based on permissions.
*
* @param username username of the user for which the menu should be built.
* @return the built menu object.
*/
public ModuleMenu buildMenu(String username) {
ModuleMenu moduleMenu = new ModuleMenu();
List<String> userRoles = userService.getRoles(username);
for (ModuleRegistrationData moduleRegistrationData : getModulesWithSubMenu(userRoles)) {
ModuleMenuSection menuSection = getModuleMenuSection(username, userRoles, moduleRegistrationData);
if (!menuSection.getLinks().isEmpty()) {
moduleMenu.addMenuSection(menuSection);
}
}
moduleMenu.addMenuSection(serverModulesMenuSection(userRoles));
if (checkUserPermission(userRoles, REST_API_PERMISSION)) {
ModuleMenuSection restSection = restDocumentationMenu();
if (CollectionUtils.isNotEmpty(restSection.getLinks())) {
moduleMenu.addMenuSection(restSection);
}
}
return moduleMenu;
}
Aggregations