You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ace.apache.org by ma...@apache.org on 2009/07/10 14:22:14 UTC
svn commit: r792913 - in /incubator/ace/trunk/webui:
src/org/apache/ace/client/ src/org/apache/ace/client/services/
src/org/apache/ace/server/ war/ war/WEB-INF/
Author: marrs
Date: Fri Jul 10 12:22:13 2009
New Revision: 792913
URL: http://svn.apache.org/viewvc?rev=792913&view=rev
Log:
ACE-27 applied the second patch
Added:
incubator/ace/trunk/webui/src/org/apache/ace/client/AddBundleDialog.java (with props)
incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRBundleDescriptor.java (with props)
incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRService.java (with props)
incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRServiceAsync.java (with props)
incubator/ace/trunk/webui/src/org/apache/ace/server/OBRServiceImpl.java (with props)
Modified:
incubator/ace/trunk/webui/src/org/apache/ace/client/BundleTable.java
incubator/ace/trunk/webui/src/org/apache/ace/client/GroupTable.java
incubator/ace/trunk/webui/src/org/apache/ace/client/LicenseTable.java
incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java
incubator/ace/trunk/webui/src/org/apache/ace/client/ObjectTable.java
incubator/ace/trunk/webui/src/org/apache/ace/client/TargetTable.java
incubator/ace/trunk/webui/src/org/apache/ace/server/Activator.java
incubator/ace/trunk/webui/war/WEB-INF/web.xml
incubator/ace/trunk/webui/war/webui.html
Added: incubator/ace/trunk/webui/src/org/apache/ace/client/AddBundleDialog.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/AddBundleDialog.java?rev=792913&view=auto
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/AddBundleDialog.java (added)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/AddBundleDialog.java Fri Jul 10 12:22:13 2009
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.client;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ace.client.services.OBRBundleDescriptor;
+import org.apache.ace.client.services.OBRService;
+import org.apache.ace.client.services.OBRServiceAsync;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.DialogBox;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.StackPanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+/**
+ * This dialog allows the user to select a bundle from an OBR. Upcoming improvements:
+ * <ul>
+ * <li>Allow the user to select an OBR</li>
+ * <li>Allow file upload to a given OBR</li>
+ * </ul>
+ */
+public class AddBundleDialog extends DialogBox {
+
+ OBRServiceAsync m_obrService = GWT.create(OBRService.class);
+
+ AddBundleDialog() {
+ setText("Add bundle");
+
+ final ObjectListBox<OBRBundleDescriptor> obrFiles = new ObjectListBox<OBRBundleDescriptor>();
+ obrFiles.setVisibleItemCount(8);
+
+ m_obrService.getBundles(new AsyncCallback<OBRBundleDescriptor[]>() {
+ public void onFailure(Throwable caught) {
+ Window.alert("Error communicating with OBR");
+ hide();
+ }
+
+ public void onSuccess(OBRBundleDescriptor[] result) {
+ for (OBRBundleDescriptor d : result) {
+ obrFiles.addObject(d);
+ }
+ }
+ });
+
+ // Put together the stackpanel
+ final StackPanel stackPanel = new StackPanel();
+ stackPanel.add(obrFiles, "In the OBR");
+
+ // Create the button panel
+ HorizontalPanel buttonPanel = new HorizontalPanel();
+ Button saveButton = new Button("Save");
+ saveButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ m_obrService.importBundle(obrFiles.getSelectedObject(), new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ Window.alert("Error importing bundle " + obrFiles.getSelectedObject());
+ }
+ public void onSuccess(Void result) {
+ // Hurrah!
+ }
+
+ });
+ hide();
+ }
+ });
+ Button cancelButton = new Button("Cancel");
+ cancelButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ // Nothing to do.
+ hide();
+ }
+ });
+
+
+ // Put the dialog together
+ VerticalPanel content = new VerticalPanel();
+ content.add(new Label("Where is your bundle?"));
+ content.add(stackPanel);
+
+ buttonPanel.add(cancelButton);
+ buttonPanel.add(saveButton);
+ content.add(buttonPanel);
+
+ add(content);
+
+ setSize("350px", "200px");
+ center();
+ setAnimationEnabled(true);
+ }
+
+ /**
+ * Helper class that allows mapping from the string representation in a listbox
+ * to the actual objects.
+ */
+ private static class ObjectListBox<T> extends ListBox {
+ private final List<T> m_objects = new ArrayList<T>();
+
+ public void addObject(T t) {
+ m_objects.add(t);
+ addItem(t.toString());
+ }
+
+ public T getSelectedObject() {
+ if (getSelectedIndex() != -1) {
+ return m_objects.get(getSelectedIndex());
+ }
+ return null;
+ }
+
+ @Override
+ public void clear() {
+ super.clear();
+ m_objects.clear();
+ }
+ }
+
+}
Propchange: incubator/ace/trunk/webui/src/org/apache/ace/client/AddBundleDialog.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/BundleTable.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/BundleTable.java?rev=792913&r1=792912&r2=792913&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/BundleTable.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/BundleTable.java Fri Jul 10 12:22:13 2009
@@ -48,4 +48,9 @@
}
return null;
}
+
+ @Override
+ protected String getTableID() {
+ return "bundles";
+ }
}
Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/GroupTable.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/GroupTable.java?rev=792913&r1=792912&r2=792913&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/GroupTable.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/GroupTable.java Fri Jul 10 12:22:13 2009
@@ -66,5 +66,10 @@
}
}
+ @Override
+ protected String getTableID() {
+ return "groups";
+ }
+
}
Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/LicenseTable.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/LicenseTable.java?rev=792913&r1=792912&r2=792913&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/LicenseTable.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/LicenseTable.java Fri Jul 10 12:22:13 2009
@@ -65,4 +65,9 @@
});
}
}
+
+ @Override
+ protected String getTableID() {
+ return "licenses";
+ }
}
Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java?rev=792913&r1=792912&r2=792913&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java Fri Jul 10 12:22:13 2009
@@ -22,10 +22,10 @@
import java.util.Map;
import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.impl.StringBuilderImpl;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Timer;
-import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
@@ -47,8 +47,8 @@
* communication with the server.
*/
interface StatusHandler {
- void handleFail(Class<?> table);
- void handleSuccess(Class<?> table);
+ void handleFail(String table);
+ void handleSuccess(String table);
}
/**
@@ -61,8 +61,7 @@
RootPanel.get("bundlesHeader").add(addBundleButton);
addBundleButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
- // TODO show a file dialog, trigger an upload, and instruct the server to extract metadata.
- Window.alert("Just wait for the next release...");
+ new AddBundleDialog().show();
}
});
@@ -133,18 +132,18 @@
* a successful connection when all components are happy.
*/
private static class StatusLabel extends Label implements StatusHandler {
- private final Map<Class<?>, Boolean> m_statuses = new HashMap<Class<?>, Boolean>();
+ private final Map<String, Boolean> m_statuses = new HashMap<String, Boolean>();
public StatusLabel() {
setText("checking server status...");
}
- public void handleFail(Class<?> table) {
+ public void handleFail(String table) {
m_statuses.put(table, false);
updateStatus();
}
- public void handleSuccess(Class<?> table) {
+ public void handleSuccess(String table) {
m_statuses.put(table, true);
updateStatus();
}
@@ -161,7 +160,14 @@
setStyleName("serverStatusGood");
}
else {
- setText("Error communicating with server.");
+ StringBuilderImpl sb = new StringBuilderImpl();
+ sb.append("Error communicating with server.");
+ for (Map.Entry<String, Boolean> entry : m_statuses.entrySet()) {
+ if (!entry.getValue()) {
+ sb.append(" (" + entry.getKey() + ")");
+ }
+ }
+ setText(sb.toString());
setStyleName("serverStatusBad");
}
}
Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/ObjectTable.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/ObjectTable.java?rev=792913&r1=792912&r2=792913&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/ObjectTable.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/ObjectTable.java Fri Jul 10 12:22:13 2009
@@ -30,13 +30,33 @@
public abstract class ObjectTable<T> extends FlexTable {
private final String[] m_columnNames;
private final StatusHandler m_handler;
+ private AsyncCallback<T[]> m_asyncCallback = new AsyncCallback<T[]>() {
+ public void onFailure(Throwable caught) {
+ m_handler.handleFail(getTableID());
+ }
+ public void onSuccess(T[] result) {
+ m_handler.handleSuccess(getTableID());
+ int row = 1;
+ for (T t : result) {
+ for (int i = 0; i < m_columnNames.length; i++) {
+ setText(row, i, getValue(t, i));
+ }
+ row++;
+ }
+ while (row <= getRowCount()) {
+ // Looks like we removed something...
+ removeRow(row);
+ }
+ }
+ };
public ObjectTable(StatusHandler handler, String... columnNames) {
m_handler = handler;
m_columnNames = columnNames;
- for (int i = 0; i < m_columnNames.length; i++) {
- setText(0, i, m_columnNames[i]);
- }
+ // We do not want column names for now
+// for (int i = 0; i < m_columnNames.length; i++) {
+// setText(0, i, m_columnNames[i]);
+// }
}
/**
@@ -45,30 +65,18 @@
protected abstract String getValue(T object, int column);
/**
+ * Gets a unique ID for this table.
+ * @return
+ */
+ protected abstract String getTableID();
+
+ /**
* Invokes the necessary service call to get the latest
* set of value objects from the server, passing the given callback.
*/
protected abstract void callService(AsyncCallback<T[]> callback);
void updateTable() {
- callService(new AsyncCallback<T[]>() {
- public void onFailure(Throwable caught) {
- m_handler.handleFail(getClass());
- }
- public void onSuccess(T[] result) {
- m_handler.handleSuccess(getClass());
- int row = 1;
- for (T t : result) {
- for (int i = 0; i < m_columnNames.length; i++) {
- setText(row, i, getValue(t, i));
- }
- row++;
- }
- while (row < getRowCount()) {
- // Looks like we removed something...
- removeRow(row);
- }
- }
- });
+ callService(m_asyncCallback);
}
}
Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/TargetTable.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/TargetTable.java?rev=792913&r1=792912&r2=792913&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/TargetTable.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/TargetTable.java Fri Jul 10 12:22:13 2009
@@ -50,4 +50,9 @@
return null;
}
+ @Override
+ protected String getTableID() {
+ return "targets";
+ }
+
}
Added: incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRBundleDescriptor.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRBundleDescriptor.java?rev=792913&view=auto
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRBundleDescriptor.java (added)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRBundleDescriptor.java Fri Jul 10 12:22:13 2009
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.client.services;
+
+import java.io.Serializable;
+
+/**
+ * Describes a bundle that currently resides in an OBR
+ */
+public class OBRBundleDescriptor implements Serializable {
+ /**
+ * Generated serialVersionUID
+ */
+ private static final long serialVersionUID = 4498575423321448776L;
+
+ private String m_name;
+ private String m_url; // We have to use this as a URL, unfortunately. We could try translating it to Google's form
+
+ public OBRBundleDescriptor() {}
+
+ public OBRBundleDescriptor(String name, String url) {
+ m_name = name;
+ m_url = url;
+ }
+
+ public String getName() {
+ return m_name;
+ }
+
+ public String getUrl() {
+ return m_url;
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+}
Propchange: incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRBundleDescriptor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRService.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRService.java?rev=792913&view=auto
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRService.java (added)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRService.java Fri Jul 10 12:22:13 2009
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.client.services;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+
+/**
+ * Service that allow interaction with the OBR.
+ */
+@RemoteServiceRelativePath("obrService")
+public interface OBRService extends RemoteService {
+ /**
+ * Gets Bundle descriptors for all available Bundles.
+ */
+ OBRBundleDescriptor[] getBundles() throws Exception;
+
+ /**
+ * Gets Bundle descriptors for all available Bundles.
+ */
+ OBRBundleDescriptor[] getBundles(String repositoryBase) throws Exception;
+
+ /**
+ * Imports the given bundle from the OBR into the repository
+ */
+ void importBundle(OBRBundleDescriptor bundle) throws Exception;
+}
Propchange: incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRService.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRServiceAsync.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRServiceAsync.java?rev=792913&view=auto
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRServiceAsync.java (added)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRServiceAsync.java Fri Jul 10 12:22:13 2009
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.client.services;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+/**
+ * Asynchronous OBRService (GWT boiler plate)
+ */
+public interface OBRServiceAsync {
+ void getBundles(AsyncCallback<OBRBundleDescriptor[]> callback);
+ void getBundles(String obrBase, AsyncCallback<OBRBundleDescriptor[]> callback);
+ void importBundle(OBRBundleDescriptor bundle, AsyncCallback<Void> callback);
+}
Propchange: incubator/ace/trunk/webui/src/org/apache/ace/client/services/OBRServiceAsync.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/ace/trunk/webui/src/org/apache/ace/server/Activator.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/server/Activator.java?rev=792913&r1=792912&r2=792913&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/server/Activator.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/server/Activator.java Fri Jul 10 12:22:13 2009
@@ -20,21 +20,35 @@
import java.io.File;
+import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
import org.apache.felix.dependencymanager.DependencyActivatorBase;
import org.apache.felix.dependencymanager.DependencyManager;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.util.tracker.ServiceTracker;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.GWT.UncaughtExceptionHandler;
+
public class Activator extends DependencyActivatorBase {
private static volatile BundleContext m_context;
-
- private static final boolean DEBUG = false;
+ private static volatile Activator m_instance;
+ private static final boolean DEBUG = true;
+ private volatile PackageAdmin m_packageAdmin;
+
+ static Activator instance() {
+ return m_instance;
+ }
+
static BundleContext getContext() {
return m_context;
}
@@ -48,6 +62,33 @@
}
/**
+ * Returns a list of exports that consists of everything this bundle imports. We use
+ * PackageAdmin to figure this out at runtime.
+ */
+ static String getExports() {
+ StringBuffer imports = new StringBuffer();
+ for (Bundle b : m_context.getBundles()) {
+ ExportedPackage[] eps = instance().m_packageAdmin.getExportedPackages(b);
+ if (eps != null) {
+ for (ExportedPackage ep : eps) {
+ Bundle[] ibs = ep.getImportingBundles();
+ if (ibs != null) {
+ for (Bundle ib : ibs) {
+ if (ib.getBundleId() == m_context.getBundle().getBundleId()) {
+ if (imports.length() > 0) {
+ imports.append(',');
+ }
+ imports.append(ep.getName() + ";version=" + ep.getVersion());
+ }
+ }
+ }
+ }
+ }
+ }
+ return imports.toString();
+ }
+
+ /**
* Gets an instance of the given service, coming from the session-dependent
* framework. For debug purposes, it can return the service from the 'outer' framework.
* (set the {@link #DEBUG} flag to <code>true</code> to use this feature)
@@ -58,7 +99,15 @@
bundleContext = m_context;
}
else {
- bundleContext = SessionFramework.getFramework(request.getSession(), Activator.getBaseDir()).getBundleContext();
+ HttpSession session = request.getSession();
+ Cookie[] cookies = request.getCookies();
+ StringBuffer cc = new StringBuffer();
+ for (Cookie c : cookies) {
+ if (cc.length() > 0) { cc.append("; "); }
+ cc.append(c.getName() + " = " + c.getValue());
+ }
+ System.out.println("Getting service for request " + request.getRequestURI() + " cookie " + cc + " with session " + session);
+ bundleContext = SessionFramework.getFramework(session, Activator.getBaseDir()).getBundleContext();
}
ServiceReference reference = bundleContext.getServiceReference(clazz.getName());
@@ -86,6 +135,27 @@
public void init(BundleContext context, DependencyManager manager)
throws Exception {
m_context = context;
+ m_instance = this;
+
+ GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
+ public void onUncaughtException(Throwable e) {
+ ServiceReference logRef = m_context
+ .getServiceReference(LogService.class.getName());
+ if (logRef != null) {
+ ((LogService) m_context.getService(logRef)).log(
+ LogService.LOG_ERROR, "Uncaught exception in GWT", e);
+ }
+ else {
+ System.err.println("Uncaught exception in GWT");
+ e.printStackTrace(System.err);
+ }
+ }
+ });
+
+ manager.add(createService()
+ .setImplementation(this)
+ .add(createServiceDependency().setRequired(true).setService(PackageAdmin.class))
+ );
}
@Override
public void destroy(BundleContext context, DependencyManager manager)
Added: incubator/ace/trunk/webui/src/org/apache/ace/server/OBRServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/server/OBRServiceImpl.java?rev=792913&view=auto
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/server/OBRServiceImpl.java (added)
+++ incubator/ace/trunk/webui/src/org/apache/ace/server/OBRServiceImpl.java Fri Jul 10 12:22:13 2009
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ace.server;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.ace.client.repository.object.ArtifactObject;
+import org.apache.ace.client.repository.repository.ArtifactRepository;
+import org.apache.ace.client.services.OBRBundleDescriptor;
+import org.apache.ace.client.services.OBRService;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+public class OBRServiceImpl extends RemoteServiceServlet implements OBRService {
+ /**
+ * Generated serialVersionUID
+ */
+ private static final long serialVersionUID = 268104499426401403L;
+
+ private static final String URL_BASE = "http://localhost:8080/obr/";
+
+ public OBRBundleDescriptor[] getBundles() throws Exception {
+ return getBundles(URL_BASE);
+ }
+
+ public OBRBundleDescriptor[] getBundles(String obrBaseUrl) throws Exception {
+ ArtifactRepository ar = Activator.getService(getThreadLocalRequest(), ArtifactRepository.class);
+
+ URL obrBase = new URL(obrBaseUrl);
+
+ // retrieve the repository.xml as a stream
+ URL url = null;
+ try {
+ url = new URL(obrBase, "repository.xml");
+ }
+ catch (MalformedURLException e) {
+ System.err.println("Error retrieving repository.xml from " + obrBase);
+ throw e;
+ }
+
+ InputStream input = null;
+ NodeList resources = null;
+ try {
+ URLConnection connection = url.openConnection();
+ connection.setUseCaches(false); //We always want the newest repository.xml file.
+ input = connection.getInputStream();
+
+ try {
+ XPath xpath = XPathFactory.newInstance().newXPath();
+ // this XPath expressing will find all 'resource' elements which have an attribute 'uri'.
+ resources = (NodeList) xpath.evaluate("/repository/resource[@uri]", new InputSource(input), XPathConstants.NODESET);
+ }
+ catch (XPathExpressionException e) {
+ System.err.println("Error evaluating XPath expression.");
+ e.printStackTrace(System.err);
+ throw e;
+ }
+ }
+ catch (IOException e) {
+ e.printStackTrace(System.err);
+ throw e;
+ }
+ finally {
+ if (input != null) {
+ try {
+ input.close();
+ }
+ catch (IOException e) {
+ // too bad, no worries.
+ }
+ }
+ }
+
+ // Create a list of filenames from the OBR
+ List<String> fromOBR = new ArrayList<String>();
+ for (int nResource = 0; nResource < resources.getLength(); nResource++) {
+ Node resource = resources.item(nResource);
+ fromOBR.add(resource.getAttributes().getNamedItem("uri").getTextContent());
+ }
+
+ // Create a list of filenames from the ArtifactRepository
+ List<String> fromRepository = new ArrayList<String>();
+ List<ArtifactObject> artifactObjects = ar.get();
+ artifactObjects.addAll(ar.getResourceProcessors());
+ for (ArtifactObject ao : artifactObjects) {
+ String artifactURL = ao.getURL();
+ if (artifactURL.startsWith(obrBase.toExternalForm())) {
+ // we now know this artifact comes from the OBR we are querying, so we are interested.
+ fromRepository.add(new File(artifactURL).getName());
+ }
+ }
+
+ // remove all urls we already know
+ fromOBR.removeAll(fromRepository);
+ if (fromOBR.isEmpty()) {
+ System.err.println("No data in obr...");
+ return null;
+ }
+
+ // Create a list of all bundle names
+ List<OBRBundleDescriptor> result = new ArrayList<OBRBundleDescriptor>();
+ for (String s : fromOBR) {
+ result.add(new OBRBundleDescriptor(s, new URL(obrBase, s).toExternalForm()));
+ }
+
+ return result.toArray(new OBRBundleDescriptor[result.size()]);
+ }
+
+ public void importBundle(OBRBundleDescriptor bundle) throws Exception {
+ ArtifactRepository ar = Activator.getService(getThreadLocalRequest(), ArtifactRepository.class);
+
+ ar.importArtifact(new URL(bundle.getUrl()), false);
+ }
+}
Propchange: incubator/ace/trunk/webui/src/org/apache/ace/server/OBRServiceImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/ace/trunk/webui/war/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/war/WEB-INF/web.xml?rev=792913&r1=792912&r2=792913&view=diff
==============================================================================
--- incubator/ace/trunk/webui/war/WEB-INF/web.xml (original)
+++ incubator/ace/trunk/webui/war/WEB-INF/web.xml Fri Jul 10 12:22:13 2009
@@ -61,5 +61,14 @@
<url-pattern>/webui/checkout</url-pattern>
</servlet-mapping>
+ <servlet>
+ <servlet-name>obrServlet</servlet-name>
+ <servlet-class>org.apache.ace.server.OBRServiceImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>obrServlet</servlet-name>
+ <url-pattern>/webui/obrService</url-pattern>
+ </servlet-mapping>
</web-app>
Modified: incubator/ace/trunk/webui/war/webui.html
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/war/webui.html?rev=792913&r1=792912&r2=792913&view=diff
==============================================================================
--- incubator/ace/trunk/webui/war/webui.html (original)
+++ incubator/ace/trunk/webui/war/webui.html Fri Jul 10 12:22:13 2009
@@ -18,7 +18,7 @@
<!-- -->
<!-- Any title is fine -->
<!-- -->
- <title>Apache Ace</title>
+ <title>Apache ACE</title>
<!-- -->
<!-- This script loads your compiled module. -->
@@ -38,15 +38,16 @@
<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
- <h1>Apache Ace</h1>
+ <h1>Apache ACE</h1>
<table align="center">
- <tr span="4" id="buttonPanel" />
+ <tr><td colspan="4" id="buttonPanel"></td></tr>
<tr>
- <td><h3 id="bundlesHeader">Bundles</h3></td>
- <td><h3 id="groupsHeader">Groups</h3></td>
- <td><h3 id="licensesHeader">Licenses</h3></td>
- </td><td><h3>Targets</h3></td></tr>
+ <th><h3 id="bundlesHeader">Bundles</h3></th>
+ <th><h3 id="groupsHeader">Groups</h3></th>
+ <th><h3 id="licensesHeader">Licenses</h3></th>
+ <th><h3>Targets</h3></th>
+ </tr>
<tr>
<td id="bundleColumnContainer"></td>
<td id="groupColumnContainer"></td>