use of org.motechproject.admin.bundles.BundleInformation in project motech by motech.
the class ModuleAdminServiceImpl method installWithDependenciesFromFile.
private BundleInformation installWithDependenciesFromFile(File bundleFile, boolean startBundle) throws IOException {
JarInformation jarInformation = getJarInformations(bundleFile);
List<Bundle> bundlesInstalled = new ArrayList<>();
BundleInformation bundleInformation = null;
if (jarInformation == null) {
throw new IOException("Unable to read bundleFile " + bundleFile.getAbsolutePath());
}
try {
List<ArtifactResult> artifactResults = new LinkedList<>();
bundleWatcherSuspensionService.suspendBundleProcessing();
for (Dependency dependency : jarInformation.getPomInformation().getDependencies()) {
artifactResults.addAll(resolveDependencies(dependency, jarInformation.getPomInformation()));
}
artifactResults = removeDuplicatedArtifacts(artifactResults);
bundlesInstalled = installBundlesFromArtifacts(artifactResults);
final Bundle requestedModule = installBundleFromFile(bundleFile, true, false);
if (requestedModule != null) {
if (!isFragmentBundle(requestedModule) && startBundle) {
requestedModule.start();
}
bundlesInstalled.add(requestedModule);
bundleInformation = null;
} else {
bundleInformation = new BundleInformation(null);
}
} catch (BundleException | RepositoryException e) {
throw new MotechException("Error while installing bundle and dependencies.", e);
} finally {
bundleWatcherSuspensionService.restoreBundleProcessing();
}
// start bundles after all bundles installed to avoid any dependency resolution problems.
startBundles(bundlesInstalled, startBundle);
return bundleInformation;
}
use of org.motechproject.admin.bundles.BundleInformation in project motech by motech.
the class ModuleAdminServiceImpl method installFromRepository.
private BundleInformation installFromRepository(Dependency dependency, boolean start) throws RepositoryException, IOException, BundleException {
LOGGER.info("Installing {} from repository", dependency);
final String featureStrNoVersion = buildFeatureStrNoVersion(dependency);
List<Bundle> bundlesInstalled = new ArrayList<>();
BundleInformation bundleInformation = null;
try {
bundleWatcherSuspensionService.suspendBundleProcessing();
List<ArtifactResult> dependencies = resolveDependencies(dependency, null);
LOGGER.trace("Resolved the following dependencies for {}: {}", dependency, dependencies);
for (ArtifactResult artifact : dependencies) {
if (isOSGiFramework(artifact)) {
// skip the framework jar
continue;
}
LOGGER.info("Installing " + artifact);
final File bundleFile = artifact.getArtifact().getFile();
boolean isRequestedModule = isRequestedModule(artifact, featureStrNoVersion);
final Bundle bundle = installBundleFromFile(bundleFile, isRequestedModule, true);
if (bundle != null) {
bundlesInstalled.add(bundle);
if (isRequestedModule) {
bundleInformation = new BundleInformation(bundle);
}
}
}
} finally {
bundleWatcherSuspensionService.restoreBundleProcessing();
}
// start bundles after all bundles installed to avoid any dependency resolution problems.
startBundles(bundlesInstalled, start);
return bundleInformation;
}
use of org.motechproject.admin.bundles.BundleInformation in project motech by motech.
the class ModuleAdminServiceImpl method getBundles.
@Override
public List<BundleInformation> getBundles() {
List<BundleInformation> bundles = new ArrayList<>();
List<Bundle> motechBundles = motechBundleFilter.filter(bundleContext.getBundles());
for (Bundle bundle : motechBundles) {
BundleInformation bundleInformation = new BundleInformation(bundle);
ModuleRegistrationData moduleRegistrationData = uiFrameworkService.getModuleDataByBundle(bundle);
if (moduleRegistrationData != null) {
bundleInformation.setSettingsURL(moduleRegistrationData.getSettingsURL());
bundleInformation.setModuleName(moduleRegistrationData.getModuleName());
List<String> angularModules = moduleRegistrationData.getAngularModules();
String angularModuleName = isEmpty(angularModules) ? moduleRegistrationData.getModuleName() : angularModules.get(0);
bundleInformation.setAngularModule(angularModuleName);
}
bundles.add(bundleInformation);
}
return bundles;
}
use of org.motechproject.admin.bundles.BundleInformation in project motech by motech.
the class ModuleAdminServiceImpl method stopBundle.
@Override
public BundleInformation stopBundle(long bundleId) throws BundleException {
Bundle bundle = getBundle(bundleId);
bundle.stop();
return new BundleInformation(bundle);
}
use of org.motechproject.admin.bundles.BundleInformation in project motech by motech.
the class BundleAdminServiceTest method testGetBundleInfo.
@Test
public void testGetBundleInfo() {
setupBundleRetrieval();
BundleInformation bundleInfo = moduleAdminService.getBundleInfo(BUNDLE_ID);
assertEquals(new BundleInformation(bundle), bundleInfo);
verify(bundleContext).getBundle(BUNDLE_ID);
}
Aggregations