Author: paperwing
Date: 2012-06-29 11:18:45 -0700 (Fri, 29 Jun 2012)
New Revision: 29728
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/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 Apps already in framework/deploy directory now shows up in app
manager when Cytoscape starts. Moving an app to the deploy directory will now
update the manager. Removing an app from the directory causes the app manager
to update correspondingly. The Karaf FeaturesService service is no longer used;
the app manager simply monitors the deploy directory.
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-29 15:56:18 UTC (rev 29727)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
2012-06-29 18:18:45 UTC (rev 29728)
@@ -146,6 +146,7 @@
// Install previously enabled apps
installAppsInDirectory(new File(getInstalledAppsPath()));
+ installAppsInDirectory(new File(getKarafDeployDirectory()));
// Load apps from the "uninstalled apps" directory
Set<App> uninstalledApps = obtainAppsFromDirectory(new
File(getUninstalledAppsPath()));
@@ -226,7 +227,7 @@
}
});
- //setupKarafDeployMonitor(fileAlterationMonitor);
+ setupKarafDeployMonitor(fileAlterationMonitor);
try {
//installAlterationObserver.initialize();
@@ -263,8 +264,11 @@
@Override
public void onFileCreate(File file) {
+
+ //System.out.println("File found: " + file);
+
if (checkIfCytoscapeApp(file)) {
-
+ //System.out.println("File was app: " +
file);
App parsedApp = null;
try {
parsedApp =
appParser.parseApp(file);
@@ -275,7 +279,11 @@
+ "app
manager! Installing anyway..");
}
+ //System.out.println("App was
parsed: " + file);
+
installApp(parsedApp);
+ //System.out.println("App was
installed: " + file);
+
} catch (AppParsingException e) {
logger.error("Failed to parse
app that was moved to Karaf deploy directory: " + file.getName()
+ ". The error
was: " + e.getMessage());
@@ -294,7 +302,7 @@
e.printStackTrace();
}
- // fileAlterationMonitor.addObserver(karafDeployObserver);
+ fileAlterationMonitor.addObserver(karafDeployObserver);
}
public CySwingAppAdapter getSwingAppAdapter() {
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-29 15:56:18 UTC (rev 29727)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppParser.java
2012-06-29 18:18:45 UTC (rev 29728)
@@ -24,6 +24,8 @@
import org.cytoscape.app.internal.exception.AppParsingException;
import org.cytoscape.app.internal.util.DebugHelper;
import org.json.XML;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
@@ -80,6 +82,8 @@
*/
private static final String APP_COMPATIBLE_TAG_REGEX =
"(\\d+(\\.\\d+)?\\s*)(,\\s*\\d+(\\.\\d+)?\\s*)*";
+ private static final Logger logger = LoggerFactory.getLogger(App.class);
+
/**
* Attempt to parse a given {@link File} object as an {@link App}
object.
* @param file The file to use for parsing
@@ -269,15 +273,26 @@
// 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";
+
+ if (bundleApp) {
+ readableName = "Name-not-found: karaf/" +
file.getName();
+ } else {
+ 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";
+
+ if (bundleApp) {
+ appVersion = "Not found";
+ } else {
+ 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");
@@ -288,8 +303,13 @@
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 = "";
+ if (bundleApp) {
+ logger.warn("Bundle app " +
file.getName() + " manifest does not contain an entry for " + APP_COMPATIBLE_TAG
+ + ". Assuming default
value 3.0..");
+ compatibleVersions = "3.0";
+ } else {
+ throw new AppParsingException("Jar is
missing value for entry " + APP_COMPATIBLE_TAG + " in its manifest file.");
+ }
} 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-29 15:56:18 UTC (rev 29727)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
2012-06-29 18:18:45 UTC (rev 29728)
@@ -8,6 +8,7 @@
import java.util.List;
import java.util.Map;
+import org.apache.commons.io.FileExistsException;
import org.apache.commons.io.FileUtils;
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeaturesService;
@@ -20,8 +21,8 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-public class BundleApp extends App {
-
+public class BundleApp extends App {
+
/**
* Karaf feature information used to install/uninstall a bundle app,
* which consists of Karaf features.
@@ -60,10 +61,17 @@
@Override
public void install(AppManager appManager) throws AppInstallException {
- // Use the default installation procedure consisting of copying
over
- // the file, creating an instance, and registering with the app
manager.
- // defaultInstall(appManager);
+ // Check if we already have an app object representing this app
registered to the app manager
+ for (App app : appManager.getApps()) {
+ if (this.heuristicEquals(app) && this != app) {
+
+ app.setAppFile(this.getAppFile());
+ app.install(appManager);
+
+ return;
+ }
+ }
File appFile = this.getAppFile();
@@ -159,14 +167,23 @@
// to the uninstalled apps directory
// defaultUninstall(appManager);
- FeaturesService featuresService =
appManager.getFeaturesService();
- List<Feature> installedFeatures =
getCorrespondingFeatures(featuresService);
+ if (this.getStatus() == AppStatus.UNINSTALLED) {
+ return;
+ }
- this.getAppTemporaryInstallFile().delete();
-
try {
- FileUtils.moveFileToDirectory(getAppFile(), new
File(appManager.getUninstalledAppsPath()), false);
- this.setAppFile(new
File(appManager.getUninstalledAppsPath() + File.separator +
this.getAppFile().getName()));
+ File uninstallDirectoryTargetFile = new
File(appManager.getUninstalledAppsPath() + File.separator +
getAppFile().getName());
+
+ if (uninstallDirectoryTargetFile.exists()) {
+ uninstallDirectoryTargetFile.delete();
+ }
+
+ try {
+ FileUtils.moveFile(getAppFile(),
uninstallDirectoryTargetFile);
+ } catch (FileExistsException e) {
+ }
+
+ this.setAppFile(uninstallDirectoryTargetFile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -174,36 +191,9 @@
throw new AppUninstallException("Unable to move app
file to uninstalled apps directory: " + e.getMessage());
}
- this.setStatus(AppStatus.UNINSTALLED);
+ this.getAppTemporaryInstallFile().delete();
- /*
- for (Feature installedFeature : installedFeatures) {
- featuresService.uninstallFeature(arg0)
- }
- */
-
- /*
- try {
- Feature[] availableFeatures =
featuresService.listFeatures();
- List<BundleApp.KarafFeature> appFeatures =
this.getFeaturesList();
-
- Feature availableFeature;
- for (int i = 0; i < availableFeatures.length; i++) {
- availableFeature = availableFeatures[i];
-
- for (BundleApp.KarafFeature appFeature :
appFeatures) {
- if
(appFeature.featureName.equalsIgnoreCase(availableFeature.getName())
- &&
appFeature.featureVersion.equalsIgnoreCase(availableFeature.getVersion())) {
-
- }
- }
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
-
- }
- */
+ this.setStatus(AppStatus.UNINSTALLED);
}
/**
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-29 15:56:18 UTC (rev 29727)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
2012-06-29 18:18:45 UTC (rev 29728)
@@ -272,12 +272,12 @@
.addComponent(searchAppsLabel)
.addComponent(filterTextField,
javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(descriptionSplitPane)
+ .addComponent(descriptionSplitPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 444, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(installFromFileButton)
- .addComponent(viewOnAppStoreButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 29,
javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(installButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 29,
javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(viewOnAppStoreButton)
+ .addComponent(installButton))
.addContainerGap())
);
--
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.