Author: wesleyhales
Date: 2009-12-19 23:23:19 -0500 (Sat, 19 Dec 2009)
New Revision: 1077
Modified:
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java
portal/branches/wsrp-integration/portlet/exoadmin/src/main/webapp/groovy/wsrp/webui/component/UIWsrpConsumerEditor.gtmpl
Log:
Consumer ui functionality mostly done - needs some LnF touch up work.
Modified:
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java
===================================================================
---
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java 2009-12-19
16:01:59 UTC (rev 1076)
+++
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java 2009-12-20
04:23:19 UTC (rev 1077)
@@ -28,6 +28,7 @@
import org.exoplatform.commons.utils.LazyPageList;
import org.exoplatform.container.ExoContainer;
import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.services.organization.User;
import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -46,72 +47,74 @@
import org.exoplatform.webui.organization.UIAccountInputSet;
import org.gatein.wsrp.WSRPConsumer;
import org.gatein.wsrp.consumer.ConsumerException;
+import org.gatein.wsrp.consumer.EndpointConfigurationInfo;
+import org.gatein.wsrp.consumer.ProducerInfo;
import org.gatein.wsrp.consumer.WSRPConsumerImpl;
import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
/** @author Wesley Hales */
@ComponentConfig(template =
"app:/groovy/wsrp/webui/component/UIWsrpConsumerEditor.gtmpl", lifecycle =
UIFormLifecycle.class, events = {
- @EventConfig(listeners = UIWsrpConsumerEditor.SaveActionListener.class)})
+ @EventConfig(listeners = UIWsrpConsumerEditor.SaveActionListener.class),
+ @EventConfig(listeners = UIWsrpConsumerEditor.EditActionListener.class)})
public class UIWsrpConsumerEditor extends UIForm
{
- protected static final String CONSUMER_NAME = "producerId";
- protected static final String CACHE_EXPIRATION = "Cache Expiration";
- protected static final String USE_WSDL = "Use WSDL";
- protected static final String SERVICE_DESC_URL = "Service Description URL";
- protected static final String MARKUP_URL = "Markup URL";
- protected static final String REG_URL = "Registration URL";
- protected static final String PORTLET_MGMT_URL = "Portlet Management URL";
+ protected static final String CONSUMER_NAME = "id";
+ protected static final String CACHE_EXPIRATION = "expirationCacheSeconds";
+ protected static final String WSDL_URL = "wsdlDefinitionURL";
public UIWsrpConsumerEditor() throws Exception
{
+
addUIFormInput(new UIFormStringInput(CONSUMER_NAME, CONSUMER_NAME,
null).addValidator(MandatoryValidator.class));
addUIFormInput(new UIFormStringInput(CACHE_EXPIRATION, CACHE_EXPIRATION, null));
- addUIFormInput(new UIFormCheckBoxInput(USE_WSDL, USE_WSDL, null));
- addUIFormInput(new UIFormStringInput(SERVICE_DESC_URL, SERVICE_DESC_URL, null));
- addUIFormInput(new UIFormStringInput(MARKUP_URL, MARKUP_URL, null));
- addUIFormInput(new UIFormStringInput(REG_URL, REG_URL, null));
- addUIFormInput(new UIFormStringInput(PORTLET_MGMT_URL, PORTLET_MGMT_URL, null));
-
+ addUIFormInput(new UIFormStringInput(WSDL_URL, WSDL_URL, null));
+ //addChild(UIWsrpEndpointConfigForm.class,null,null);
}
private String getConsumerName(){
return getUIStringInput(CONSUMER_NAME).getValue();
}
- private String getCacheExpiration(){
- return getUIStringInput(CACHE_EXPIRATION).getValue();
+ private Integer getCacheExpiration(){
+ Integer cacheExp = 0;
+ String cacheExpString = getUIStringInput(CACHE_EXPIRATION).getValue();
+ if(cacheExpString != null){
+ cacheExp = Integer.parseInt(cacheExpString);
+ }
+ return cacheExp;
}
- private Object isUseWsdl(){
- return getUIFormCheckBoxInput(USE_WSDL).getValue();
- }
- private String getServiceDescriptionUrl(){
- return getUIStringInput(SERVICE_DESC_URL).getValue();
- }
- private String getMarkupUrl(){
- return getUIStringInput(MARKUP_URL).getValue();
- }
-
- private String getRegistrationUrl(){
- return getUIStringInput(REG_URL).getValue();
- }
-
- private String getPortletMgmtUrl(){
- return getUIStringInput(PORTLET_MGMT_URL).getValue();
- }
-
public void setConsumer(WSRPConsumer consumer) throws Exception{
+ //UIWsrpEndpointConfigForm uiWsrpEndpointConfigForm =
getChild(UIWsrpEndpointConfigForm.class);
if (consumer == null)
{
getUIStringInput(CONSUMER_NAME).setEditable(UIFormStringInput.ENABLE);
return;
}
- getUIStringInput(CONSUMER_NAME).setEditable(UIFormStringInput.DISABLE);
- invokeGetBindingBean(consumer);
+ getUIStringInput(CONSUMER_NAME).setEditable(UIFormStringInput.ENABLE);
+
+ getUIStringInput(CONSUMER_NAME).setValue(consumer.getProducerId());
+
getUIStringInput(CACHE_EXPIRATION).setValue(consumer.getProducerInfo().getExpirationCacheSeconds().toString());
+
getUIStringInput(WSDL_URL).setValue(consumer.getProducerInfo().getEndpointConfigurationInfo().getWsdlDefinitionURL());
+ //invokeGetBindingBean(consumer.getProducerInfo());
+
+ //uiWsrpEndpointConfigForm.setProducerInfo(consumer.getProducerInfo());
+
//uiWsrpEndpointConfigForm.invokeGetBindingBean(consumer.getProducerInfo().getEndpointConfigurationInfo());
+ //bindingFields(consumer);
}
+ private void bindingFields(WSRPConsumer consumer){
+ //ExoContainer manager = ExoContainerContext.getCurrentContainer();
+ //ConsumerRegistry consumerRegistry =
(ConsumerRegistry)manager.getComponentInstanceOfType(ConsumerRegistry.class);
+ ProducerInfo producerInfo = consumer.getProducerInfo();
+ producerInfo.setId(getConsumerName());
+ producerInfo.setExpirationCacheSeconds(getCacheExpiration());
+ //EndpointConfigurationInfo ecinfo =
producerInfo.getEndpointConfigurationInfo().setWsdlDefinitionURL();
+ //producerInfo.getEndpointConfigurationInfo().setWsdlDefinitionURL(getWsdlUrl());
+ }
+
static public class SaveActionListener extends
EventListener<UIWsrpConsumerEditor>
{
public void execute(Event<UIWsrpConsumerEditor> event) throws Exception
@@ -120,10 +123,9 @@
UIWsrpConsumerOverview consumerOverview =
consumerEditor.getAncestorOfType(UIWsrpConsumerOverview.class);
-
-
WebuiRequestContext ctx = event.getRequestContext();
consumerEditor.save(ctx);
+ consumerEditor.reset();
//loose the popup
//update the consumer grid/list using ajax
@@ -133,10 +135,9 @@
UIPopupWindow popup = consumerEditor.getParent();
popup.setRendered(false);
popup.setShow(false);
- popup.setUIComponent(null);
+ //create a new form, clears out the old, probably a better way
+
//popup.setUIComponent(consumerOverview.createUIComponent(UIWsrpConsumerEditor.class,
null, null));
-
-
LazyPageList pageList =
consumerOverview.createPageList(consumerOverview.getTempArrayList());
UIGrid uiGrid = consumerOverview.getChild(UIGrid.class);
uiGrid.getUIPageIterator().setPageList(pageList);
@@ -148,6 +149,32 @@
}
}
+ static public class EditActionListener extends
EventListener<UIWsrpConsumerEditor>
+ {
+ public void execute(Event<UIWsrpConsumerEditor> event) throws Exception
+ {
+ UIWsrpConsumerEditor consumerEditor = event.getSource();
+
+ UIWsrpConsumerOverview consumerOverview =
consumerEditor.getAncestorOfType(UIWsrpConsumerOverview.class);
+
+ WebuiRequestContext ctx = event.getRequestContext();
+ consumerEditor.edit(ctx);
+ consumerEditor.reset();
+
+ UIPopupWindow popup = consumerEditor.getParent();
+ popup.setRendered(false);
+ popup.setShow(false);
+
+ LazyPageList pageList =
consumerOverview.createPageList(consumerOverview.getTempArrayList());
+ UIGrid uiGrid = consumerOverview.getChild(UIGrid.class);
+ uiGrid.getUIPageIterator().setPageList(pageList);
+
+ ctx.addUIComponentToUpdateByAjax(consumerOverview);
+ }
+
+ }
+
+
public boolean save(WebuiRequestContext context) throws Exception
{
ExoContainer manager = ExoContainerContext.getCurrentContainer();
@@ -157,18 +184,38 @@
UIApplication uiApp = context.getUIApplication();
try{
- consumerRegistry.createConsumer(getConsumerName(),100);
+ consumerRegistry.createConsumer(getConsumerName(),300);
+ uiApp.addMessage(new ApplicationMessage("Consumer Successfully Added",
null));
}catch(ConsumerException ce){
//todo - add to resource bundle
uiApp.addMessage(new ApplicationMessage("Consumer already exists!",
null));
}
+ return true;
+ }
- //consumer = new WSRPConsumerImpl();
+ public boolean edit(WebuiRequestContext context) throws Exception
+ {
+ ExoContainer manager = ExoContainerContext.getCurrentContainer();
+ ConsumerRegistry consumerRegistry =
(ConsumerRegistry)manager.getComponentInstanceOfType(ConsumerRegistry.class);
+ ProducerInfo producerInfo =
consumerRegistry.getConsumer(getConsumerName()).getProducerInfo();
+ //invokeSetBindingBean(consumer.getProducerInfo());
+ //UIWsrpEndpointConfigForm uiWsrpEndpointConfigForm =
getChild(UIWsrpEndpointConfigForm.class);
+
//uiWsrpEndpointConfigForm.invokeSetBindingBean(consumer.getProducerInfo().getEndpointConfigurationInfo());
+ producerInfo.setId(getUIStringInput(CONSUMER_NAME).getValue());
+
producerInfo.setExpirationCacheSeconds(Integer.parseInt(getUIStringInput(CACHE_EXPIRATION).getValue()));
+
producerInfo.getEndpointConfigurationInfo().setWsdlDefinitionURL(getUIStringInput(WSDL_URL).getValue());
+ UIApplication uiApp = context.getUIApplication();
- System.out.println("----------getConsumerName: " + getConsumerName());
+ try{
+ consumerRegistry.updateProducerInfo(producerInfo);
+ uiApp.addMessage(new ApplicationMessage("Edit Consumer Successful!",
null));
+ }catch(ConsumerException ce){
+ //todo - add to resource bundle
+ uiApp.addMessage(new ApplicationMessage("Edit Consumer Problem!",
null));
+ }
return true;
}
Modified:
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java
===================================================================
---
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java 2009-12-19
16:01:59 UTC (rev 1076)
+++
portal/branches/wsrp-integration/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java 2009-12-20
04:23:19 UTC (rev 1077)
@@ -51,11 +51,11 @@
import java.util.ArrayList;
import java.util.List;
-/** @author Wesley Hales */
+/** @author Wesley Hales */
@ComponentConfigs({
@ComponentConfig(id = "ConsumerSelector", type = UIGrid.class, template =
"system:/groovy/webui/core/UIGrid.gtmpl",
events = { //make note in doc not to put grid listeners here
- }),
+ }),
@ComponentConfig(
lifecycle = UIApplicationLifecycle.class,
template =
"app:/groovy/wsrp/webui/component/UIWsrpConsumerOverview.gtmpl",
@@ -79,7 +79,7 @@
//edit
//delete
//
- public static String[] SELECT_ACTIONS =
{"Edit","Delete","Refresh","Deactivate","Start","Stop"};
+ public static String[] SELECT_ACTIONS = {"Edit", "Delete",
"Refresh", "Deactivate", "Start", "Stop"};
private List tempArrayList;
@@ -90,7 +90,8 @@
return consumerRegistry.getConfiguredConsumers();
}
- public LazyPageList createPageList(final List pageList){
+ public LazyPageList createPageList(final List pageList)
+ {
return new LazyPageList(new ListAccess<WSRPConsumer>()
{
@@ -156,6 +157,12 @@
public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
{
UIWsrpConsumerOverview consumerOverview = event.getSource();
+ consumerOverview.refreshGrid(event);
+ }
+ }
+
+ public void refreshGrid(Event<UIWsrpConsumerOverview> event){
+ UIWsrpConsumerOverview consumerOverview = event.getSource();
WebuiRequestContext ctx = event.getRequestContext();
UIGrid uiGrid = consumerOverview.getChild(UIGrid.class);
@@ -164,8 +171,6 @@
uiGrid.getUIPageIterator().setPageList(pageList);
ctx.addUIComponentToUpdateByAjax(consumerOverview);
-
- }
}
static public class OpenPopupActionListener extends
EventListener<UIWsrpConsumerOverview>
@@ -181,8 +186,8 @@
popup.setRendered(true);
popup.setShow(true);
popup.setShowCloseButton(true);
- popup.setShowMask(true);
-
+ //popup.setShowMask(true);
+
}
}
@@ -192,17 +197,26 @@
{
UIWsrpConsumerOverview consumerOverview = event.getSource();
WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
+
UIApplication uiApp = event.getRequestContext().getUIApplication();
- if(consumer != null){
- UIPopupWindow popup = consumerOverview.getChild(UIPopupWindow.class);
- UIWsrpConsumerEditor editor = (UIWsrpConsumerEditor)popup.getUIComponent();
- editor.setConsumer(consumer);
- popup.setRendered(true);
- popup.setShow(true);
+ if (consumer != null)
+ {
+ UIPopupWindow popup = consumerOverview.getChild(UIPopupWindow.class);
+ UIWsrpConsumerEditor editor = (UIWsrpConsumerEditor)popup.getUIComponent();
+
+ try
+ {
+ editor.setConsumer(consumer);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ popup.setUIComponent(editor);
+ popup.setRendered(true);
+ popup.setShow(true);
}
-
-
}
}
@@ -212,17 +226,20 @@
{
UIWsrpConsumerOverview consumerOverview = event.getSource();
WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
+ ConsumerRegistry consumerRegistry = consumerOverview.getConsumerRegistry();
UIApplication uiApp = event.getRequestContext().getUIApplication();
-
- if(consumer != null){
- consumer.getProducerInfo().deregister();
- uiApp.addMessage(new ApplicationMessage("Consumer has been
deleted.", null));
+ String id = event.getRequestContext().getRequestParameter(OBJECTID);
+ if (consumer != null)
+ {
+ consumerRegistry.destroyConsumer(id);
+ uiApp.addMessage(new ApplicationMessage("Consumer has been
deleted.", null));
+ consumerOverview.refreshGrid(event);
}
}
}
- static public class StartActionListener extends
EventListener<UIWsrpConsumerOverview>
+ static public class StartActionListener extends
EventListener<UIWsrpConsumerOverview>
{
public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
{
@@ -230,15 +247,17 @@
WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
UIApplication uiApp = event.getRequestContext().getUIApplication();
- if(consumer != null){
- consumer.start();
- uiApp.addMessage(new ApplicationMessage("todo", null));
+ if (consumer != null)
+ {
+ consumer.start();
+ uiApp.addMessage(new ApplicationMessage("Consumer Started
Successfully", null));
+ consumerOverview.refreshGrid(event);
}
}
}
- static public class StopActionListener extends
EventListener<UIWsrpConsumerOverview>
+ static public class StopActionListener extends
EventListener<UIWsrpConsumerOverview>
{
public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
{
@@ -246,9 +265,11 @@
WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
UIApplication uiApp = event.getRequestContext().getUIApplication();
- if(consumer != null){
- consumer.stop();
- uiApp.addMessage(new ApplicationMessage("todo", null));
+ if (consumer != null)
+ {
+ consumer.stop();
+ uiApp.addMessage(new ApplicationMessage("Consumer Stopped
Successfully", null));
+ consumerOverview.refreshGrid(event);
}
}
}
@@ -261,9 +282,11 @@
WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
UIApplication uiApp = event.getRequestContext().getUIApplication();
- if(consumer != null){
- consumer.deactivate();
- uiApp.addMessage(new ApplicationMessage("todo", null));
+ if (consumer != null)
+ {
+ consumer.deactivate();
+ uiApp.addMessage(new ApplicationMessage("Consumer Deactivated
Successfully", null));
+ consumerOverview.refreshGrid(event);
}
}
}
@@ -276,21 +299,29 @@
WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
UIApplication uiApp = event.getRequestContext().getUIApplication();
- if(consumer != null){
- consumer.refresh(true);
- uiApp.addMessage(new ApplicationMessage("todo", null));
+ if (consumer != null)
+ {
+ consumer.refresh(true);
+ uiApp.addMessage(new ApplicationMessage("Consumer Refreshed
Successfully", null));
+ consumerOverview.refreshGrid(event);
}
}
}
- public WSRPConsumer getConsumerFromEvent(Event<?> event) throws Exception{
- ExoContainer manager = ExoContainerContext.getCurrentContainer();
- ConsumerRegistry consumerRegistry =
(ConsumerRegistry)manager.getComponentInstanceOfType(ConsumerRegistry.class);
+ public WSRPConsumer getConsumerFromEvent(Event<?> event) throws Exception
+ {
+ ConsumerRegistry consumerRegistry = getConsumerRegistry();
String id = event.getRequestContext().getRequestParameter(OBJECTID);
return consumerRegistry.getConsumer(id);
}
+ public ConsumerRegistry getConsumerRegistry() throws Exception
+ {
+ ExoContainer manager = ExoContainerContext.getCurrentContainer();
+ return
(ConsumerRegistry)manager.getComponentInstanceOfType(ConsumerRegistry.class);
+ }
+
// public void processRender(WebuiRequestContext context) throws Exception
// {
// super.processRender(context);
Modified:
portal/branches/wsrp-integration/portlet/exoadmin/src/main/webapp/groovy/wsrp/webui/component/UIWsrpConsumerEditor.gtmpl
===================================================================
---
portal/branches/wsrp-integration/portlet/exoadmin/src/main/webapp/groovy/wsrp/webui/component/UIWsrpConsumerEditor.gtmpl 2009-12-19
16:01:59 UTC (rev 1076)
+++
portal/branches/wsrp-integration/portlet/exoadmin/src/main/webapp/groovy/wsrp/webui/component/UIWsrpConsumerEditor.gtmpl 2009-12-20
04:23:19 UTC (rev 1077)
@@ -11,6 +11,7 @@
<div class="FloatRight">
<div class="FloatLeft">
<div class="UserName">
+ <div>
<label>Consumer Name</label>
<% //uiform.renderChild(0); %>
<%
@@ -59,8 +60,27 @@
</tr>
</table>
</div>
+
+ <div class="UIAction">
+ <table class="ActionContainer">
+ <tr>
+ <td>
+ <div onclick="<%=uicomponent.event("Edit")%>"
class="ActionButton LightBlueStyle">
+ <div class="ButtonLeft">
+ <div class="ButtonRight">
+ <div class="ButtonMiddle">
+ <a
href="javascript:void(0);"><%=_ctx.appRes(uicomponent.getId() +
".action.Edit")%></a>
+ </div>
+ </div>
+ </div>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </div>
<div class="ClearLeft"><span></span></div>
</div>
<div class="ClearRight"><span></span></div>
<% uiform.end() %>
</div>
+</div>
\ No newline at end of file