Search in sources :

Example 46 with FabricService

use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.

the class ProfileMetadata method findMetadataForProfile.

protected void findMetadataForProfile(String versionId, String profileId, MetadataHandler handler) throws Exception {
    FabricService service = fabricService.get();
    Objects.notNull(service, "FabricService");
    ProfileService profileService = service.adapt(ProfileService.class);
    Objects.notNull(profileService, "ProfileService");
    DownloadManager downloadManager = DownloadManagers.createDownloadManager(service, executorService);
    Objects.notNull(downloadManager, "DownloadManager");
    Profile immediateProfile = profileService.getProfile(versionId, profileId);
    Objects.notNull(immediateProfile, "Profile for versionId: " + versionId + ", profileId: " + profileId);
    Profile profile = profileService.getOverlayProfile(immediateProfile);
    Set<String> pids = new HashSet<>();
    Map<String, File> fileMap = AgentUtils.downloadProfileArtifacts(service, downloadManager, profile);
    Set<Map.Entry<String, File>> entries = fileMap.entrySet();
    for (Map.Entry<String, File> entry : entries) {
        String uri = entry.getKey();
        File file = entry.getValue();
        if (!file.exists() || !file.isFile()) {
            LOG.warn("File " + file + " is not an existing file for " + uri + ". Ignoring");
            continue;
        }
        addMetaTypeInformation(handler, uri, file);
        pids.add(uri);
    }
    // lets check if the MetaType folder exists
    if (metaTypeFolder != null && metaTypeFolder.exists() && metaTypeFolder.isDirectory()) {
        Set<String> configurationFileNames = profile.getConfigurationFileNames();
        for (String configName : configurationFileNames) {
            if (configName.endsWith(PROPERTIES_SUFFIX) && configName.indexOf('/') < 0) {
                String pid = configName.substring(0, configName.length() - PROPERTIES_SUFFIX.length());
                addMetaTypeInformation(pids, handler, pid);
                String factoryPid = getFactoryPid(pid);
                addMetaTypeInformation(pids, handler, factoryPid);
            }
        }
    }
}
Also used : DownloadManager(io.fabric8.agent.download.DownloadManager) Profile(io.fabric8.api.Profile) JarEntry(java.util.jar.JarEntry) ProfileService(io.fabric8.api.ProfileService) FabricService(io.fabric8.api.FabricService) JarFile(java.util.jar.JarFile) File(java.io.File) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 47 with FabricService

use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.

the class ContainerResource method stop.

/**
 * Stops the container
 */
@DELETE
@Path("start")
public void stop() {
    FabricService fabricService = getFabricService();
    Objects.notNull(fabricService, "fabricService");
    fabricService.stopContainer(container);
}
Also used : FabricService(io.fabric8.api.FabricService) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 48 with FabricService

use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.

the class ContainerResource method delete.

/**
 * Deletes this container
 */
@DELETE
public void delete() {
    FabricService fabricService = getFabricService();
    Objects.notNull(fabricService, "fabricService");
    fabricService.destroyContainer(container);
}
Also used : FabricService(io.fabric8.api.FabricService) DELETE(javax.ws.rs.DELETE)

Example 49 with FabricService

use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.

the class FabricResource method version.

/**
 * Accesses a version resource
 */
@Path("version/{versionId}")
public VersionResource version(@PathParam("versionId") String versionId) {
    FabricService fabricService = getFabricService();
    if (fabricService != null && Strings.isNotBlank(versionId)) {
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        Version version = profileService.getRequiredVersion(versionId);
        if (version != null) {
            return new VersionResource(this, version);
        } else {
            LOG.warn("No version found for: {}", version);
        }
    }
    return null;
}
Also used : ProfileService(io.fabric8.api.ProfileService) Version(io.fabric8.api.Version) FabricService(io.fabric8.api.FabricService) Path(javax.ws.rs.Path)

Example 50 with FabricService

use of io.fabric8.api.FabricService in project fabric8 by jboss-fuse.

the class FabricResource method versions.

/**
 * Returns the list of version ids
 */
@GET
@Path("versions")
public Map<String, String> versions() {
    FabricService fabricService = getFabricService();
    if (fabricService != null) {
        ProfileService profileService = fabricService.adapt(ProfileService.class);
        List<String> versionIds = profileService.getVersions();
        return mapToLinks(versionIds, "/version/");
    } else {
        noFabricService();
    }
    return Collections.emptyMap();
}
Also used : ProfileService(io.fabric8.api.ProfileService) FabricService(io.fabric8.api.FabricService) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

FabricService (io.fabric8.api.FabricService)80 Container (io.fabric8.api.Container)76 Test (org.junit.Test)52 Profile (io.fabric8.api.Profile)50 BundleContext (org.osgi.framework.BundleContext)29 Version (io.fabric8.api.Version)24 ArrayList (java.util.ArrayList)21 ProfileService (io.fabric8.api.ProfileService)19 HashMap (java.util.HashMap)16 CuratorFramework (org.apache.curator.framework.CuratorFramework)16 HashSet (java.util.HashSet)14 Map (java.util.Map)13 FabricException (io.fabric8.api.FabricException)12 IOException (java.io.IOException)12 ContainerProxy (io.fabric8.itests.paxexam.support.ContainerProxy)11 Ignore (org.junit.Ignore)10 File (java.io.File)9 LinkedList (java.util.LinkedList)9 Path (javax.ws.rs.Path)8 FabricRequirements (io.fabric8.api.FabricRequirements)7