use of io.fabric8.api.ProfileRegistry in project fabric8 by jboss-fuse.
the class AbstractChildContainerCreateAction method getDataStoreProperties.
protected Map<String, String> getDataStoreProperties() {
ProfileRegistry profileRegistry = fabricService.adapt(ProfileRegistry.class);
Map<String, String> options = new HashMap<String, String>(profileRegistry.getDataStoreProperties());
if (dataStoreOption != null) {
for (String opt : dataStoreOption) {
String[] parts = opt.trim().split(" +");
options.put(parts[0], parts[1]);
}
}
return options;
}
use of io.fabric8.api.ProfileRegistry in project fabric8 by jboss-fuse.
the class ProjectDeployerImpl method writeRequirementsJson.
private ProjectRequirements writeRequirementsJson(ProjectRequirements requirements, Profile profile, ProfileBuilder builder) throws IOException {
ObjectMapper mapper = DtoHelper.getMapper();
byte[] json = mapper.writeValueAsBytes(requirements);
String fileName = DtoHelper.getRequirementsConfigFileName(requirements);
// lets read the previous requirements if there are any
ProfileRegistry profileRegistry = fabricService.get().adapt(ProfileRegistry.class);
byte[] oldData = profile.getFileConfiguration(fileName);
LOG.info("Writing file " + fileName + " to profile " + profile);
builder.addFileConfiguration(fileName, json);
if (oldData == null || oldData.length == 0) {
return null;
} else {
return mapper.reader(ProjectRequirements.class).readValue(oldData);
}
}
use of io.fabric8.api.ProfileRegistry in project fabric8 by jboss-fuse.
the class ProvisionSupport method profileAvailable.
public static Boolean profileAvailable(String profile, String version, Long timeout) throws Exception {
FabricService fabricService = ServiceLocator.awaitService(FabricService.class);
ProfileRegistry profileRegistry = fabricService.adapt(ProfileRegistry.class);
for (long t = 0; (!profileRegistry.hasProfile(version, profile) && t < timeout); t += 2000L) {
Thread.sleep(2000L);
}
return profileRegistry.hasProfile(version, profile);
}
use of io.fabric8.api.ProfileRegistry in project fabric8 by jboss-fuse.
the class GitDataStoreImplProfilesIT method init.
@Before
public void init() throws NoSuchFieldException, IllegalAccessException, IOException, GitAPIException {
File repo = new File("target/fabric-git");
FileUtils.deleteDirectory(repo);
repo.mkdirs();
git = Git.init().setDirectory(repo).setGitDir(new File(repo, ".git")).call();
git.commit().setMessage("init").call();
git.tag().setName(GitHelpers.ROOT_TAG).call();
dataStore = mock(DataStore.class);
when(dataStore.getDefaultVersion()).thenReturn("1.0");
gitService = mock(GitService.class);
when(gitService.getGit()).thenReturn(git);
runtimeProperties = mock(RuntimeProperties.class);
when(runtimeProperties.getRuntimeIdentity()).thenReturn("root");
curator = mock(CuratorFramework.class);
pullPushPolicy = mock(PullPushPolicy.class);
PullPushPolicy.PushPolicyResult ppResult = mock(PullPushPolicy.PushPolicyResult.class);
when(ppResult.getPushResults()).thenReturn(new ArrayList<PushResult>());
when(pullPushPolicy.doPush(any(GitContext.class), any(CredentialsProvider.class))).thenReturn(ppResult);
mockStatic(ZooKeeperUtils.class);
PowerMockito.when(ZooKeeperUtils.generateContainerToken(runtimeProperties, curator)).thenReturn("token");
gdsi = new GitDataStoreImpl();
this.<ValidationSupport>getField(gdsi, "active", ValidationSupport.class).setValid();
this.<ValidatingReference<DataStore>>getField(gdsi, "dataStore", ValidatingReference.class).bind(dataStore);
this.<ValidatingReference<GitService>>getField(gdsi, "gitService", ValidatingReference.class).bind(gitService);
this.<ValidatingReference<RuntimeProperties>>getField(gdsi, "runtimeProperties", ValidatingReference.class).bind(runtimeProperties);
this.<ValidatingReference<CuratorFramework>>getField(gdsi, "curator", ValidatingReference.class).bind(curator);
setField(gdsi, "dataStoreProperties", Map.class, new HashMap<String, Object>());
setField(gdsi, "pullPushPolicy", PullPushPolicy.class, pullPushPolicy);
profileRegistry = gdsi;
}
use of io.fabric8.api.ProfileRegistry in project fabric8 by jboss-fuse.
the class ProfileDynamicJaxbCompiler method listFiles.
private Collection<String> listFiles(final String versionId, final Iterable<String> profileIds, final String path) {
assertValid();
Git git = gitService.getGit();
ProfileRegistry profileRegistry = getFabricService().adapt(ProfileRegistry.class);
SortedSet<String> answer = new TreeSet<String>();
for (String profileId : profileIds) {
profileRegistry.getRequiredProfile(versionId, profileId);
File profileDirectory = GitHelpers.getProfileDirectory(git, profileId);
File file = Strings.isNotBlank(path) ? new File(profileDirectory, path) : profileDirectory;
if (file.exists()) {
String[] values = file.list();
if (values != null) {
for (String value : values) {
answer.add(value);
}
}
}
}
return Collections.unmodifiableSet(answer);
}
Aggregations