use of io.fabric8.maven.util.Parser in project fabric8 by jboss-fuse.
the class ProfileDownloader method downloadProfile.
/**
* Downloads the bundles, features and FABs for this profile.
*/
public void downloadProfile(Profile profile) throws Exception {
if (listener != null) {
listener.beforeDownloadProfile(profile);
}
ProfileService profileService = fabricService.adapt(ProfileService.class);
if (!profile.isOverlay()) {
profile = profileService.getOverlayProfile(profile);
}
DownloadManager downloadManager = DownloadManagers.createDownloadManager(fabricService, executorService);
Set<String> bundles = new LinkedHashSet<String>();
Set<Feature> features = new LinkedHashSet<Feature>();
addMavenBundles(fabricService, profile, bundles, profile.getBundles());
addMavenBundles(fabricService, profile, bundles, profile.getFabs());
AgentUtils.addFeatures(features, fabricService, downloadManager, profile);
Map<String, File> files = AgentUtils.downloadBundles(downloadManager, features, bundles, Collections.<String>emptySet(), !isDownloadFilesFromProfile());
Set<Map.Entry<String, File>> entries = files.entrySet();
for (Map.Entry<String, File> entry : entries) {
String name = entry.getKey();
File file = entry.getValue();
if (processedFiles.add(file)) {
String fileName = file.getName();
String mvnCoords = getMavenCoords(name);
File destFile;
if (mvnCoords != null) {
Parser parser = new Parser(mvnCoords);
destFile = new File(target, parser.getArtifactPath());
} else {
destFile = new File(target, fileName);
}
if (force || !destFile.exists()) {
LOG.info("Copying file: " + file + " to: " + destFile.getCanonicalPath());
Files.copy(file, destFile);
if (listener != null) {
listener.onCopyDone(profile, destFile);
}
}
}
}
if (listener != null) {
listener.afterDownloadProfile(profile);
}
}
use of io.fabric8.maven.util.Parser in project fabric8 by jboss-fuse.
the class AgentUtils method getProfileArtifacts.
/**
* Returns the location and parser map (i.e. the location and the parsed maven coordinates and artifact locations) of each bundle and feature
*/
public static Map<String, Parser> getProfileArtifacts(FabricService fabricService, Profile profile, Iterable<String> bundles, Iterable<Feature> features, Callback<String> nonMavenLocationCallback) {
Set<String> locations = new HashSet<>();
for (Feature feature : features) {
List<BundleInfo> bundleList = feature.getBundles();
if (bundleList == null) {
LOGGER.warn("No bundles for feature " + feature);
} else {
for (BundleInfo bundle : bundleList) {
locations.add(bundle.getLocation());
}
}
}
for (String bundle : bundles) {
locations.add(bundle);
}
Map<String, Parser> artifacts = new HashMap<>();
for (String location : locations) {
try {
if (location.contains("$")) {
ProfileService profileService = fabricService.adapt(ProfileService.class);
Profile overlay = profileService.getOverlayProfile(profile);
location = VersionPropertyPointerResolver.replaceVersions(fabricService, overlay.getConfigurations(), location);
}
if (location.startsWith("mvn:") || location.contains(":mvn:")) {
Parser parser = Parser.parsePathWithSchemePrefix(location);
artifacts.put(location, parser);
} else {
if (nonMavenLocationCallback != null) {
nonMavenLocationCallback.call(location);
}
}
} catch (MalformedURLException e) {
LOGGER.error("Failed to parse bundle URL: " + location + ". " + e, e);
}
}
return artifacts;
}
use of io.fabric8.maven.util.Parser in project fabric8 by jboss-fuse.
the class JavaContainers method getJavaContainerArtifactsFiles.
public static Map<String, File> getJavaContainerArtifactsFiles(FabricService fabricService, List<Profile> profileList, DownloadManager downloadManager) throws Exception {
Map<String, File> answer = new HashMap<String, File>();
ProfileService profileService = fabricService.adapt(ProfileService.class);
for (Profile profile : profileList) {
Profile overlay = profileService.getOverlayProfile(profile);
Map<String, Parser> profileArtifacts = AgentUtils.getProfileArtifacts(fabricService, downloadManager, overlay);
appendMavenDependencies(profileArtifacts, profile);
Set<String> rawUrls = profileArtifacts.keySet();
downloadArtifactUrls(downloadManager, rawUrls, answer);
}
return answer;
}
use of io.fabric8.maven.util.Parser in project fabric8 by jboss-fuse.
the class StompProtocolDecoder method read_headers.
private Action<StompFrame> read_headers(final StompFrame frame) {
final Ascii[] contentLengthValue = new Ascii[1];
final ArrayList<StompFrame.HeaderEntry> headers = new ArrayList<StompFrame.HeaderEntry>(10);
return new Action<StompFrame>() {
public StompFrame apply() throws IOException {
Buffer line = readUntil((byte) '\n', protocol.maxHeaderLength, "The maximum header length was exceeded");
while (line != null) {
line = chomp(line);
if (line.length() > 0) {
if (protocol.maxHeaders != -1 && headers.size() > protocol.maxHeaders) {
throw new IOException("The maximum number of headers was exceeded");
}
try {
int seperatorIndex = indexOf(line, COLON_BYTE);
if (seperatorIndex < 0) {
throw new IOException("Header line missing separator [" + Ascii.ascii(line) + "]");
}
Buffer name = line.getBuffer(0, seperatorIndex);
if (trim) {
name = trim(name);
}
Buffer value = line.getBuffer(seperatorIndex + 1, line.length());
if (trim) {
value = trim(value);
}
StompFrame.HeaderEntry entry = new StompFrame.HeaderEntry(Ascii.ascii(name), Ascii.ascii(value));
if (entry.key.equals(CONTENT_LENGTH)) {
contentLengthValue[0] = entry.value;
}
headers.add(entry);
} catch (Exception e) {
throw new IOException("Unable to parser header line [" + line + "]");
}
} else {
frame.setHeaders(headers);
Ascii contentLength = contentLengthValue[0];
if (contentLength != null) {
// Bless the client, he's telling us how much data to read in.
int length = 0;
try {
length = Integer.parseInt(contentLength.toString());
} catch (NumberFormatException e) {
throw new IOException("Specified content-length is not a valid integer");
}
if (protocol.maxDataLength != -1 && length > protocol.maxDataLength) {
throw new IOException("The maximum data length was exceeded");
}
nextDecodeAction = read_binary_body(frame, length);
} else {
nextDecodeAction = read_text_body(frame);
}
return nextDecodeAction.apply();
}
line = readUntil((byte) '\n', protocol.maxHeaderLength, "The maximum header length was exceeded");
}
return null;
}
};
}
use of io.fabric8.maven.util.Parser in project watchdog by isdream.
the class KubernetesListenerTest method main.
public static void main(String[] args) throws Exception {
// Configure config = new Parser().parse("config/podWatcher.yaml");
Configure config = new Parser().parse("config/namespaceWatcher.yaml");
DefaultKubernetesClient client = new DefaultKubernetesClient("https://master.example:8443");
Listener listener = new KubernetesListener();
listener.start(client, config);
}
Aggregations