Author: paperwing
Date: 2012-06-27 14:16:50 -0700 (Wed, 27 Jun 2012)
New Revision: 29709
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppParser.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
Log:
refs #1158 Bundle apps should now show up in the App Manager, provided they
have values for the following entries in the manifest: Cytoscape-App-Name,
Cytoscape-App-Version, Cytoscape-API-Compatibility
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
2012-06-27 20:01:00 UTC (rev 29708)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
2012-06-27 21:16:50 UTC (rev 29709)
@@ -348,10 +348,10 @@
registerService(bc, webQuerier, WebQuerier.class, new
Properties());
FeaturesService featuresService = getService(bc,
FeaturesService.class);
-
+
// Instantiate new manager
- final AppManager appManager = new AppManager(
- cyAppAdapter,
cyApplicationConfigurationServiceRef, webQuerier);
+ final AppManager appManager = new AppManager(cyAppAdapter,
+ cyApplicationConfigurationServiceRef,
webQuerier, featuresService);
registerService(bc, appManager, AppManager.class, new
Properties());
appManager.setFeaturesService(featuresService);
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
2012-06-27 20:01:00 UTC (rev 29708)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
2012-06-27 21:16:50 UTC (rev 29709)
@@ -8,6 +8,10 @@
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.Executors;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOCase;
@@ -43,7 +47,7 @@
/** Only files with these extensions are checked when looking for apps
in a given subdirectory.
*/
- private static final String[] APP_EXTENSIONS = {"jar"};
+ private static final String[] APP_EXTENSIONS = {"jar", "kar"};
/** Installed apps are copied to this subdirectory under the local app
storage directory. */
private static final String INSTALLED_APPS_DIRECTORY_NAME = "installed";
@@ -119,15 +123,18 @@
}
}
- public AppManager(CySwingAppAdapter swingAppAdapter,
CyApplicationConfiguration applicationConfiguration, final WebQuerier
webQuerier) {
+ public AppManager(CySwingAppAdapter swingAppAdapter,
CyApplicationConfiguration applicationConfiguration,
+ final WebQuerier webQuerier, FeaturesService
featuresService) {
this.applicationConfiguration = applicationConfiguration;
this.swingAppAdapter = swingAppAdapter;
this.webQuerier = webQuerier;
+ this.featuresService = featuresService;
apps = new HashSet<App>();
appParser = new AppParser();
+ cleanKarafDeployDirectory();
purgeTemporaryDirectories();
initializeAppsDirectories();
@@ -524,7 +531,44 @@
}
public void cleanKarafDeployDirectory() {
- // Remove apps
+ String[] bundleAppExtensions = new String[]{"kar"};
+ File karafDeployDirectory = new File(getKarafDeployDirectory());
+ Collection<File> files =
FileUtils.listFiles(karafDeployDirectory, bundleAppExtensions, false);
+
+ JarFile jarFile = null;
+ Manifest manifest;
+ for (File potentialApp : files) {
+ try {
+ jarFile = new JarFile(potentialApp);
+
+ manifest = jarFile.getManifest();
+
+ // Check the manifest file
+ if (manifest != null) {
+ if
(manifest.getMainAttributes().getValue("Cytoscape-App-Name") != null) {
+
+ jarFile.close();
+ System.gc();
+ potentialApp.delete();
+ }
+ }
+
+ jarFile.close();
+ } catch (ZipException e) {
+ // Do nothing; skip file
+ e.printStackTrace();
+ } catch (IOException e) {
+ // Do nothing; skip file
+ e.printStackTrace();
+ } finally {
+ if (jarFile != null) {
+ try {
+ jarFile.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
}
/**
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppParser.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppParser.java
2012-06-27 20:01:00 UTC (rev 29708)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppParser.java
2012-06-27 21:16:50 UTC (rev 29709)
@@ -59,7 +59,7 @@
* The name of the key in the app jar's manifest file indicating the
major versions of
* Cytoscape that the app is known to be compatible with in
comma-delimited form
*/
- private static final String APP_COMPATIBLE_TAG =
"Cytoscape-App-Compatibility";
+ private static final String APP_COMPATIBLE_TAG =
"Cytoscape-API-Compatibility";
/**
* An alternative name of the key in the app jar's manifest file
indicating the major versions of
@@ -219,6 +219,10 @@
if (featuresList.size() > 0 && !xmlParseFailed) {
bundleApp = true;
parsedApp = new BundleApp();
+
+ for (BundleApp.KarafFeature feature: featuresList) {
+ ((BundleApp)
parsedApp).getFeaturesList().put(feature.featureName, feature);
+ }
}
// Attempt to obtain manifest file from jar
@@ -247,15 +251,15 @@
// Obtain the human-readable name of the app
String readableName =
manifest.getMainAttributes().getValue(APP_READABLE_NAME_TAG);
if (readableName == null || readableName.trim().length() == 0) {
- throw new AppParsingException("Jar is missing value for
entry " + APP_READABLE_NAME_TAG + " in its manifest file.");
- //readableName = "unnamed";
+ //throw new AppParsingException("Jar is missing value
for entry " + APP_READABLE_NAME_TAG + " in its manifest file.");
+ readableName = "unnamed";
}
// Obtain the version of the app, in major.minor.patch[-tag]
format, ie. 3.0.0-SNAPSHOT or 1.2.3
String appVersion =
manifest.getMainAttributes().getValue(APP_VERSION_TAG);
if (appVersion == null || appVersion.trim().length() == 0) {
- throw new AppParsingException("Jar is missing value for
entry " + APP_VERSION_TAG + " in its manifiest file.");
- //appVersion = "unversioned";
+ //throw new AppParsingException("Jar is missing value
for entry " + APP_VERSION_TAG + " in its manifiest file.");
+ appVersion = "unversioned";
} else if (!appVersion.matches(APP_VERSION_TAG_REGEX)) {
throw new AppParsingException("The app version
specified in its manifest file under the key " + APP_VERSION_TAG
+ " was found to not match the format
major.minor[.patch][-tag], eg. 2.1, 2.1-test, 3.0.0 or 3.0.0-SNAPSHOT");
@@ -266,8 +270,8 @@
compatibleVersions =
manifest.getMainAttributes().getValue(APP_COMPATIBLE_ALTERNATIVE_TAG);
if (compatibleVersions == null ||
compatibleVersions.trim().length() == 0) {
- throw new AppParsingException("Jar is missing
value for entry " + APP_COMPATIBLE_TAG + " in its manifest file.");
- //compatibleVersions = "";
+ //throw new AppParsingException("Jar is missing
value for entry " + APP_COMPATIBLE_TAG + " in its manifest file.");
+ compatibleVersions = "";
} else if
(!compatibleVersions.matches(APP_COMPATIBLE_TAG_REGEX)) {
throw new AppParsingException("The known
compatible versions of Cytoscape specified in the manifest under the"
+ " key " +
APP_COMPATIBLE_ALTERNATIVE_TAG + " does not match the form of a comma-delimited
list of"
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
2012-06-27 20:01:00 UTC (rev 29708)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
2012-06-27 21:16:50 UTC (rev 29709)
@@ -96,11 +96,17 @@
FeaturesService featuresService =
appManager.getFeaturesService();
List<Feature> installedFeatures =
getCorrespondingFeatures(featuresService);
+ //System.out.println("features from app: " +
featuresSet.size());
+ //System.out.println("available features: " +
featuresService.listFeatures().length);
+
+ /*
if (installedFeatures.size() == featuresSet.size()) {
} else {
+ this.getAppTemporaryInstallFile().delete();
throw new AppInstallException("Not all Karaf features
were successfully installed from the bundle app.");
}
+ */
if (!appManager.getApps().contains(this)) {
appManager.getApps().add(this);
@@ -124,6 +130,8 @@
BundleApp.KarafFeature appFeature =
featuresSet.get(availableFeature.getName());
+ // System.out.println("available feature: " +
availableFeature.getName() + ", " + availableFeature.getVersion());
+
if (appFeature != null
&&
appFeature.featureVersion.equalsIgnoreCase(availableFeature.getVersion())) {
correspondingFeatures.add(availableFeature);
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
2012-06-27 20:01:00 UTC (rev 29708)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
2012-06-27 21:16:50 UTC (rev 29709)
@@ -319,8 +319,8 @@
private void
installFromFileButtonActionPerformed(java.awt.event.ActionEvent evt) {
// Setup a the file filter for the open file dialog
- FileChooserFilter fileChooserFilter = new FileChooserFilter("Jar, Zip
Files (*.jar, *.zip)",
- new String[]{"jar", "zip"});
+ FileChooserFilter fileChooserFilter = new FileChooserFilter("Jar, Zip,
and Karaf Kar Files (*.jar, *.zip, *.kar)",
+ new String[]{"jar", "zip", "kar"});
Collection<FileChooserFilter> fileChooserFilters = new
LinkedList<FileChooserFilter>();
fileChooserFilters.add(fileChooserFilter);
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.