protected List<String> updateProvisioning(Map<String, File> artifacts, Provisioner provisionService) throws Exception {
        ResourceInstaller resourceInstaller = provisionService.getResourceInstaller();
        Map<ResourceIdentity, Resource> installedResources = getInstalledResources(provisionService);
        Map<Requirement, Resource> requirements = new HashMap<Requirement, Resource>();
        Set<Map.Entry<String, File>> entries = artifacts.entrySet();
        List<Resource> resourcesToInstall = new ArrayList<Resource>();
        List<String> resourceUrisInstalled = new ArrayList<String>();
        updateStatus("installing", null, null);
        for (Map.Entry<String, File> entry : entries) {
            String name = entry.getKey();
            File file = entry.getValue();
            String coords = name;
            int idx = coords.lastIndexOf(':');
            if (idx > 0) {
                coords = name.substring(idx + 1);
            }
            // lets switch to gravia's mvn coordinates
            coords = coords.replace('/', ':');
            MavenCoordinates mvnCoords = parse(coords);
            URL url = file.toURI().toURL();
            if (url == null) {
                LOGGER.warn("Could not find URL for file " + file);
                continue;
            }
            // TODO lets just detect wars for now for servlet engines - how do we decide on WildFly?
            boolean isShared = !isWar(name, file);
            Resource resource = findMavenResource(mvnCoords, url, isShared);
            if (resource == null) {
                LOGGER.warn("Could not find resource for " + mvnCoords + " and " + url);
            } else {
                ResourceIdentity identity = resource.getIdentity();
                Resource oldResource = installedResources.remove(identity);
                if (oldResource == null && !resourcehandleMap.containsKey(identity)) {
                    if (isShared) {
                        // TODO lest not deploy shared stuff for now since bundles throw an exception when trying to stop them
                        // which breaks the tests ;)
                        LOGGER.debug("TODO not installing " + (isShared ? "shared" : "non-shared") + " resource: " + identity);
                    } else {
                        LOGGER.info("Installing " + (isShared ? "shared" : "non-shared") + " resource: " + identity);
                        resourcesToInstall.add(resource);
                        resourceUrisInstalled.add(name);
                    }
                }
            }
        }
        for (Resource installedResource : installedResources.values()) {
            ResourceIdentity identity = installedResource.getIdentity();
            ResourceHandle resourceHandle = resourcehandleMap.get(identity);
            if (resourceHandle == null) {
                // TODO should not really happen when we can ask about the installed Resources
                LOGGER.warn("TODO: Cannot uninstall " + installedResource + " as we have no handle!");
            } else {
                LOGGER.info("Uninstalling " + installedResource);
                resourceHandle.uninstall();
                resourcehandleMap.remove(identity);
                LOGGER.info("Uninstalled " + installedResource);
            }
        }
        if (resourcesToInstall.size() > 0) {
            LOGGER.info("Installing " + resourcesToInstall.size() + " resource(s)");
            Set<ResourceHandle> resourceHandles = new LinkedHashSet<>();
            ResourceInstaller.Context context = new DefaultInstallerContext(resourcesToInstall, requirements);
            for (Resource resource : resourcesToInstall) {
                resourceHandles.add(resourceInstaller.installResource(context, resource));
            }
            LOGGER.info("Got " + resourceHandles.size() + " resource handle(s)");
            for (ResourceHandle resourceHandle : resourceHandles) {
                resourcehandleMap.put(resourceHandle.getResource().getIdentity(), resourceHandle);
            }
        }
        return resourceUrisInstalled;
    }
