use of com.infiniteautomation.mango.rest.latest.model.modules.CoreModuleModel in project ma-modules-public by infiniteautomation.
the class ModulesRestController method getCore.
@ApiOperation(value = "Get Core Module", notes = "For checking current licensing and version", response = ModuleModel.class)
@RequestMapping(method = RequestMethod.GET, value = "/core")
public MappingJacksonValue getCore(@AuthenticationPrincipal PermissionHolder user) {
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"));
MappingJacksonValue jacksonValue = new MappingJacksonValue(coreModel);
if (permissionService.hasAdminRole(user)) {
jacksonValue.setSerializationView(AdminView.class);
} else {
jacksonValue.setSerializationView(Object.class);
}
return jacksonValue;
}
use of com.infiniteautomation.mango.rest.latest.model.modules.CoreModuleModel 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