use of com.serotonin.m2m2.module.Module in project ma-modules-public by infiniteautomation.
the class ModulesRestController method getCoreModule.
/**
* Create a Core Module Model
*
* @return
*/
private ModuleModel getCoreModule() {
CoreModuleModel coreModel = new CoreModuleModel(ModuleRegistry.getCoreModule());
coreModel.setGuid(Providers.get(ICoreLicense.class).getGuid());
coreModel.setInstanceDescription(SystemSettingsDao.getValue(SystemSettingsDao.INSTANCE_DESCRIPTION));
coreModel.setDistributor(Common.envProps.getString("distributor"));
coreModel.setUpgradeVersionState(SystemSettingsDao.getIntValue(SystemSettingsDao.UPGRADE_VERSION_STATE));
return coreModel;
}
use of com.serotonin.m2m2.module.Module 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.Module 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", produces = { "application/json" })
public ResponseEntity<List<ModuleModel>> listModules(HttpServletRequest request) {
RestProcessResult<List<ModuleModel>> result = new RestProcessResult<List<ModuleModel>>(HttpStatus.OK);
User user = this.checkUser(request, result);
if (result.isOk()) {
if (Permissions.hasAdmin(user)) {
List<ModuleModel> models = new ArrayList<ModuleModel>();
ModuleModel core = getCoreModule();
List<Module> modules = ModuleRegistry.getModules();
models.add(core);
for (Module module : modules) 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 result.createResponseEntity(models);
} else {
result.addRestMessage(this.getUnauthorizedMessage());
}
}
return result.createResponseEntity();
}
use of com.serotonin.m2m2.module.Module in project ma-core-public by infiniteautomation.
the class ModuleRegistry method ensurePermissionDefinitions.
private static void ensurePermissionDefinitions() {
if (PERMISSION_DEFINITIONS == null) {
synchronized (LOCK) {
if (PERMISSION_DEFINITIONS == null) {
Map<String, PermissionDefinition> map = new HashMap<String, PermissionDefinition>();
for (PermissionDefinition def : Module.getDefinitions(preDefaults, PermissionDefinition.class)) {
map.put(def.getPermissionTypeName(), def);
}
for (Module module : MODULES.values()) {
for (PermissionDefinition def : module.getDefinitions(PermissionDefinition.class)) map.put(def.getPermissionTypeName(), def);
}
for (PermissionDefinition def : Module.getDefinitions(postDefaults, PermissionDefinition.class)) {
map.put(def.getPermissionTypeName(), def);
}
PERMISSION_DEFINITIONS = map;
}
}
}
}
use of com.serotonin.m2m2.module.Module in project ma-core-public by infiniteautomation.
the class ModuleRegistry method getCoreModule.
/**
* Helper Method to create a Module with Core Information
* @return
*/
public static Module getCoreModule() {
Module core = new Module("core", Common.getVersion(), new TranslatableMessage("modules.core.description"), "Infinite Automation Systems, Inc.", "https://www.infiniteautomation.com", null, -1, Common.isCoreSigned());
if (Common.isInvalid())
core.setLicenseType("Invalid");
else
core.setLicenseType(Common.license() == null ? null : Common.license().getLicenseType());
core.addDefinition((LicenseDefinition) Providers.get(ICoreLicense.class));
return core;
}
Aggregations