protected List<String> updateProvisioning(Map<String, File> artifacts, Provisioner provisionService) throws Exception {
        ResourceInstaller resourceInstaller = provisionService.getResourceInstaller();
        Map<ResourceIdentity, Resource> installedResources = getInstalledResources(provisionService);
        Map<Requirement, Resource> requirements = new HashMap<Requirement, Resource>();
        Set<Map.Entry<String, File>> entries = artifacts.entrySet();
        List<Resource> resourcesToInstall = new ArrayList<Resource>();
        List<String> resourceUrisInstalled = new ArrayList<String>();
        updateStatus("installing", null, null);
        for (Map.Entry<String, File> entry : entries) {
            String name = entry.getKey();
            File file = entry.getValue();
            String coords = name;
            int idx = coords.lastIndexOf(':');
            if (idx > 0) {
                coords = name.substring(idx + 1);
            }
           
            coords = coords.replace('/', ':');
            MavenCoordinates mvnCoords = parse(coords);
            URL url = file.toURI().toURL();
            if (url == null) {
                LOGGER.warn("Could not find URL for file " + file);
                continue;
            }
           
            boolean isShared = !isWar(name, file);
            Resource resource = findMavenResource(mvnCoords, url, isShared);
            if (resource == null) {
                LOGGER.warn("Could not find resource for " + mvnCoords + " and " + url);
            } else {
                ResourceIdentity identity = resource.getIdentity();
                Resource oldResource = installedResources.remove(identity);
                if (oldResource == null && !resourcehandleMap.containsKey(identity)) {
                    if (isShared) {
                       
                       
                        LOGGER.debug("TODO not installing " + (isShared ? "shared" : "non-shared") + " resource: " + identity);
                    } else {
                        LOGGER.info("Installing " + (isShared ? "shared" : "non-shared") + " resource: " + identity);
                        resourcesToInstall.add(resource);
                        resourceUrisInstalled.add(name);
                    }
                }
            }
        }
        for (Resource installedResource : installedResources.values()) {
            ResourceIdentity identity = installedResource.getIdentity();
            ResourceHandle resourceHandle = resourcehandleMap.get(identity);
            if (resourceHandle == null) {
               
                LOGGER.warn("TODO: Cannot uninstall " + installedResource + " as we have no handle!");
            } else {
                LOGGER.info("Uninstalling " + installedResource);
                resourceHandle.uninstall();
                resourcehandleMap.remove(identity);
                LOGGER.info("Uninstalled " + installedResource);
            }
        }
        if (resourcesToInstall.size() > 0) {
            LOGGER.info("Installing " + resourcesToInstall.size() + " resource(s)");
            Set<ResourceHandle> resourceHandles = new LinkedHashSet<>();
            ResourceInstaller.Context context = new DefaultInstallerContext(resourcesToInstall, requirements);
            for (Resource resource : resourcesToInstall) {
                resourceHandles.add(resourceInstaller.installResource(context, resource));
            }
            LOGGER.info("Got " + resourceHandles.size() + " resource handle(s)");
            for (ResourceHandle resourceHandle : resourceHandles) {
                resourcehandleMap.put(resourceHandle.getResource().getIdentity(), resourceHandle);
            }
        }
        return resourceUrisInstalled;
    }
protected list<string> updateprovisioning(map<string, file> artifacts, provisioner provisionservice) throws exception { resourceinstaller resourceinstaller = provisionservice.getresourceinstaller(); map<resourceidentity, resource> installedresources = getinstalledresources(provisionservice); map<requirement, resource> requirements = new hashmap<requirement, resource>(); set<map.entry<string, file>> entries = artifacts.entryset(); list<resource> resourcestoinstall = new arraylist<resource>(); list<string> resourceurisinstalled = new arraylist<string>(); updatestatus("installing", null, null); for (map.entry<string, file> entry : entries) { string name = entry.getkey(); file file = entry.getvalue(); string coords = name; int idx = coords.lastindexof(':'); if (idx > 0) { coords = name.substring(idx + 1); } coords = coords.replace('/', ':'); mavencoordinates mvncoords = parse(coords); url url = file.touri().tourl(); if (url == null) { logger.warn("could not find url for file " + file); continue; } boolean isshared = !iswar(name, file); resource resource = findmavenresource(mvncoords, url, isshared); if (resource == null) { logger.warn("could not find resource for " + mvncoords + " and " + url); } else { resourceidentity identity = resource.getidentity(); resource oldresource = installedresources.remove(identity); if (oldresource == null && !resourcehandlemap.containskey(identity)) { if (isshared) { logger.debug("todo not installing " + (isshared ? "shared" : "non-shared") + " resource: " + identity); } else { logger.info("installing " + (isshared ? "shared" : "non-shared") + " resource: " + identity); resourcestoinstall.add(resource); resourceurisinstalled.add(name); } } } } for (resource installedresource : installedresources.values()) { resourceidentity identity = installedresource.getidentity(); resourcehandle resourcehandle = resourcehandlemap.get(identity); if (resourcehandle == null) { logger.warn("todo: cannot uninstall " + installedresource + " as we have no handle!"); } else { logger.info("uninstalling " + installedresource); resourcehandle.uninstall(); resourcehandlemap.remove(identity); logger.info("uninstalled " + installedresource); } } if (resourcestoinstall.size() > 0) { logger.info("installing " + resourcestoinstall.size() + " resource(s)"); set<resourcehandle> resourcehandles = new linkedhashset<>(); resourceinstaller.context context = new defaultinstallercontext(resourcestoinstall, requirements); for (resource resource : resourcestoinstall) { resourcehandles.add(resourceinstaller.installresource(context, resource)); } logger.info("got " + resourcehandles.size() + " resource handle(s)"); for (resourcehandle resourcehandle : resourcehandles) { resourcehandlemap.put(resourcehandle.getresource().getidentity(), resourcehandle); } } return resourceurisinstalled; }