Author: paperwing
Date: 2012-06-26 16:05:08 -0700 (Tue, 26 Jun 2012)
New Revision: 29697
Modified:
core3/impl/trunk/app-impl/pom.xml
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/App.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/net/server/LocalHttpServer.java
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
Log:
refs #1158 Bundle apps now moved to the framework/deploy directory upon
installing, and removed upon uninstalling. A copy of the app file is stored in
the local storage directory for installed apps, similarly to how simple apps
are treated.
Modified: core3/impl/trunk/app-impl/pom.xml
===================================================================
--- core3/impl/trunk/app-impl/pom.xml 2012-06-26 22:27:42 UTC (rev 29696)
+++ core3/impl/trunk/app-impl/pom.xml 2012-06-26 23:05:08 UTC (rev 29697)
@@ -108,6 +108,13 @@
<version>2.2.7</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>karaf</artifactId>
+ <version>2.2.7</version>
+ <type>pom</type>
+ </dependency>
+
<!-- dependency for file copying and moving, as well as
directory watching -->
<dependency>
<groupId>commons-io</groupId>
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-26 22:27:42 UTC (rev 29696)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/CyActivator.java
2012-06-26 23:05:08 UTC (rev 29697)
@@ -123,8 +123,6 @@
import java.util.Properties;
import java.util.concurrent.Executors;
-
-
public class CyActivator extends AbstractCyActivator {
public CyActivator() {
super();
@@ -350,7 +348,7 @@
registerService(bc, webQuerier, WebQuerier.class, new
Properties());
FeaturesService featuresService = getService(bc,
FeaturesService.class);
-
+
// Instantiate new manager
final AppManager appManager = new AppManager(
cyAppAdapter,
cyApplicationConfigurationServiceRef, webQuerier);
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
2012-06-26 22:27:42 UTC (rev 29696)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/App.java
2012-06-26 23:05:08 UTC (rev 29697)
@@ -26,7 +26,7 @@
*/
public abstract class App {
- private static final Logger logger =
LoggerFactory.getLogger(AppManager.class);
+ private static final Logger logger = LoggerFactory.getLogger(App.class);
private String appName;
private String version;
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-26 22:27:42 UTC (rev 29696)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppManager.java
2012-06-26 23:05:08 UTC (rev 29697)
@@ -81,6 +81,9 @@
*/
private FeaturesService featuresService;
+
+ // private KarService karService;
+
/**
* {@link CyApplicationConfiguration} service used to obtain the
directories used to store the apps.
*/
@@ -510,6 +513,20 @@
}
}
+
+ public String getKarafDeployDirectory() {
+ String current =
System.getProperties().get("user.dir").toString();
+
+ String deployDirectoryPath = current + File.separator +
"framework"
+ + File.separator + "deploy";
+
+ return deployDirectoryPath;
+ }
+
+ public void cleanKarafDeployDirectory() {
+ // Remove apps
+ }
+
/**
* Removes the temporary app download directory and the directory used
to store uninstalled apps.
*/
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-26 22:27:42 UTC (rev 29696)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/AppParser.java
2012-06-26 23:05:08 UTC (rev 29697)
@@ -248,12 +248,14 @@
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";
}
// 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";
} 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");
@@ -265,6 +267,7 @@
if (compatibleVersions == null ||
compatibleVersions.trim().length() == 0) {
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-26 22:27:42 UTC (rev 29696)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/manager/BundleApp.java
2012-06-26 23:05:08 UTC (rev 29697)
@@ -1,8 +1,14 @@
package org.cytoscape.app.internal.manager;
+import java.io.File;
+import java.io.IOException;
import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import org.apache.commons.io.FileUtils;
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeaturesService;
import org.cytoscape.app.CyAppAdapter;
@@ -25,8 +31,14 @@
public String featureVersion;
}
- private List<KarafFeature> featuresList = null;
+ private Map<String, KarafFeature> featuresSet;
+ public BundleApp() {
+ super();
+
+ this.featuresSet = new HashMap<String, KarafFeature>();
+ }
+
@Override
public Object createAppInstance(CySwingAppAdapter appAdapter)
throws AppInstanceException {
@@ -53,10 +65,76 @@
// defaultInstall(appManager);
// Copy to Karaf deploy directory
+ String karafDeployDirectory =
appManager.getKarafDeployDirectory();
+ File appFile = this.getAppFile();
+ try {
+ if (appFile != null
+ &&
!appFile.getParentFile().getCanonicalPath().equals(appManager.getInstalledAppsPath()))
{
+
+ FileUtils.copyFileToDirectory(appFile, new
File(appManager.getInstalledAppsPath()));
+
+ if
(appFile.getParentFile().getCanonicalPath().equalsIgnoreCase(
+
appManager.getUninstalledAppsPath())) {
+ appFile.delete();
+ }
+
+ this.setAppFile(new
File(appManager.getInstalledAppsPath() + File.separator + appFile.getName()));
+ }
+ } catch (IOException e) {
+ throw new AppInstallException("Failed to copy bundle
app to local storage directory for installed apps");
+ }
+ try {
+ FileUtils.copyFileToDirectory(this.getAppFile(), new
File(karafDeployDirectory));
+ this.setAppTemporaryInstallFile(new
File(karafDeployDirectory + File.separator + this.getAppFile().getName()));
+ } catch (IOException e) {
+ throw new AppInstallException("Failed to copy bundle
app to Karaf deploy directory");
+ }
+
+ // Check if the features were installed
+ FeaturesService featuresService =
appManager.getFeaturesService();
+ List<Feature> installedFeatures =
getCorrespondingFeatures(featuresService);
+
+ if (installedFeatures.size() == featuresSet.size()) {
+
+ } else {
+ throw new AppInstallException("Not all Karaf features
were successfully installed from the bundle app.");
+ }
+
+ if (!appManager.getApps().contains(this)) {
+ appManager.getApps().add(this);
+ }
+
+ this.setStatus(AppStatus.INSTALLED);
}
+ private List<Feature> getCorrespondingFeatures(FeaturesService
featuresService) {
+ List<Feature> correspondingFeatures = new LinkedList<Feature>();
+
+ Feature[] availableFeatures = new Feature[]{};
+ try {
+ availableFeatures = featuresService.listFeatures();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ for (int i = 0; i < availableFeatures.length; i++) {
+ Feature availableFeature = availableFeatures[i];
+
+ BundleApp.KarafFeature appFeature =
featuresSet.get(availableFeature.getName());
+
+ if (appFeature != null
+ &&
appFeature.featureVersion.equalsIgnoreCase(availableFeature.getVersion())) {
+ correspondingFeatures.add(availableFeature);
+
+ // System.out.println("feature match: " +
availableFeature.getName() + " vs " + appFeature.featureName);
+ }
+ }
+
+ return correspondingFeatures;
+ }
+
@Override
public void uninstall(AppManager appManager) throws
AppUninstallException {
@@ -65,8 +143,30 @@
// defaultUninstall(appManager);
FeaturesService featuresService =
appManager.getFeaturesService();
+ List<Feature> installedFeatures =
getCorrespondingFeatures(featuresService);
+ this.getAppTemporaryInstallFile().delete();
+
try {
+ FileUtils.moveFileToDirectory(getAppFile(), new
File(appManager.getUninstalledAppsPath()), false);
+ this.setAppFile(new
File(appManager.getUninstalledAppsPath() + File.separator +
this.getAppFile().getName()));
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+
+ throw new AppUninstallException("Unable to move app
file to uninstalled apps directory: " + e.getMessage());
+ }
+
+ this.setStatus(AppStatus.UNINSTALLED);
+
+ /*
+ for (Feature installedFeature : installedFeatures) {
+ featuresService.uninstallFeature(arg0)
+ }
+ */
+
+ /*
+ try {
Feature[] availableFeatures =
featuresService.listFeatures();
List<BundleApp.KarafFeature> appFeatures =
this.getFeaturesList();
@@ -86,20 +186,18 @@
e.printStackTrace();
}
+ */
}
/**
* Return the list of karaf features.
* @return The list of karaf features
*/
- public List<KarafFeature> getFeaturesList() {
- return featuresList;
+ public Map<String, KarafFeature> getFeaturesList() {
+ return featuresSet;
}
- public void setFeaturesList(List<KarafFeature> featuresList) {
- this.featuresList = featuresList;
+ public void setFeaturesList(Map<String, KarafFeature> featuresSet) {
+ this.featuresSet = featuresSet;
}
-
-
-
}
Modified:
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/net/server/LocalHttpServer.java
===================================================================
---
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/net/server/LocalHttpServer.java
2012-06-26 22:27:42 UTC (rev 29696)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/net/server/LocalHttpServer.java
2012-06-26 23:05:08 UTC (rev 29697)
@@ -96,7 +96,7 @@
public Response respond(String url, String body) throws
Exception;
}
- final Logger logger = LoggerFactory.getLogger(LocalHttpServer.class);
+ private static final Logger logger =
LoggerFactory.getLogger(LocalHttpServer.class);
final List<GetResponder> getResponders = new ArrayList<GetResponder>();
final List<PostResponder> postResponders = new ArrayList<PostResponder>();
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-26 22:27:42 UTC (rev 29696)
+++
core3/impl/trunk/app-impl/src/main/java/org/cytoscape/app/internal/ui/InstallFromStorePanel.java
2012-06-26 23:05:08 UTC (rev 29697)
@@ -216,11 +216,11 @@
descriptionPanel.setLayout(descriptionPanelLayout);
descriptionPanelLayout.setHorizontalGroup(
descriptionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(descriptionScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE)
+ .addComponent(descriptionScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
);
descriptionPanelLayout.setVerticalGroup(
descriptionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(descriptionScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 435, Short.MAX_VALUE)
+ .addComponent(descriptionScrollPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE)
);
descriptionSplitPane.setRightComponent(descriptionPanel);
@@ -252,17 +252,17 @@
.addComponent(descriptionSplitPane,
javax.swing.GroupLayout.DEFAULT_SIZE, 635, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
+ .addComponent(searchAppsLabel)
+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(filterTextField)
+ .addGap(247, 247, 247))
+ .addGroup(layout.createSequentialGroup()
.addComponent(installFromFileButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(installButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(viewOnAppStoreButton)
- .addContainerGap())
- .addGroup(layout.createSequentialGroup()
- .addComponent(searchAppsLabel)
-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(filterTextField)
- .addGap(247, 247, 247))))
+ .addContainerGap())))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -277,7 +277,8 @@
.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(installButton,
javax.swing.GroupLayout.PREFERRED_SIZE, 29,
javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap())
);
// Make the JTextPane render HTML using the default UI font
--
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.