Source:
<code>public Object create(SimpleObject post, RequestContext context) throws ResponseException { moduleFactoryWrapper.checkPrivilege(); ModuleAction action = newDelegate(); setConvertedProperties(action, post, getCreatableProperties(), true); String installUri = action.getInstallUri(); Collection<Module> modules; if (action.isAllModules() != null && action.isAllModules()) { modules = moduleFactoryWrapper.getLoadedModules(); action.setModules(new ArrayList<Module>(modules)); } else { modules = action.getModules(); } ServletContext servletContext = getServletContext(context); if (modules == null || modules.isEmpty()) { throw new IllegalRequestException("Cannot execute action " + action.getAction() + " on empty set of modules."); } else { if (action.getAction() == Action.INSTALL) { if (installUri == null || !ResourceUtils.isUrl(installUri)) { throw new IllegalRequestException("The installUri needs to be a URL for this action to be performed"); } } else { if (action.isAllModules() == null || !action.isAllModules()) { for (Module module : modules) { if (module == null) { throw new IllegalRequestException( "One or more of the modules you specified are not loaded on this server"); } if (module.getModuleId().equals(RestConstants.MODULE_ID)) { throw new IllegalRequestException("You are not allowed to modify " + module.getModuleId() + " via this REST call"); } } } Module restModule = moduleFactoryWrapper.getModuleById(RestConstants.MODULE_ID); modules.remove(restModule); } switch (action.getAction()) { case START: startModules(modules, servletContext); break; case STOP: stopModules(modules, servletContext, true); break; case RESTART: restartModules(modules, servletContext); break; case UNLOAD: unloadModules(modules, servletContext); break; case INSTALL: Module module = installModule(modules, installUri, servletContext); <START> List<Module> listModule = new ArrayList<Module>(); <END> listModule.add(0, module); action.setModules(listModule); break; } } return ConversionUtil.convertToRepresentation(action, Representation.DEFAULT); }</code><technical_language>Is reason do call listModule.add(module)</technical_language>

Target:
public Object create(SimpleObject post, RequestContext context) throws ResponseException { moduleFactoryWrapper.checkPrivilege(); ModuleAction action = newDelegate(); setConvertedProperties(action, post, getCreatableProperties(), true); String installUri = action.getInstallUri(); Collection<Module> modules; if (action.isAllModules() != null && action.isAllModules()) { modules = moduleFactoryWrapper.getLoadedModules(); action.setModules(new ArrayList<Module>(modules)); } else { modules = action.getModules(); } ServletContext servletContext = getServletContext(context); if (modules == null || modules.isEmpty()) { throw new IllegalRequestException("Cannot execute action " + action.getAction() + " on empty set of modules."); } else { if (action.getAction() == Action.INSTALL) { if (installUri == null || !ResourceUtils.isUrl(installUri)) { throw new IllegalRequestException("The installUri needs to be a URL for this action to be performed"); } } else { if (action.isAllModules() == null || !action.isAllModules()) { for (Module module : modules) { if (module == null) { throw new IllegalRequestException( "One or more of the modules you specified are not loaded on this server"); } if (module.getModuleId().equals(RestConstants.MODULE_ID)) { throw new IllegalRequestException("You are not allowed to modify " + module.getModuleId() + " via this REST call"); } } } Module restModule = moduleFactoryWrapper.getModuleById(RestConstants.MODULE_ID); modules.remove(restModule); } switch (action.getAction()) { case START: startModules(modules, servletContext); break; case STOP: stopModules(modules, servletContext, true); break; case RESTART: restartModules(modules, servletContext); break; case UNLOAD: unloadModules(modules, servletContext); break; case INSTALL: Module module = installModule(modules, installUri, servletContext); modules.clear(); modules.add(module); action.setModules(new ArrayList<Module>(modules)); break; } } return ConversionUtil.convertToRepresentation(action, Representation.DEFAULT); }