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/09 11:38:08 UTC
svn commit: r792472 - 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: Thu Jul 9 09:38:07 2009
New Revision: 792472
URL: http://svn.apache.org/viewvc?rev=792472&view=rev
Log:
ACE-29 patch applied
Added:
incubator/ace/trunk/webui/src/org/apache/ace/client/CheckoutPanel.java (with props)
incubator/ace/trunk/webui/src/org/apache/ace/client/services/CheckoutService.java (with props)
incubator/ace/trunk/webui/src/org/apache/ace/client/services/CheckoutServiceAsync.java (with props)
incubator/ace/trunk/webui/src/org/apache/ace/server/CheckoutServiceImpl.java (with props)
Modified:
incubator/ace/trunk/webui/src/org/apache/ace/client/Main.java
incubator/ace/trunk/webui/src/org/apache/ace/client/services/TargetService.java
incubator/ace/trunk/webui/src/org/apache/ace/server/Activator.java
incubator/ace/trunk/webui/src/org/apache/ace/server/TargetServiceImpl.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/CheckoutPanel.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/CheckoutPanel.java?rev=792472&view=auto
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/CheckoutPanel.java (added)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/CheckoutPanel.java Thu Jul 9 09:38:07 2009
@@ -0,0 +1,63 @@
+package org.apache.ace.client;
+
+import org.apache.ace.client.services.CheckoutService;
+import org.apache.ace.client.services.CheckoutServiceAsync;
+
+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.HorizontalPanel;
+
+public class CheckoutPanel extends HorizontalPanel {
+ private CheckoutServiceAsync m_checkoutService = GWT.create(CheckoutService.class);
+
+ public CheckoutPanel(final Main main) {
+ Button retrieve = new Button("Retrieve");
+ retrieve.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ m_checkoutService.checkout(new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ Window.alert("Error retrieving latest version from server.");
+ }
+ public void onSuccess(Void result) {
+ main.updateUI();
+ }
+ });
+ }
+ });
+
+ Button store = new Button("Store");
+ store.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ m_checkoutService.commit(new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ Window.alert("Error storing version on the server.");
+ }
+ public void onSuccess(Void result) {
+ main.updateUI();
+ }
+ });
+ }
+ });
+ Button revert = new Button("Revert");
+ revert.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ m_checkoutService.revert(new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ Window.alert("Error reverting to latest version from server.");
+ }
+ public void onSuccess(Void result) {
+ main.updateUI();
+ }
+ });
+ }
+ });
+
+ add(retrieve);
+ add(store);
+ add(revert);
+ }
+}
Propchange: incubator/ace/trunk/webui/src/org/apache/ace/client/CheckoutPanel.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
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=792472&r1=792471&r2=792472&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 Thu Jul 9 09:38:07 2009
@@ -23,6 +23,7 @@
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
@@ -65,12 +66,15 @@
// Put our status label in the lower left corner
RootPanel.get("serverStatusLabel").add(m_statusLabel);
+
+ // Add our checkout panel
+ RootPanel.get("buttonPanel").add(new CheckoutPanel(this));
}
/**
* Triggers an update of UI.
*/
- private void updateUI() {
+ void updateUI() {
m_targetTable.updateTable();
}
Added: incubator/ace/trunk/webui/src/org/apache/ace/client/services/CheckoutService.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/services/CheckoutService.java?rev=792472&view=auto
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/services/CheckoutService.java (added)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/services/CheckoutService.java Thu Jul 9 09:38:07 2009
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+/**
+ * Allows repository actions on the RepositoryAdmin's repositories.
+ */
+@RemoteServiceRelativePath("checkout")
+public interface CheckoutService extends RemoteService {
+ public void checkout() throws Exception;
+ public void commit() throws Exception;
+ public void revert() throws Exception;
+}
Propchange: incubator/ace/trunk/webui/src/org/apache/ace/client/services/CheckoutService.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/ace/trunk/webui/src/org/apache/ace/client/services/CheckoutServiceAsync.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/services/CheckoutServiceAsync.java?rev=792472&view=auto
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/services/CheckoutServiceAsync.java (added)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/services/CheckoutServiceAsync.java Thu Jul 9 09:38:07 2009
@@ -0,0 +1,29 @@
+/*
+ * 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 CheckoutService (GWT boiler plate)
+ */
+public interface CheckoutServiceAsync {
+ void checkout(AsyncCallback<Void> callback);
+ void commit(AsyncCallback<Void> callback);
+ void revert(AsyncCallback<Void> callback);
+}
Propchange: incubator/ace/trunk/webui/src/org/apache/ace/client/services/CheckoutServiceAsync.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/ace/trunk/webui/src/org/apache/ace/client/services/TargetService.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/client/services/TargetService.java?rev=792472&r1=792471&r2=792472&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/client/services/TargetService.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/client/services/TargetService.java Thu Jul 9 09:38:07 2009
@@ -29,5 +29,5 @@
/**
* Gets target descriptors for all available targets, including those that are not registered.
*/
- TargetDescriptor[] getTargets();
+ TargetDescriptor[] getTargets() throws Exception;
}
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=792472&r1=792471&r2=792472&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 Thu Jul 9 09:38:07 2009
@@ -18,16 +18,69 @@
*/
package org.apache.ace.server;
+import java.io.File;
+
+import javax.servlet.http.HttpServletRequest;
+
import org.apache.felix.dependencymanager.DependencyActivatorBase;
import org.apache.felix.dependencymanager.DependencyManager;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
public class Activator extends DependencyActivatorBase {
private static volatile BundleContext m_context;
+
+ private static final boolean DEBUG = true;
static BundleContext getContext() {
return m_context;
}
+
+ /**
+ * Gets a base directory for this bundle's data; you can use this directory
+ * to pass to {@link SessionFramework#getFramework(javax.servlet.http.HttpSession, File)}.
+ */
+ static File getBaseDir() {
+ return m_context.getDataFile("webui");
+ }
+
+ /**
+ * 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)
+ */
+ static <T> T getService(HttpServletRequest request, Class<T> clazz) throws Exception {
+ BundleContext bundleContext;
+ if (DEBUG) {
+ bundleContext = m_context;
+ }
+ else {
+ bundleContext = SessionFramework.getFramework(request.getSession(), Activator.getBaseDir()).getBundleContext();
+ }
+
+ ServiceReference reference = bundleContext.getServiceReference(clazz.getName());
+ if (reference != null) {
+ @SuppressWarnings("unchecked")
+ T result = (T) bundleContext.getService(reference);
+ return result;
+ }
+
+ // we were not able to find the reference immediately, try again for a few seconds...
+ ServiceTracker tracker = new ServiceTracker(bundleContext, "(" + Constants.OBJECTCLASS + "=" + clazz.getName() + ")", null);
+ tracker.open();
+ @SuppressWarnings("unchecked")
+ T result = (T) tracker.waitForService(5000);
+ if (result == null) {
+ ServiceReference logRef = bundleContext.getServiceReference(LogService.class.getName());
+ if (logRef != null) {
+ ((LogService) bundleContext.getService(logRef)).log(LogService.LOG_ERROR, "Error finding service " + clazz.getName());
+ }
+ }
+ return result;
+ }
@Override
public void init(BundleContext context, DependencyManager manager)
Added: incubator/ace/trunk/webui/src/org/apache/ace/server/CheckoutServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/server/CheckoutServiceImpl.java?rev=792472&view=auto
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/server/CheckoutServiceImpl.java (added)
+++ incubator/ace/trunk/webui/src/org/apache/ace/server/CheckoutServiceImpl.java Thu Jul 9 09:38:07 2009
@@ -0,0 +1,72 @@
+/*
+ * 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.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.ace.client.repository.RepositoryAdmin;
+import org.apache.ace.client.repository.RepositoryAdminLoginContext;
+import org.apache.ace.client.services.CheckoutService;
+import org.osgi.service.useradmin.User;
+import org.osgi.service.useradmin.UserAdmin;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+public class CheckoutServiceImpl extends RemoteServiceServlet implements CheckoutService {
+ /**
+ * Generated serialVersionUID
+ */
+ private static final long serialVersionUID = 302748031613265624L;
+
+
+ private final Set<RepositoryAdmin> m_loggedIn = new HashSet<RepositoryAdmin>();
+
+ /**
+ * Gets a repository admin for this session. If this admin is not yet logged in,
+ * this will be done automatically.
+ */
+ private RepositoryAdmin getRepositoryAdmin() throws Exception {
+ RepositoryAdmin admin = Activator.getService(getThreadLocalRequest(), RepositoryAdmin.class);
+ if (!m_loggedIn.contains(admin)) {
+ UserAdmin userAdmin = Activator.getService(getThreadLocalRequest(), UserAdmin.class);
+ RepositoryAdminLoginContext context = admin.createLoginContext((User) userAdmin.getRole("d"));
+ context.addShopRepository(new URL("http://localhost:8080/repository"), "apache", "shop", true);
+ context.addGatewayRepository(new URL("http://localhost:8080/repository"), "apache", "gateway", true);
+ context.addDeploymentRepository(new URL("http://localhost:8080/repository"), "apache", "deployment", true);
+ admin.login(context);
+ m_loggedIn.add(admin);
+ }
+ return admin;
+ }
+
+ public void checkout() throws Exception {
+ getRepositoryAdmin().checkout();
+ }
+
+ public void commit() throws Exception {
+ getRepositoryAdmin().commit();
+ }
+
+ public void revert() throws Exception {
+ getRepositoryAdmin().revert();
+ }
+
+}
Propchange: incubator/ace/trunk/webui/src/org/apache/ace/server/CheckoutServiceImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/ace/trunk/webui/src/org/apache/ace/server/TargetServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/webui/src/org/apache/ace/server/TargetServiceImpl.java?rev=792472&r1=792471&r2=792472&view=diff
==============================================================================
--- incubator/ace/trunk/webui/src/org/apache/ace/server/TargetServiceImpl.java (original)
+++ incubator/ace/trunk/webui/src/org/apache/ace/server/TargetServiceImpl.java Thu Jul 9 09:38:07 2009
@@ -25,7 +25,6 @@
import org.apache.ace.client.repository.stateful.StatefulGatewayRepository;
import org.apache.ace.client.services.TargetDescriptor;
import org.apache.ace.client.services.TargetService;
-import org.osgi.framework.ServiceReference;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@@ -38,7 +37,7 @@
/**
* Helper method to translate between server- and client lingo
*/
- public static TargetDescriptor.ProvisioningState from(org.apache.ace.client.repository.stateful.StatefulGatewayObject.ProvisioningState state) {
+ private static TargetDescriptor.ProvisioningState from(org.apache.ace.client.repository.stateful.StatefulGatewayObject.ProvisioningState state) {
if (state != null) {
switch (state) {
case Failed: return TargetDescriptor.ProvisioningState.FAILED;
@@ -50,18 +49,8 @@
return null;
}
- public TargetDescriptor[] getTargets() {
- if (Activator.getContext() == null) {
- // We could be running without our bundle being started.
- return null;
- }
-
- ServiceReference reference = Activator.getContext().getServiceReference(StatefulGatewayRepository.class.getName());
- if (reference == null) {
- return null;
- }
-
- StatefulGatewayRepository sgr = (StatefulGatewayRepository) Activator.getContext().getService(reference);
+ public TargetDescriptor[] getTargets() throws Exception {
+ StatefulGatewayRepository sgr = Activator.getService(getThreadLocalRequest(), StatefulGatewayRepository.class);
sgr.refresh();
List<TargetDescriptor> result = new ArrayList<TargetDescriptor>();
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=792472&r1=792471&r2=792472&view=diff
==============================================================================
--- incubator/ace/trunk/webui/war/WEB-INF/web.xml (original)
+++ incubator/ace/trunk/webui/war/WEB-INF/web.xml Thu Jul 9 09:38:07 2009
@@ -21,4 +21,15 @@
<url-pattern>/webui/targets</url-pattern>
</servlet-mapping>
+ <servlet>
+ <servlet-name>checkoutServlet</servlet-name>
+ <servlet-class>org.apache.ace.server.CheckoutServiceImpl</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>checkoutServlet</servlet-name>
+ <url-pattern>/webui/checkout</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=792472&r1=792471&r2=792472&view=diff
==============================================================================
--- incubator/ace/trunk/webui/war/webui.html (original)
+++ incubator/ace/trunk/webui/war/webui.html Thu Jul 9 09:38:07 2009
@@ -41,6 +41,7 @@
<h1>Apache Ace</h1>
<table align="center">
+ <tr span="4" id="buttonPanel" />
<tr><td><h3>Bundles</h3></td><td><h3>Groups</h3></td><td><h3>Licenses</h3></td><td><h3>Targets</h3></td></tr>
<tr>
<td>Bundles column goes here</td>