use of com.serotonin.m2m2.module.ModuleRegistry.CoreModule in project ma-modules-public by infiniteautomation.
the class ModulesRestController method getCore.
@ApiOperation(value = "Get Core Module", notes = "For checking current licensing and version")
@RequestMapping(method = RequestMethod.GET, value = "/core", produces = { "application/json" })
public ResponseEntity<MappingJacksonValue> getCore(HttpServletRequest request) {
RestProcessResult<MappingJacksonValue> result = new RestProcessResult<>(HttpStatus.OK);
User user = this.checkUser(request, result);
if (result.isOk()) {
ModuleModel coreModule = getCoreModule();
MappingJacksonValue jacksonValue = new MappingJacksonValue(coreModule);
if (Permissions.hasAdmin(user)) {
jacksonValue.setSerializationView(ModuleModel.AdminView.class);
} else {
jacksonValue.setSerializationView(Object.class);
}
return result.createResponseEntity(jacksonValue);
}
return result.createResponseEntity();
}
use of com.serotonin.m2m2.module.ModuleRegistry.CoreModule in project ma-modules-public by infiniteautomation.
the class ModulesRestController method listModules.
@ApiOperation(value = "List Current Installed Modules", notes = "List all installed")
@RequestMapping(method = RequestMethod.GET, value = "/list")
public List<ModuleModel> listModules(@AuthenticationPrincipal PermissionHolder user) {
permissionService.ensureAdminRole(user);
List<ModuleModel> models = new ArrayList<ModuleModel>();
List<Module> modules = ModuleRegistry.getModules();
for (Module module : modules) {
if (module instanceof CoreModule) {
CoreModuleModel coreModel = new CoreModuleModel(ModuleRegistry.getModule(ModuleRegistry.CORE_MODULE_NAME));
coreModel.setGuid(Providers.get(ICoreLicense.class).getGuid());
coreModel.setInstanceDescription(SystemSettingsDao.getInstance().getValue(SystemSettingsDao.INSTANCE_DESCRIPTION));
coreModel.setDistributor(Common.envProps.getString("distributor"));
coreModel.setUpgradeVersionState(SystemSettingsDao.getInstance().getIntValue(SystemSettingsDao.UPGRADE_VERSION_STATE));
coreModel.setStoreUrl(Common.envProps.getString("store.url"));
models.add(coreModel);
} else {
models.add(new ModuleModel(module));
}
}
// Add the unloaded modules at the end?
List<Module> unloaded = ModuleRegistry.getUnloadedModules();
for (Module module : unloaded) {
ModuleModel model = new ModuleModel(module);
model.setUnloaded(true);
models.add(model);
}
return models;
}
Aggregations