Return-Path: Delivered-To: apmail-incubator-ace-commits-archive@minotaur.apache.org Received: (qmail 89750 invoked from network); 9 Jul 2009 09:38:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Jul 2009 09:38:24 -0000 Received: (qmail 64670 invoked by uid 500); 9 Jul 2009 09:38:34 -0000 Delivered-To: apmail-incubator-ace-commits-archive@incubator.apache.org Received: (qmail 64655 invoked by uid 500); 9 Jul 2009 09:38:34 -0000 Mailing-List: contact ace-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ace-dev@incubator.apache.org Delivered-To: mailing list ace-commits@incubator.apache.org Received: (qmail 64645 invoked by uid 99); 9 Jul 2009 09:38:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jul 2009 09:38:34 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jul 2009 09:38:30 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B99752388892; Thu, 9 Jul 2009 09:38:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/ Date: Thu, 09 Jul 2009 09:38:08 -0000 To: ace-commits@incubator.apache.org From: marrs@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090709093808.B99752388892@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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() { + 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() { + 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() { + 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 callback); + void commit(AsyncCallback callback); + void revert(AsyncCallback 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 true to use this feature) + */ + static T getService(HttpServletRequest request, Class 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 m_loggedIn = new HashSet(); + + /** + * 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 result = new ArrayList(); 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 @@ /webui/targets + + checkoutServlet + org.apache.ace.server.CheckoutServiceImpl + + + + checkoutServlet + /webui/checkout + + + 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 @@

Apache Ace

+

Bundles

Groups

Licenses

Targets

Bundles column goes here