Author: chris.laprun(a)jboss.com
Date: 2010-01-19 11:58:27 -0500 (Tue, 19 Jan 2010)
New Revision: 1383
Added:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/ConsumerController.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/UIWsrpConsumerEditor.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/UIWsrpConsumerOverview.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpProducerEditor.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpProducerOverview.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpProducerPropertyEditor.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpRegistrationDetails.java
Removed:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/ConsumerController.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerEditor.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerOverview.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerPropertyEditor.java
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpRegistrationDetails.java
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpPortlet.java
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/wsrp/webui/component/UIWsrpProducerOverview.gtmpl
Log:
- Created packages to better organize code.
Deleted:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/ConsumerController.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/ConsumerController.java 2010-01-19
16:55:52 UTC (rev 1382)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/ConsumerController.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -1,85 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
- * contributors as indicated by the @authors tag. See the
- * copyright.txt in the distribution for a full listing of
- * individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.wsrp.webui.component;
-
-import org.gatein.pc.api.PortletInvokerException;
-import org.gatein.wsrp.WSRPConsumer;
-import org.gatein.wsrp.consumer.RefreshResult;
-import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
-
-import java.util.List;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class ConsumerController
-{
- private ConsumerRegistry registry;
-
- public ConsumerController(ConsumerRegistry registry)
- {
- this.registry = registry;
- }
-
- public ConsumerRegistry getRegistry()
- {
- return registry;
- }
-
- public WSRPConsumer getConsumer(String id)
- {
- return registry.getConsumer(id);
- }
-
- public List<WSRPConsumer> getConfiguredConsumers()
- {
- return registry.getConfiguredConsumers();
- }
-
- public RefreshResult refreshConsumer(WSRPConsumer consumer) throws
PortletInvokerException
- {
- RefreshResult result = consumer.refresh(true);
-
- if (result.hasIssues())
- {
- // refresh had issues, we should deactivate this consumer
- registry.deactivateConsumerWith(consumer.getProducerId());
- }
- else
- {
- // activate the consumer if it's supposed to be active
- if (consumer.isActive())
- {
- registry.activateConsumerWith(consumer.getProducerId());
- }
- else
- {
- registry.deactivateConsumerWith(consumer.getProducerId());
- }
- }
-
- return result;
- }
-}
Deleted:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java 2010-01-19
16:55:52 UTC (rev 1382)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -1,222 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2009, Red Hat Middleware, LLC, and individual
- * contributors as indicated by the @authors tag. See the
- * copyright.txt in the distribution for a full listing of
- * individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.wsrp.webui.component;
-
-import org.exoplatform.commons.utils.LazyPageList;
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.web.application.ApplicationMessage;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.core.UIApplication;
-import org.exoplatform.webui.core.UIGrid;
-import org.exoplatform.webui.core.UIPopupWindow;
-import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-import org.exoplatform.webui.form.UIForm;
-import org.exoplatform.webui.form.UIFormInputBase;
-import org.exoplatform.webui.form.UIFormStringInput;
-import org.exoplatform.webui.form.validator.MandatoryValidator;
-import org.gatein.common.util.ParameterValidation;
-import org.gatein.wsrp.WSRPConsumer;
-import org.gatein.wsrp.consumer.ConsumerException;
-import org.gatein.wsrp.consumer.ProducerInfo;
-import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
-import org.gatein.wsrp.services.ManageableServiceFactory;
-
-/** @author Wesley Hales */
-@ComponentConfig(template =
"app:/groovy/wsrp/webui/component/UIWsrpConsumerEditor.gtmpl", lifecycle =
UIFormLifecycle.class, events = {
- @EventConfig(listeners = UIWsrpConsumerEditor.SaveActionListener.class)})
-public class UIWsrpConsumerEditor extends UIForm
-{
- protected static final String CONSUMER_NAME = "Consumer name: ";
- protected static final String CACHE_EXPIRATION = "Seconds before cache
expiration: ";
- protected static final String TIMEOUT = "Milliseconds before timeout: ";
- protected static final String WSDL_URL = "WSDL URL: ";
- private UIFormInputBase<String> consumerName;
- private UIFormStringInput cache;
- private UIFormStringInput timeoutWS;
- private UIFormStringInput wsdl;
-
- public UIWsrpConsumerEditor() throws Exception
- {
-
- consumerName = new UIFormStringInput(CONSUMER_NAME, CONSUMER_NAME,
null).addValidator(MandatoryValidator.class);
- addUIFormInput(consumerName);
- cache = new UIFormStringInput(CACHE_EXPIRATION, CACHE_EXPIRATION, null);
- addUIFormInput(cache);
- timeoutWS = new UIFormStringInput(TIMEOUT, TIMEOUT, null);
- addUIFormInput(timeoutWS);
- wsdl = new UIFormStringInput(WSDL_URL, WSDL_URL, null);
- addUIFormInput(wsdl);
- }
-
- private String getConsumerName()
- {
- return consumerName.getValue();
- }
-
- private Integer getCacheExpiration()
- {
- Integer cacheExp = 0;
- String cacheExpString = cache.getValue();
- if (cacheExpString != null)
- {
- cacheExp = Integer.parseInt(cacheExpString);
- }
- return cacheExp;
- }
-
- private Integer getTimeout()
- {
- int timeout = ManageableServiceFactory.DEFAULT_TIMEOUT_MS;
- String timeoutString = timeoutWS.getValue();
- if (!ParameterValidation.isNullOrEmpty(timeoutString))
- {
- timeout = Integer.parseInt(timeoutString);
- }
-
- return timeout;
- }
-
- private String getWSDLURL()
- {
- return wsdl.getValue();
- }
-
- private Boolean newConsumer;
-
- public Boolean isNewConsumer()
- {
- return newConsumer;
- }
-
- public void setNewConsumer(Boolean newConsumer)
- {
- this.newConsumer = newConsumer;
- }
-
- public void setConsumer(WSRPConsumer consumer)
- {
- if (consumer == null)
- {
- consumerName.setEditable(UIFormStringInput.ENABLE);
- setNewConsumer(true);
- return;
- }
- consumerName.setEditable(UIFormStringInput.ENABLE);
-
- consumerName.setValue(consumer.getProducerId());
- ProducerInfo producerInfo = consumer.getProducerInfo();
- cache.setValue(producerInfo.getExpirationCacheSeconds().toString());
- timeoutWS.setValue("" +
producerInfo.getEndpointConfigurationInfo().getWSOperationTimeOut());
- wsdl.setValue(producerInfo.getEndpointConfigurationInfo().getWsdlDefinitionURL());
- setNewConsumer(false);
- }
-
- static public class SaveActionListener 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();
- if (consumerEditor.isNewConsumer())
- {
- consumerEditor.save(ctx);
- }
- else
- {
- consumerEditor.edit(ctx);
- }
-
- consumerEditor.reset();
-
- UIPopupWindow popup = consumerEditor.getParent();
- popup.setRendered(false);
- popup.setShow(false);
-
- //temp way to refresh list, should call broadcast event (below)
- LazyPageList pageList =
consumerOverview.createPageList(consumerOverview.getConfiguredConsumers());
- UIGrid uiGrid = consumerOverview.getChild(UIGrid.class);
- uiGrid.getUIPageIterator().setPageList(pageList);
- //uiGrid.configure()
- //try to broadcast an event back to consumerOverview to refresh grid... works
but shows error
- //PortalRequestContext portalContext =
org.exoplatform.portal.webui.util.Util.getPortalRequestContext();
- //Event<UIWsrpConsumerOverview> pnevent = new
Event<UIWsrpConsumerOverview>(consumerOverview, "RefreshGrid",
portalContext);
- //consumerOverview.broadcast(pnevent, Event.Phase.PROCESS);
-
- ctx.addUIComponentToUpdateByAjax(consumerOverview);
- }
- }
-
- public boolean save(WebuiRequestContext context) throws Exception
- {
- ExoContainer manager = ExoContainerContext.getCurrentContainer();
- ConsumerRegistry consumerRegistry =
(ConsumerRegistry)manager.getComponentInstanceOfType(ConsumerRegistry.class);
-
- UIApplication uiApp = context.getUIApplication();
-
- try
- {
- consumerRegistry.createConsumer(getConsumerName(), getCacheExpiration(),
getWSDLURL());
- uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.action.add.success", null));
- }
- catch (ConsumerException ce)
- {
- //todo - add to resource bundle
- uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.action.add.exists", null,
ApplicationMessage.ERROR));
- }
- return true;
- }
-
- public boolean edit(WebuiRequestContext context) throws Exception
- {
- ExoContainer manager = ExoContainerContext.getCurrentContainer();
- ConsumerRegistry consumerRegistry =
(ConsumerRegistry)manager.getComponentInstanceOfType(ConsumerRegistry.class);
- ProducerInfo producerInfo =
consumerRegistry.getConsumer(getConsumerName()).getProducerInfo();
-
- producerInfo.setId(getConsumerName());
- producerInfo.setExpirationCacheSeconds(getCacheExpiration());
- producerInfo.getEndpointConfigurationInfo().setWsdlDefinitionURL(getWSDLURL());
- producerInfo.getEndpointConfigurationInfo().setWSOperationTimeOut(getTimeout());
-
- UIApplication uiApp = context.getUIApplication();
-
- try
- {
- consumerRegistry.updateProducerInfo(producerInfo);
- uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.action.edit.success", null));
- }
- catch (ConsumerException ce)
- {
- uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.action.edit.fail", null,
ApplicationMessage.ERROR));
- }
- return true;
- }
-
-}
Deleted:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java 2010-01-19
16:55:52 UTC (rev 1382)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -1,323 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
- * contributors as indicated by the @authors tag. See the
- * copyright.txt in the distribution for a full listing of
- * individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.wsrp.webui.component;
-
-import org.exoplatform.commons.utils.LazyPageList;
-import org.exoplatform.commons.utils.ListAccess;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.web.application.ApplicationMessage;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.core.UIApplication;
-import org.exoplatform.webui.core.UIContainer;
-import org.exoplatform.webui.core.UIGrid;
-import org.exoplatform.webui.core.UIPageIterator;
-import org.exoplatform.webui.core.UIPopupWindow;
-import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-import org.gatein.wsrp.WSRPConsumer;
-import org.gatein.wsrp.consumer.RefreshResult;
-import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
-
-import java.util.List;
-
-/** @author Wesley Hales */
-
-@ComponentConfig(
- lifecycle = UIApplicationLifecycle.class,
- template = "app:/groovy/wsrp/webui/component/UIWsrpConsumerOverview.gtmpl",
- events = {
- @EventConfig(listeners =
UIWsrpConsumerOverview.CreateConsumerActionListener.class),
- @EventConfig(listeners = UIWsrpConsumerOverview.EditActionListener.class),
- @EventConfig(listeners = UIWsrpConsumerOverview.DeleteActionListener.class),
- @EventConfig(listeners = UIWsrpConsumerOverview.RefreshActionListener.class),
- @EventConfig(listeners = UIWsrpConsumerOverview.DeactivateActionListener.class),
- @EventConfig(listeners = UIWsrpConsumerOverview.ActivateActionListener.class),
- @EventConfig(listeners = UIWsrpConsumerOverview.RefreshGridActionListener.class)
- })
-public class UIWsrpConsumerOverview extends UIContainer
-{
- public static String[] FIELDS = {"producerId", "active",
"refreshNeeded"};
-
- //The action names are also your class names on the ui buttons. You should stick with
common names like:
- //edit
- //delete
- //
- public static String[] SELECT_ACTIONS = {"Edit", "Delete",
"Refresh", "Activate", "Deactivate"};
-
- private ConsumerController controller;
- private UIPopupWindow consumerEditorPopup;
- private UIPageIterator consumersIterator;
-
- public List getConfiguredConsumers() throws Exception
- {
- return controller.getConfiguredConsumers();
- }
-
- public LazyPageList createPageList(final List pageList)
- {
- return new LazyPageList<WSRPConsumer>(new ListAccess<WSRPConsumer>()
- {
-
- public int getSize() throws Exception
- {
- return pageList.size();
- }
-
- public WSRPConsumer[] load(int index, int length) throws Exception
- {
- WSRPConsumer[] pcs = new WSRPConsumer[pageList.size()];
-
- if (index < 0)
- {
- throw new IllegalArgumentException("Illegal index: index must be a
positive number");
- }
-
- if (length < 0)
- {
- throw new IllegalArgumentException("Illegal length: length must be a
positive number");
- }
-
- if (index + length > pageList.size())
- {
- throw new IllegalArgumentException(
- "Illegal index or length: sum of the index and the length cannot
be greater than the list size");
- }
-
- for (int i = 0; i < length; i++)
- {
- pcs[i] = (WSRPConsumer)pageList.get(i + index);
- }
-
- return pcs;
- }
-
- }, 10);
- }
-
- public UIWsrpConsumerOverview() throws Exception
- {
- // controller
- ConsumerRegistry registry =
(ConsumerRegistry)ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(ConsumerRegistry.class);
- controller = new ConsumerController(registry);
-
- //setSelectedTab(1);
- consumerEditorPopup = addChild(UIPopupWindow.class, null, null);
- consumerEditorPopup.setWindowSize(450, 0);
- UIWsrpConsumerEditor consumerForm = createUIComponent(UIWsrpConsumerEditor.class,
null, "Consumer Editor");
- consumerEditorPopup.setUIComponent(consumerForm);
- consumerEditorPopup.setRendered(false);
-
- UIGrid consumers = addChild(UIGrid.class, null, null);
- //configure the edit and delete buttons based on an id from the data list - this
will also be passed as param to listener
- consumers.configure("producerId", FIELDS, SELECT_ACTIONS);
-
- consumersIterator = consumers.getUIPageIterator();
- consumersIterator.setId("ChangeConsumerPageIterator");
- consumersIterator.setRendered(false);
-
- refreshConsumersList();
- }
-
- static public class RefreshGridActionListener extends
EventListener<UIWsrpConsumerOverview>
- {
- public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
- {
- UIWsrpConsumerOverview consumerOverview = event.getSource();
- consumerOverview.refreshGrid(event);
- }
- }
-
- public void refreshGrid(Event<UIWsrpConsumerOverview> event) throws Exception
- {
- //refresh the list
- refreshConsumersList();
-
- event.getRequestContext().addUIComponentToUpdateByAjax(this);
- }
-
- private void refreshConsumersList() throws Exception
- {
- LazyPageList pageList = createPageList(getConfiguredConsumers());
- consumersIterator.setPageList(pageList);
- }
-
- static public class CreateConsumerActionListener extends
EventListener<UIWsrpConsumerOverview>
- {
- public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
- {
- UIWsrpConsumerOverview consumerOverview = event.getSource();
- consumerOverview.displayConsumerEditor(null);
- }
- }
-
- private void displayConsumerEditor(WSRPConsumer consumer) throws Exception
- {
- UIWsrpConsumerEditor editor =
(UIWsrpConsumerEditor)consumerEditorPopup.getUIComponent();
-
- //reset the form
- editor.reset();
- editor.setConsumer(consumer);
- consumerEditorPopup.setRendered(true);
- consumerEditorPopup.setShow(true);
- consumerEditorPopup.setShowCloseButton(true);
- }
-
- static public class EditActionListener extends
EventListener<UIWsrpConsumerOverview>
- {
- public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
- {
- UIWsrpConsumerOverview consumerOverview = event.getSource();
- WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
-
- if (consumer != null)
- {
- consumerOverview.displayConsumerEditor(consumer);
- }
- }
- }
-
- static public class DeleteActionListener extends
EventListener<UIWsrpConsumerOverview>
- {
- public void execute(Event<UIWsrpConsumerOverview> event)
- {
- UIApplication uiApp = event.getRequestContext().getUIApplication();
- try
- {
- UIWsrpConsumerOverview consumerOverview = event.getSource();
- WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
- ConsumerRegistry consumerRegistry = consumerOverview.getConsumerRegistry();
- String id = event.getRequestContext().getRequestParameter(OBJECTID);
- if (consumer != null)
- {
- consumerRegistry.destroyConsumer(id);
- uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.delete.success", null,
ApplicationMessage.INFO));
- consumerOverview.refreshGrid(event);
- }
- }
- catch (Exception e)
- {
- uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.delete.fail", new
String[]{e.getCause().toString()}, ApplicationMessage.ERROR));
- }
-
- }
- }
-
- static public class DeactivateActionListener extends
EventListener<UIWsrpConsumerOverview>
- {
- public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
- {
- UIWsrpConsumerOverview consumerOverview = event.getSource();
- WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
- UIApplication uiApp = event.getRequestContext().getUIApplication();
-
- if (consumer != null)
- {
- if (consumer.isActive())
- {
- ConsumerRegistry registry = consumerOverview.getConsumerRegistry();
- registry.deactivateConsumerWith(consumer.getProducerId());
- uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.deactivate.success", null));
- consumerOverview.refreshGrid(event);
- }
- else
- {
- uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.deactivate.fail", null));
- }
- }
- }
- }
-
- static public class ActivateActionListener extends
EventListener<UIWsrpConsumerOverview>
- {
- public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
- {
- UIWsrpConsumerOverview consumerOverview = event.getSource();
- WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
- UIApplication uiApp = event.getRequestContext().getUIApplication();
-
- if (consumer != null && !consumer.isActive())
- {
- try
- {
- ConsumerRegistry registry = consumerOverview.getConsumerRegistry();
- registry.activateConsumerWith(consumer.getProducerId());
- uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.activate.success", null));
- consumerOverview.refreshGrid(event);
- }
- catch (Exception e)
- {
- uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.activate.fail", new
String[]{e.getCause().toString()}, ApplicationMessage.ERROR));
- e.printStackTrace();
- }
- }
- }
- }
-
- static public class RefreshActionListener extends
EventListener<UIWsrpConsumerOverview>
- {
- public void execute(Event<UIWsrpConsumerOverview> event)
- {
- UIApplication uiApp = event.getRequestContext().getUIApplication();
- try
- {
- UIWsrpConsumerOverview consumerOverview = event.getSource();
- WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
-
- if (consumer != null)
- {
- RefreshResult result =
consumerOverview.controller.refreshConsumer(consumer);
-
- if (result.hasIssues())
- {
- consumerOverview.displayConsumerEditor(consumer);
- }
- else
- {
- uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.refresh.success", null,
ApplicationMessage.INFO));
- }
-
- // refresh consumers
- consumerOverview.refreshGrid(event);
- }
- }
- catch (Exception e)
- {
- uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.refresh.fail", new
String[]{e.getCause().toString()}, ApplicationMessage.ERROR));
- e.printStackTrace();
- }
- }
- }
-
- public WSRPConsumer getConsumerFromEvent(Event<?> event) throws Exception
- {
- String id = event.getRequestContext().getRequestParameter(OBJECTID);
- return controller.getConsumer(id);
- }
-
- public ConsumerRegistry getConsumerRegistry() throws Exception
- {
- return controller.getRegistry();
- }
-}
Modified:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpPortlet.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpPortlet.java 2010-01-19
16:55:52 UTC (rev 1382)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpPortlet.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -26,6 +26,8 @@
import org.exoplatform.webui.core.UIPortletApplication;
import org.exoplatform.webui.core.UITabPane;
import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
+import org.exoplatform.wsrp.webui.component.consumer.UIWsrpConsumerOverview;
+import org.exoplatform.wsrp.webui.component.producer.UIWsrpProducerOverview;
/** @author Wesley Hales */
@ComponentConfig(
Deleted:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerEditor.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerEditor.java 2010-01-19
16:55:52 UTC (rev 1382)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerEditor.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -1,177 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
- * contributors as indicated by the @authors tag. See the
- * copyright.txt in the distribution for a full listing of
- * individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.wsrp.webui.component;
-
-import org.exoplatform.portal.webui.util.Util;
-import org.exoplatform.web.application.ApplicationMessage;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.core.UIApplication;
-import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-import org.exoplatform.webui.form.UIForm;
-import org.exoplatform.webui.form.UIFormCheckBoxInput;
-import org.gatein.wsrp.producer.config.ProducerConfiguration;
-import org.gatein.wsrp.producer.config.ProducerConfigurationService;
-import org.gatein.wsrp.producer.config.ProducerRegistrationRequirements;
-
-/**
- * @author Wesley Hales
- * @author Chris Laprun
- */
-@ComponentConfig(
- lifecycle = UIFormLifecycle.class,
- template = "app:/groovy/wsrp/webui/component/UIWsrpProducerEditor.gtmpl",
- events = {
- @EventConfig(listeners = UIWsrpProducerEditor.SaveActionListener.class),
- @EventConfig(listeners =
UIWsrpProducerEditor.RegistrationOnChangeActionListener.class)
- }
-)
-public class UIWsrpProducerEditor extends UIForm
-{
- private static final String REG_REQUIRED_FOR_DESCRIPTION =
"registrationrequiredforfulldescription";
- private static final String STRICT_MODE = "strictmode";
- private static final String REQUIRES_REGISTRATION = "requiresregistration";
- private static final String REGISTRATION_DETAILS = "registrationdetails";
-
- private ProducerConfigurationService configService;
- private UIWsrpRegistrationDetails registrationDetails;
- private UIFormCheckBoxInput regReqForDesc;
- private UIFormCheckBoxInput strictMode;
- private UIFormCheckBoxInput<Boolean> regRequired;
-
- public UIWsrpProducerEditor() throws Exception
- {
- configService =
Util.getUIPortalApplication().getApplicationComponent(ProducerConfigurationService.class);
-
- regReqForDesc = new UIFormCheckBoxInput(REG_REQUIRED_FOR_DESCRIPTION,
REG_REQUIRED_FOR_DESCRIPTION, null);
- addUIFormInput(regReqForDesc);
- strictMode = new UIFormCheckBoxInput(STRICT_MODE, STRICT_MODE, null);
- addUIFormInput(strictMode);
-
- // registration required check box with onChange event
- regRequired = new UIFormCheckBoxInput<Boolean>(REQUIRES_REGISTRATION,
REQUIRES_REGISTRATION, null);
- regRequired.setOnChange("RegistrationOnChange");
- addUIFormInput(regRequired);
- // because when we use setOnChange method, new eventListener will add to this form,
we must re-set the actions of this form.
- // thif form has no action, so i'll put empty string array
- setActions(new String[]{});
-
- // registration details
- // form set to gather registration information
- registrationDetails = addChild(UIWsrpRegistrationDetails.class, null,
REGISTRATION_DETAILS);
-
- init(false);
- }
-
- ProducerConfigurationService getService()
- {
- return configService;
- }
-
- private void init(boolean getRegistrationRequiredFromCheckBox) throws Exception
- {
- ProducerConfiguration configuration = configService.getConfiguration();
-
- ProducerRegistrationRequirements registrationRequirements =
configuration.getRegistrationRequirements();
-
regReqForDesc.setValue(registrationRequirements.isRegistrationRequiredForFullDescription());
- strictMode.setValue(configuration.isUsingStrictMode());
-
- boolean registrationRequired = getRegistrationRequiredFromCheckBox ?
- regRequired.getValue() :
- registrationRequirements.isRegistrationRequired();
- regRequired.setValue(registrationRequired);
-
- // if registration is required then we display more information
- if (registrationRequired)
- {
- registrationDetails.init(registrationRequirements);
- registrationDetails.setRendered(true);
- }
- else
- {
- registrationDetails.setRendered(false);
- }
- }
-
-
- static public class SaveActionListener extends
EventListener<UIWsrpProducerEditor>
- {
- public void execute(Event<UIWsrpProducerEditor> event) throws Exception
- {
- UIWsrpProducerEditor source = event.getSource();
- ProducerConfigurationService service = source.getService();
- ProducerConfiguration producerConfiguration = service.getConfiguration();
- ProducerRegistrationRequirements registrationRequirements =
producerConfiguration.getRegistrationRequirements();
-
registrationRequirements.setRegistrationRequiredForFullDescription(Boolean.parseBoolean(source.regReqForDesc.getValue().toString()));
-
producerConfiguration.setUsingStrictMode(Boolean.parseBoolean(source.strictMode.getValue().toString()));
-
- boolean requiresReg =
Boolean.parseBoolean(source.regRequired.getValue().toString());
- registrationRequirements.setRegistrationRequired(requiresReg);
- if (requiresReg)
- {
-
source.registrationDetails.updateRegistrationDetailsFromForm(registrationRequirements);
- }
-
- try
- {
- service.saveConfiguration();
- }
- catch (Exception e)
- {
- UIApplication uiApp = event.getRequestContext().getUIApplication();
- uiApp.addMessage(new ApplicationMessage("Producer Modification
Error", null, ApplicationMessage.ERROR));
- e.printStackTrace();
- }
-
- source.init(false);
- }
- }
-
- /*public static class RegistrationOnChangeActionListener extends
EventListener<UIFormCheckBoxInput>
- {
- public void execute(Event<UIFormCheckBoxInput> event) throws Exception
- {
- UIFormCheckBoxInput source = event.getSource();
- UIWsrpProducerEditor parent =
source.getAncestorOfType(UIWsrpProducerEditor.class);
- parent.init();
-
- //update only the parent, avoid updating the full portlet
- event.getRequestContext().addUIComponentToUpdateByAjax(parent);
- }
- }*/
-
- public static class RegistrationOnChangeActionListener extends
EventListener<UIWsrpProducerEditor>
- {
- public void execute(Event<UIWsrpProducerEditor> event) throws Exception
- {
- UIWsrpProducerEditor source = event.getSource();
- source.init(true);
-
- //update only the parent, avoid updating the full portlet
- event.getRequestContext().addUIComponentToUpdateByAjax(source);
- }
- }
-
-}
Deleted:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerOverview.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerOverview.java 2010-01-19
16:55:52 UTC (rev 1382)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerOverview.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -1,46 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
- * contributors as indicated by the @authors tag. See the
- * copyright.txt in the distribution for a full listing of
- * individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.wsrp.webui.component;
-
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.core.UIContainer;
-import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
-
-/**
- * @author Wesley Hales
- * @author Chris Laprun
- */
-@ComponentConfig(
- lifecycle = UIApplicationLifecycle.class,
- template = "app:/groovy/wsrp/webui/component/UIWsrpProducerOverview.gtmpl"
-)
-public class UIWsrpProducerOverview extends UIContainer
-{
- private UIWsrpProducerEditor producerForm;
-
- public UIWsrpProducerOverview() throws Exception
- {
- producerForm = createUIComponent(UIWsrpProducerEditor.class, null, "Producer
Editor");
- addChild(producerForm);
- }
-}
Deleted:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerPropertyEditor.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerPropertyEditor.java 2010-01-19
16:55:52 UTC (rev 1382)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerPropertyEditor.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -1,145 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.exoplatform.wsrp.webui.component;
-
-import org.exoplatform.container.ExoContainer;
-import org.exoplatform.container.ExoContainerContext;
-import org.exoplatform.web.application.ApplicationMessage;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.core.UIApplication;
-import org.exoplatform.webui.core.UIPopupWindow;
-import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-import org.exoplatform.webui.form.UIForm;
-import org.exoplatform.webui.form.UIFormStringInput;
-import org.exoplatform.webui.form.validator.MandatoryValidator;
-import org.gatein.wsrp.producer.config.ProducerConfiguration;
-import org.gatein.wsrp.producer.config.ProducerConfigurationService;
-import org.gatein.wsrp.registration.LocalizedString;
-import org.gatein.wsrp.registration.RegistrationPropertyDescription;
-
-
-/** @author Wesley Hales */
-@ComponentConfig(template =
"app:/groovy/wsrp/webui/component/UIWsrpProducerPropertyEditor.gtmpl", lifecycle
= UIFormLifecycle.class,
- events = {
- @EventConfig(listeners = UIWsrpProducerPropertyEditor.SaveActionListener.class)})
-public class UIWsrpProducerPropertyEditor extends UIForm
-{
- protected static final String DESCRIPTION = "description";
- protected static final String LABEL = "label";
- protected static final String HINT = "hint";
- private RegistrationPropertyDescription registrationPropertyDescription_;
-
- public UIWsrpProducerPropertyEditor() throws Exception
- {
- addUIFormInput(new UIFormStringInput(DESCRIPTION, DESCRIPTION,
null).addValidator(MandatoryValidator.class));
- addUIFormInput(new UIFormStringInput(LABEL, LABEL,
null).addValidator(MandatoryValidator.class));
- addUIFormInput(new UIFormStringInput(HINT, HINT,
null).addValidator(MandatoryValidator.class));
- }
-
- public void setRegistrationPropertyDescription(RegistrationPropertyDescription
registrationPropertyDescription) throws Exception
- {
-
- this.registrationPropertyDescription_ = registrationPropertyDescription;
-
- if (registrationPropertyDescription_ == null)
- {
- getUIStringInput(DESCRIPTION).setEditable(UIFormStringInput.ENABLE);
- reset();
- return;
- }
- getUIStringInput(DESCRIPTION).setEditable(UIFormStringInput.ENABLE);
-
- invokeGetBindingBean(registrationPropertyDescription_);
-
- }
-
- public RegistrationPropertyDescription getRegistrationPropertyDescription()
- {
- return registrationPropertyDescription_;
- }
-
- static public class SaveActionListener extends
EventListener<UIWsrpProducerPropertyEditor>
- {
- public void execute(Event<UIWsrpProducerPropertyEditor> event) throws
Exception
- {
- UIWsrpProducerPropertyEditor source = event.getSource();
- source.save(event.getRequestContext());
- UIPopupWindow popup = source.getParent();
- popup.setRendered(false);
- popup.setShow(false);
- }
- }
-
- public boolean save(WebuiRequestContext context) throws Exception
- {
-
- ProducerConfigurationService pconfService = getProducerConfigurationService();
- ProducerConfiguration producerConfiguration = pconfService.getConfiguration();
-
-
- RegistrationPropertyDescription regPropDesc =
getRegistrationPropertyDescription();
- if (regPropDesc != null)
- {
- System.out.println("---------old1: " + regPropDesc.getDescription());
- RegistrationPropertyDescription oldRegPropDesc =
producerConfiguration.getRegistrationRequirements().getRegistrationProperties().get(regPropDesc);
- invokeSetBindingBean(oldRegPropDesc);
- System.out.println("---------new1: " +
oldRegPropDesc.getNameAsString());
- //return;
- }
- else
- {
-
- RegistrationPropertyDescription newRegProcDesc = new
RegistrationPropertyDescription();
- newRegProcDesc.setDescription(new
LocalizedString(getUIStringInput(DESCRIPTION).getValue()));
- newRegProcDesc.setDescription(new
LocalizedString(getUIStringInput(LABEL).getValue()));
- newRegProcDesc.setDescription(new
LocalizedString(getUIStringInput(HINT).getValue()));
- System.out.println("---------new2: " + newRegProcDesc);
-
producerConfiguration.getRegistrationRequirements().addRegistrationProperty(newRegProcDesc);
- }
-
- UIApplication uiApp = context.getUIApplication();
-
- try
- {
- pconfService.saveConfiguration();
- uiApp.addMessage(new ApplicationMessage("Producer Successfully
Changed", null));
- }
- catch (Exception e)
- {
- uiApp.addMessage(new ApplicationMessage("Producer Modification Error",
null));
-
- }
-
- return true;
- }
-
- public ProducerConfigurationService getProducerConfigurationService() throws
Exception
- {
- ExoContainer manager = ExoContainerContext.getCurrentContainer();
- return
(ProducerConfigurationService)manager.getComponentInstanceOfType(ProducerConfigurationService.class);
- }
-}
Deleted:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpRegistrationDetails.java
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpRegistrationDetails.java 2010-01-19
16:55:52 UTC (rev 1382)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpRegistrationDetails.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -1,324 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
- * contributors as indicated by the @authors tag. See the
- * copyright.txt in the distribution for a full listing of
- * individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-
-package org.exoplatform.wsrp.webui.component;
-
-import org.exoplatform.commons.utils.LazyPageList;
-import org.exoplatform.commons.utils.ListAccess;
-import org.exoplatform.portal.webui.util.Util;
-import org.exoplatform.web.application.ApplicationMessage;
-import org.exoplatform.webui.application.WebuiRequestContext;
-import org.exoplatform.webui.config.annotation.ComponentConfig;
-import org.exoplatform.webui.config.annotation.ComponentConfigs;
-import org.exoplatform.webui.config.annotation.EventConfig;
-import org.exoplatform.webui.core.UIApplication;
-import org.exoplatform.webui.core.UIComponent;
-import org.exoplatform.webui.core.UIGrid;
-import org.exoplatform.webui.core.UIPopupWindow;
-import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
-import org.exoplatform.webui.core.renderers.ValueRenderer;
-import org.exoplatform.webui.event.Event;
-import org.exoplatform.webui.event.EventListener;
-import org.exoplatform.webui.form.UIForm;
-import org.exoplatform.webui.form.UIFormInputBase;
-import org.exoplatform.webui.form.UIFormInputSet;
-import org.exoplatform.webui.form.UIFormStringInput;
-import org.gatein.registration.RegistrationPolicy;
-import org.gatein.registration.policies.DefaultRegistrationPolicy;
-import org.gatein.wsrp.producer.config.ProducerConfigurationService;
-import org.gatein.wsrp.producer.config.ProducerRegistrationRequirements;
-import org.gatein.wsrp.registration.LocalizedString;
-import org.gatein.wsrp.registration.RegistrationPropertyDescription;
-
-import javax.xml.namespace.QName;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-@ComponentConfigs({
- @ComponentConfig(id = UIWsrpRegistrationDetails.REGISTRATION_PROPERTIES, type =
UIGrid.class, template = "system:/groovy/webui/core/UIGrid.gtmpl"),
- @ComponentConfig(
- lifecycle = UIContainerLifecycle.class,
- events = {
- @EventConfig(listeners =
UIWsrpRegistrationDetails.AddPropertyActionListener.class),
- @EventConfig(listeners =
UIWsrpRegistrationDetails.EditPropertyActionListener.class),
- @EventConfig(listeners =
UIWsrpRegistrationDetails.DeletePropertyActionListener.class)
- })
-})
-public class UIWsrpRegistrationDetails extends UIFormInputSet
-{
- private UIFormInputBase<String> policy;
- private UIFormInputBase<String> validator;
- private UIGrid registrationProperties;
- private static final String NAME = "name";
- static String[] FIELDS = {NAME, "description", "label",
"hint"};
-// static String[] PROPERTIES_ACTIONS = {"EditProperty",
"DeleteProperty"};
- static String[] PROPERTIES_ACTIONS = {};
- static final String POLICY_CLASS = "policyClassName";
- static final String VALIDATOR_CLASS = "validatorClassName";
- static final String REGISTRATION_PROPERTIES = "registrationproperties";
- static final String REGISTRATION_PROPERTIES_ITERATOR =
"registrationpropertiesiterator";
-
- public UIWsrpRegistrationDetails() throws Exception
- {
- //super(name);
-
- // policy
- policy = new UIFormStringInput(POLICY_CLASS, POLICY_CLASS, null);
- addUIFormInput(policy);
-
- // validator
- validator = new UIFormStringInput(VALIDATOR_CLASS, VALIDATOR_CLASS, null);
- addUIFormInput(validator);
-
- // registration properties
- registrationProperties = addChild(UIGrid.class, REGISTRATION_PROPERTIES,
REGISTRATION_PROPERTIES);
-
- // add renderer for LocalizedString
- ValueRenderer<LocalizedString> renderer = new
ValueRenderer<LocalizedString>()
- {
- @Override
- public String render(LocalizedString value)
- {
- return value.getValue();
- }
- };
- registrationProperties.registerRendererFor(renderer, LocalizedString.class);
-
- //configure the edit and delete buttons based on an id from the data list - this
will also be passed as param to listener
- registrationProperties.configure(NAME, FIELDS, PROPERTIES_ACTIONS);
-
registrationProperties.getUIPageIterator().setId(REGISTRATION_PROPERTIES_ITERATOR);
- registrationProperties.getUIPageIterator().setRendered(false);
- addChild(registrationProperties.getUIPageIterator());
-
- init(getService().getConfiguration().getRegistrationRequirements());
-
- //add the popup for property edit and adding new properties
- UIPopupWindow popup = addChild(UIPopupWindow.class, null, null);
- popup.setWindowSize(400, 300);
- UIWsrpProducerPropertyEditor propertyForm =
createUIComponent(UIWsrpProducerPropertyEditor.class, null, "Producer Property
Editor");
- popup.setUIComponent(propertyForm);
- popup.setRendered(false);
- }
-
- void init(ProducerRegistrationRequirements registrationRequirements) throws Exception
- {
- RegistrationPolicy policy = registrationRequirements.getPolicy();
- String policyClassName = policy.getClass().getName();
- this.policy.setValue(policyClassName);
-
- // if policy is the default one, display information about the validator
- if
(ProducerRegistrationRequirements.DEFAULT_POLICY_CLASS_NAME.equals(policyClassName))
- {
- DefaultRegistrationPolicy defaultPolicy = (DefaultRegistrationPolicy)policy;
- validator.setValue(defaultPolicy.getValidator().getClass().getName());
- validator.setRendered(true);
- }
- else
- {
- validator.setRendered(false);
- }
-
- // registration properties
- Map<QName, RegistrationPropertyDescription> regProps =
registrationRequirements.getRegistrationProperties();
-
registrationProperties.getUIPageIterator().setPageList(createPageList(getPropertyList(regProps)));
- }
-
- ProducerConfigurationService getService()
- {
- return
Util.getUIPortalApplication().getApplicationComponent(ProducerConfigurationService.class);
- }
-
- private List<RegistrationPropertyDescription> getPropertyList(Map<QName,
RegistrationPropertyDescription> descriptions) throws Exception
- {
- Comparator<RegistrationPropertyDescription> descComparator = new
Comparator<RegistrationPropertyDescription>()
- {
- public int compare(RegistrationPropertyDescription o1,
RegistrationPropertyDescription o2)
- {
- return o1.getName().toString().compareTo(o2.getName().toString());
- }
- };
-
- List<RegistrationPropertyDescription> result = new
ArrayList<RegistrationPropertyDescription>(descriptions.values());
- Collections.sort(result, descComparator);
- return result;
- }
-
- private LazyPageList<RegistrationPropertyDescription> createPageList(final
List<RegistrationPropertyDescription> pageList)
- {
- return new LazyPageList<RegistrationPropertyDescription>(new
ListAccess<RegistrationPropertyDescription>()
- {
-
- public int getSize() throws Exception
- {
- return pageList.size();
- }
-
- public RegistrationPropertyDescription[] load(int index, int length) throws
Exception, IllegalArgumentException
- {
- RegistrationPropertyDescription[] pcs = new
RegistrationPropertyDescription[pageList.size()];
-
- if (index < 0)
- {
- throw new IllegalArgumentException("Illegal index: index must be a
positive number");
- }
-
- if (length < 0)
- {
- throw new IllegalArgumentException("Illegal length: length must be a
positive number");
- }
-
- if (index + length > pageList.size())
- {
- throw new IllegalArgumentException(
- "Illegal index or length: sum of the index and the length cannot
be greater than the list size");
- }
-
- for (int i = 0; i < length; i++)
- {
- pcs[i] = pageList.get(i + index);
- }
-
- return pcs;
- }
-
- }, 10);
- }
-
- @Override
- public void processRender(WebuiRequestContext context) throws Exception
- {
- /*if (getComponentConfig() != null)
- {
- super.processRender(context);
- return;
- }*/
-
- Writer w = context.getWriter();
- w.write("<div class=\"UIFormInputSet\">");
-
- ResourceBundle res = context.getApplicationResourceBundle();
- UIForm uiForm = getAncestorOfType(UIForm.class);
- for (UIComponent inputEntry : getChildren())
- {
- if (inputEntry.isRendered())
- {
- w.write("<div class=\"row\">");
-
- String label;
- try
- {
- label = uiForm.getLabel(res, inputEntry.getId());
- }
- catch (MissingResourceException ex)
- {
- label = inputEntry.getName();
- System.err.println("\n " + uiForm.getId() + ".label."
+ inputEntry.getId() + " not found value");
- }
-
- w.write("<label>" + label + "</label>");
- renderUIComponent(inputEntry);
-
- w.write("</div>");
- }
- }
- w.write("</div>");
- }
-
- public void updateRegistrationDetailsFromForm(ProducerRegistrationRequirements
registrationRequirements)
- {
- registrationRequirements.reloadPolicyFrom(policy.getValue(),
validator.getValue());
- }
-
- static public class EditPropertyActionListener extends
EventListener<UIWsrpRegistrationDetails>
- {
- public void execute(Event<UIWsrpRegistrationDetails> event) throws Exception
- {
- UIWsrpRegistrationDetails source = event.getSource();
- UIPopupWindow popup = source.getChild(UIPopupWindow.class);
- UIWsrpProducerPropertyEditor editor =
(UIWsrpProducerPropertyEditor)popup.getUIComponent();
- String id = event.getRequestContext().getRequestParameter(OBJECTID);
- try
- {
-
editor.setRegistrationPropertyDescription(source.getService().getConfiguration().getRegistrationRequirements().getRegistrationPropertyWith(id));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- popup.setUIComponent(editor);
- popup.setRendered(true);
- popup.setShow(true);
-
- }
- }
-
- static public class DeletePropertyActionListener extends
EventListener<UIWsrpRegistrationDetails>
- {
- public void execute(Event<UIWsrpRegistrationDetails> event)
- {
- UIWsrpRegistrationDetails source = event.getSource();
- String id = event.getRequestContext().getRequestParameter(OBJECTID);
- try
- {
- ProducerConfigurationService service = source.getService();
-
service.getConfiguration().getRegistrationRequirements().removeRegistrationProperty(id);
- service.saveConfiguration();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- UIApplication uiApp = event.getRequestContext().getUIApplication();
- uiApp.addMessage(new ApplicationMessage("Failed to delete Producer
Property. Cause: " + e.getCause(), null, ApplicationMessage.ERROR));
- }
-
- }
- }
-
- static public class AddPropertyActionListener extends
EventListener<UIWsrpRegistrationDetails>
- {
- public void execute(Event<UIWsrpRegistrationDetails> event) throws Exception
- {
- UIWsrpRegistrationDetails source = event.getSource();
- UIPopupWindow popup = source.getChild(UIPopupWindow.class);
- UIWsrpProducerPropertyEditor editor =
(UIWsrpProducerPropertyEditor)popup.getUIComponent();
-
- //reset the form
- editor.setRegistrationPropertyDescription(null);
- popup.setRendered(true);
- popup.setShow(true);
- popup.setShowCloseButton(true);
- //popup.setShowMask(true);
-
- }
- }
-}
Copied:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/ConsumerController.java
(from rev 1378,
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/ConsumerController.java)
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/ConsumerController.java
(rev 0)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/ConsumerController.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.wsrp.webui.component.consumer;
+
+import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.wsrp.WSRPConsumer;
+import org.gatein.wsrp.consumer.RefreshResult;
+import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
+
+import java.util.List;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ConsumerController
+{
+ private ConsumerRegistry registry;
+
+ public ConsumerController(ConsumerRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public ConsumerRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ public WSRPConsumer getConsumer(String id)
+ {
+ return registry.getConsumer(id);
+ }
+
+ public List<WSRPConsumer> getConfiguredConsumers()
+ {
+ return registry.getConfiguredConsumers();
+ }
+
+ public RefreshResult refreshConsumer(WSRPConsumer consumer) throws
PortletInvokerException
+ {
+ RefreshResult result = consumer.refresh(true);
+
+ if (result.hasIssues())
+ {
+ // refresh had issues, we should deactivate this consumer
+ registry.deactivateConsumerWith(consumer.getProducerId());
+ }
+ else
+ {
+ // activate the consumer if it's supposed to be active
+ if (consumer.isActive())
+ {
+ registry.activateConsumerWith(consumer.getProducerId());
+ }
+ else
+ {
+ registry.deactivateConsumerWith(consumer.getProducerId());
+ }
+ }
+
+ return result;
+ }
+}
Copied:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/UIWsrpConsumerEditor.java
(from rev 1378,
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerEditor.java)
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/UIWsrpConsumerEditor.java
(rev 0)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/UIWsrpConsumerEditor.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -0,0 +1,222 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2009, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.wsrp.webui.component.consumer;
+
+import org.exoplatform.commons.utils.LazyPageList;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.core.UIApplication;
+import org.exoplatform.webui.core.UIGrid;
+import org.exoplatform.webui.core.UIPopupWindow;
+import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.webui.form.UIForm;
+import org.exoplatform.webui.form.UIFormInputBase;
+import org.exoplatform.webui.form.UIFormStringInput;
+import org.exoplatform.webui.form.validator.MandatoryValidator;
+import org.gatein.common.util.ParameterValidation;
+import org.gatein.wsrp.WSRPConsumer;
+import org.gatein.wsrp.consumer.ConsumerException;
+import org.gatein.wsrp.consumer.ProducerInfo;
+import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
+import org.gatein.wsrp.services.ManageableServiceFactory;
+
+/** @author Wesley Hales */
+@ComponentConfig(template =
"app:/groovy/wsrp/webui/component/UIWsrpConsumerEditor.gtmpl", lifecycle =
UIFormLifecycle.class, events = {
+ @EventConfig(listeners = UIWsrpConsumerEditor.SaveActionListener.class)})
+public class UIWsrpConsumerEditor extends UIForm
+{
+ protected static final String CONSUMER_NAME = "Consumer name: ";
+ protected static final String CACHE_EXPIRATION = "Seconds before cache
expiration: ";
+ protected static final String TIMEOUT = "Milliseconds before timeout: ";
+ protected static final String WSDL_URL = "WSDL URL: ";
+ private UIFormInputBase<String> consumerName;
+ private UIFormStringInput cache;
+ private UIFormStringInput timeoutWS;
+ private UIFormStringInput wsdl;
+
+ public UIWsrpConsumerEditor() throws Exception
+ {
+
+ consumerName = new UIFormStringInput(CONSUMER_NAME, CONSUMER_NAME,
null).addValidator(MandatoryValidator.class);
+ addUIFormInput(consumerName);
+ cache = new UIFormStringInput(CACHE_EXPIRATION, CACHE_EXPIRATION, null);
+ addUIFormInput(cache);
+ timeoutWS = new UIFormStringInput(TIMEOUT, TIMEOUT, null);
+ addUIFormInput(timeoutWS);
+ wsdl = new UIFormStringInput(WSDL_URL, WSDL_URL, null);
+ addUIFormInput(wsdl);
+ }
+
+ private String getConsumerName()
+ {
+ return consumerName.getValue();
+ }
+
+ private Integer getCacheExpiration()
+ {
+ Integer cacheExp = 0;
+ String cacheExpString = cache.getValue();
+ if (cacheExpString != null)
+ {
+ cacheExp = Integer.parseInt(cacheExpString);
+ }
+ return cacheExp;
+ }
+
+ private Integer getTimeout()
+ {
+ int timeout = ManageableServiceFactory.DEFAULT_TIMEOUT_MS;
+ String timeoutString = timeoutWS.getValue();
+ if (!ParameterValidation.isNullOrEmpty(timeoutString))
+ {
+ timeout = Integer.parseInt(timeoutString);
+ }
+
+ return timeout;
+ }
+
+ private String getWSDLURL()
+ {
+ return wsdl.getValue();
+ }
+
+ private Boolean newConsumer;
+
+ public Boolean isNewConsumer()
+ {
+ return newConsumer;
+ }
+
+ public void setNewConsumer(Boolean newConsumer)
+ {
+ this.newConsumer = newConsumer;
+ }
+
+ public void setConsumer(WSRPConsumer consumer)
+ {
+ if (consumer == null)
+ {
+ consumerName.setEditable(UIFormStringInput.ENABLE);
+ setNewConsumer(true);
+ return;
+ }
+ consumerName.setEditable(UIFormStringInput.ENABLE);
+
+ consumerName.setValue(consumer.getProducerId());
+ ProducerInfo producerInfo = consumer.getProducerInfo();
+ cache.setValue(producerInfo.getExpirationCacheSeconds().toString());
+ timeoutWS.setValue("" +
producerInfo.getEndpointConfigurationInfo().getWSOperationTimeOut());
+ wsdl.setValue(producerInfo.getEndpointConfigurationInfo().getWsdlDefinitionURL());
+ setNewConsumer(false);
+ }
+
+ static public class SaveActionListener 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();
+ if (consumerEditor.isNewConsumer())
+ {
+ consumerEditor.save(ctx);
+ }
+ else
+ {
+ consumerEditor.edit(ctx);
+ }
+
+ consumerEditor.reset();
+
+ UIPopupWindow popup = consumerEditor.getParent();
+ popup.setRendered(false);
+ popup.setShow(false);
+
+ //temp way to refresh list, should call broadcast event (below)
+ LazyPageList pageList =
consumerOverview.createPageList(consumerOverview.getConfiguredConsumers());
+ UIGrid uiGrid = consumerOverview.getChild(UIGrid.class);
+ uiGrid.getUIPageIterator().setPageList(pageList);
+ //uiGrid.configure()
+ //try to broadcast an event back to consumerOverview to refresh grid... works
but shows error
+ //PortalRequestContext portalContext =
org.exoplatform.portal.webui.util.Util.getPortalRequestContext();
+ //Event<UIWsrpConsumerOverview> pnevent = new
Event<UIWsrpConsumerOverview>(consumerOverview, "RefreshGrid",
portalContext);
+ //consumerOverview.broadcast(pnevent, Event.Phase.PROCESS);
+
+ ctx.addUIComponentToUpdateByAjax(consumerOverview);
+ }
+ }
+
+ public boolean save(WebuiRequestContext context) throws Exception
+ {
+ ExoContainer manager = ExoContainerContext.getCurrentContainer();
+ ConsumerRegistry consumerRegistry =
(ConsumerRegistry)manager.getComponentInstanceOfType(ConsumerRegistry.class);
+
+ UIApplication uiApp = context.getUIApplication();
+
+ try
+ {
+ consumerRegistry.createConsumer(getConsumerName(), getCacheExpiration(),
getWSDLURL());
+ uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.action.add.success", null));
+ }
+ catch (ConsumerException ce)
+ {
+ //todo - add to resource bundle
+ uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.action.add.exists", null,
ApplicationMessage.ERROR));
+ }
+ return true;
+ }
+
+ public boolean edit(WebuiRequestContext context) throws Exception
+ {
+ ExoContainer manager = ExoContainerContext.getCurrentContainer();
+ ConsumerRegistry consumerRegistry =
(ConsumerRegistry)manager.getComponentInstanceOfType(ConsumerRegistry.class);
+ ProducerInfo producerInfo =
consumerRegistry.getConsumer(getConsumerName()).getProducerInfo();
+
+ producerInfo.setId(getConsumerName());
+ producerInfo.setExpirationCacheSeconds(getCacheExpiration());
+ producerInfo.getEndpointConfigurationInfo().setWsdlDefinitionURL(getWSDLURL());
+ producerInfo.getEndpointConfigurationInfo().setWSOperationTimeOut(getTimeout());
+
+ UIApplication uiApp = context.getUIApplication();
+
+ try
+ {
+ consumerRegistry.updateProducerInfo(producerInfo);
+ uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.action.edit.success", null));
+ }
+ catch (ConsumerException ce)
+ {
+ uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.action.edit.fail", null,
ApplicationMessage.ERROR));
+ }
+ return true;
+ }
+
+}
Copied:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/UIWsrpConsumerOverview.java
(from rev 1379,
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpConsumerOverview.java)
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/UIWsrpConsumerOverview.java
(rev 0)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/consumer/UIWsrpConsumerOverview.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -0,0 +1,323 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.wsrp.webui.component.consumer;
+
+import org.exoplatform.commons.utils.LazyPageList;
+import org.exoplatform.commons.utils.ListAccess;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.core.UIApplication;
+import org.exoplatform.webui.core.UIContainer;
+import org.exoplatform.webui.core.UIGrid;
+import org.exoplatform.webui.core.UIPageIterator;
+import org.exoplatform.webui.core.UIPopupWindow;
+import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+import org.gatein.wsrp.WSRPConsumer;
+import org.gatein.wsrp.consumer.RefreshResult;
+import org.gatein.wsrp.consumer.registry.ConsumerRegistry;
+
+import java.util.List;
+
+/** @author Wesley Hales */
+
+@ComponentConfig(
+ lifecycle = UIApplicationLifecycle.class,
+ template = "app:/groovy/wsrp/webui/component/UIWsrpConsumerOverview.gtmpl",
+ events = {
+ @EventConfig(listeners =
UIWsrpConsumerOverview.CreateConsumerActionListener.class),
+ @EventConfig(listeners = UIWsrpConsumerOverview.EditActionListener.class),
+ @EventConfig(listeners = UIWsrpConsumerOverview.DeleteActionListener.class),
+ @EventConfig(listeners = UIWsrpConsumerOverview.RefreshActionListener.class),
+ @EventConfig(listeners = UIWsrpConsumerOverview.DeactivateActionListener.class),
+ @EventConfig(listeners = UIWsrpConsumerOverview.ActivateActionListener.class),
+ @EventConfig(listeners = UIWsrpConsumerOverview.RefreshGridActionListener.class)
+ })
+public class UIWsrpConsumerOverview extends UIContainer
+{
+ public static String[] FIELDS = {"producerId", "active",
"refreshNeeded"};
+
+ //The action names are also your class names on the ui buttons. You should stick with
common names like:
+ //edit
+ //delete
+ //
+ public static String[] SELECT_ACTIONS = {"Edit", "Delete",
"Refresh", "Activate", "Deactivate"};
+
+ private ConsumerController controller;
+ private UIPopupWindow consumerEditorPopup;
+ private UIPageIterator consumersIterator;
+
+ public List getConfiguredConsumers() throws Exception
+ {
+ return controller.getConfiguredConsumers();
+ }
+
+ public LazyPageList createPageList(final List pageList)
+ {
+ return new LazyPageList<WSRPConsumer>(new ListAccess<WSRPConsumer>()
+ {
+
+ public int getSize() throws Exception
+ {
+ return pageList.size();
+ }
+
+ public WSRPConsumer[] load(int index, int length) throws Exception
+ {
+ WSRPConsumer[] pcs = new WSRPConsumer[pageList.size()];
+
+ if (index < 0)
+ {
+ throw new IllegalArgumentException("Illegal index: index must be a
positive number");
+ }
+
+ if (length < 0)
+ {
+ throw new IllegalArgumentException("Illegal length: length must be a
positive number");
+ }
+
+ if (index + length > pageList.size())
+ {
+ throw new IllegalArgumentException(
+ "Illegal index or length: sum of the index and the length cannot
be greater than the list size");
+ }
+
+ for (int i = 0; i < length; i++)
+ {
+ pcs[i] = (WSRPConsumer)pageList.get(i + index);
+ }
+
+ return pcs;
+ }
+
+ }, 10);
+ }
+
+ public UIWsrpConsumerOverview() throws Exception
+ {
+ // controller
+ ConsumerRegistry registry =
(ConsumerRegistry)ExoContainerContext.getCurrentContainer().getComponentInstanceOfType(ConsumerRegistry.class);
+ controller = new ConsumerController(registry);
+
+ //setSelectedTab(1);
+ consumerEditorPopup = addChild(UIPopupWindow.class, null, null);
+ consumerEditorPopup.setWindowSize(450, 0);
+ UIWsrpConsumerEditor consumerForm = createUIComponent(UIWsrpConsumerEditor.class,
null, "Consumer Editor");
+ consumerEditorPopup.setUIComponent(consumerForm);
+ consumerEditorPopup.setRendered(false);
+
+ UIGrid consumers = addChild(UIGrid.class, null, null);
+ //configure the edit and delete buttons based on an id from the data list - this
will also be passed as param to listener
+ consumers.configure("producerId", FIELDS, SELECT_ACTIONS);
+
+ consumersIterator = consumers.getUIPageIterator();
+ consumersIterator.setId("ChangeConsumerPageIterator");
+ consumersIterator.setRendered(false);
+
+ refreshConsumersList();
+ }
+
+ static public class RefreshGridActionListener extends
EventListener<UIWsrpConsumerOverview>
+ {
+ public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
+ {
+ UIWsrpConsumerOverview consumerOverview = event.getSource();
+ consumerOverview.refreshGrid(event);
+ }
+ }
+
+ public void refreshGrid(Event<UIWsrpConsumerOverview> event) throws Exception
+ {
+ //refresh the list
+ refreshConsumersList();
+
+ event.getRequestContext().addUIComponentToUpdateByAjax(this);
+ }
+
+ private void refreshConsumersList() throws Exception
+ {
+ LazyPageList pageList = createPageList(getConfiguredConsumers());
+ consumersIterator.setPageList(pageList);
+ }
+
+ static public class CreateConsumerActionListener extends
EventListener<UIWsrpConsumerOverview>
+ {
+ public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
+ {
+ UIWsrpConsumerOverview consumerOverview = event.getSource();
+ consumerOverview.displayConsumerEditor(null);
+ }
+ }
+
+ private void displayConsumerEditor(WSRPConsumer consumer) throws Exception
+ {
+ UIWsrpConsumerEditor editor =
(UIWsrpConsumerEditor)consumerEditorPopup.getUIComponent();
+
+ //reset the form
+ editor.reset();
+ editor.setConsumer(consumer);
+ consumerEditorPopup.setRendered(true);
+ consumerEditorPopup.setShow(true);
+ consumerEditorPopup.setShowCloseButton(true);
+ }
+
+ static public class EditActionListener extends
EventListener<UIWsrpConsumerOverview>
+ {
+ public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
+ {
+ UIWsrpConsumerOverview consumerOverview = event.getSource();
+ WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
+
+ if (consumer != null)
+ {
+ consumerOverview.displayConsumerEditor(consumer);
+ }
+ }
+ }
+
+ static public class DeleteActionListener extends
EventListener<UIWsrpConsumerOverview>
+ {
+ public void execute(Event<UIWsrpConsumerOverview> event)
+ {
+ UIApplication uiApp = event.getRequestContext().getUIApplication();
+ try
+ {
+ UIWsrpConsumerOverview consumerOverview = event.getSource();
+ WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
+ ConsumerRegistry consumerRegistry = consumerOverview.getConsumerRegistry();
+ String id = event.getRequestContext().getRequestParameter(OBJECTID);
+ if (consumer != null)
+ {
+ consumerRegistry.destroyConsumer(id);
+ uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.delete.success", null,
ApplicationMessage.INFO));
+ consumerOverview.refreshGrid(event);
+ }
+ }
+ catch (Exception e)
+ {
+ uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.delete.fail", new
String[]{e.getCause().toString()}, ApplicationMessage.ERROR));
+ }
+
+ }
+ }
+
+ static public class DeactivateActionListener extends
EventListener<UIWsrpConsumerOverview>
+ {
+ public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
+ {
+ UIWsrpConsumerOverview consumerOverview = event.getSource();
+ WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
+ UIApplication uiApp = event.getRequestContext().getUIApplication();
+
+ if (consumer != null)
+ {
+ if (consumer.isActive())
+ {
+ ConsumerRegistry registry = consumerOverview.getConsumerRegistry();
+ registry.deactivateConsumerWith(consumer.getProducerId());
+ uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.deactivate.success", null));
+ consumerOverview.refreshGrid(event);
+ }
+ else
+ {
+ uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.deactivate.fail", null));
+ }
+ }
+ }
+ }
+
+ static public class ActivateActionListener extends
EventListener<UIWsrpConsumerOverview>
+ {
+ public void execute(Event<UIWsrpConsumerOverview> event) throws Exception
+ {
+ UIWsrpConsumerOverview consumerOverview = event.getSource();
+ WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
+ UIApplication uiApp = event.getRequestContext().getUIApplication();
+
+ if (consumer != null && !consumer.isActive())
+ {
+ try
+ {
+ ConsumerRegistry registry = consumerOverview.getConsumerRegistry();
+ registry.activateConsumerWith(consumer.getProducerId());
+ uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.activate.success", null));
+ consumerOverview.refreshGrid(event);
+ }
+ catch (Exception e)
+ {
+ uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.activate.fail", new
String[]{e.getCause().toString()}, ApplicationMessage.ERROR));
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ static public class RefreshActionListener extends
EventListener<UIWsrpConsumerOverview>
+ {
+ public void execute(Event<UIWsrpConsumerOverview> event)
+ {
+ UIApplication uiApp = event.getRequestContext().getUIApplication();
+ try
+ {
+ UIWsrpConsumerOverview consumerOverview = event.getSource();
+ WSRPConsumer consumer = consumerOverview.getConsumerFromEvent(event);
+
+ if (consumer != null)
+ {
+ RefreshResult result =
consumerOverview.controller.refreshConsumer(consumer);
+
+ if (result.hasIssues())
+ {
+ consumerOverview.displayConsumerEditor(consumer);
+ }
+ else
+ {
+ uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.refresh.success", null,
ApplicationMessage.INFO));
+ }
+
+ // refresh consumers
+ consumerOverview.refreshGrid(event);
+ }
+ }
+ catch (Exception e)
+ {
+ uiApp.addMessage(new
ApplicationMessage("UIWsrp.consumer.grid.action.refresh.fail", new
String[]{e.getCause().toString()}, ApplicationMessage.ERROR));
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public WSRPConsumer getConsumerFromEvent(Event<?> event) throws Exception
+ {
+ String id = event.getRequestContext().getRequestParameter(OBJECTID);
+ return controller.getConsumer(id);
+ }
+
+ public ConsumerRegistry getConsumerRegistry() throws Exception
+ {
+ return controller.getRegistry();
+ }
+}
Copied:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpProducerEditor.java
(from rev 1378,
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerEditor.java)
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpProducerEditor.java
(rev 0)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpProducerEditor.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -0,0 +1,177 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.wsrp.webui.component.producer;
+
+import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.core.UIApplication;
+import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.webui.form.UIForm;
+import org.exoplatform.webui.form.UIFormCheckBoxInput;
+import org.gatein.wsrp.producer.config.ProducerConfiguration;
+import org.gatein.wsrp.producer.config.ProducerConfigurationService;
+import org.gatein.wsrp.producer.config.ProducerRegistrationRequirements;
+
+/**
+ * @author Wesley Hales
+ * @author Chris Laprun
+ */
+@ComponentConfig(
+ lifecycle = UIFormLifecycle.class,
+ template = "app:/groovy/wsrp/webui/component/UIWsrpProducerEditor.gtmpl",
+ events = {
+ @EventConfig(listeners = UIWsrpProducerEditor.SaveActionListener.class),
+ @EventConfig(listeners =
UIWsrpProducerEditor.RegistrationOnChangeActionListener.class)
+ }
+)
+public class UIWsrpProducerEditor extends UIForm
+{
+ private static final String REG_REQUIRED_FOR_DESCRIPTION =
"registrationrequiredforfulldescription";
+ private static final String STRICT_MODE = "strictmode";
+ private static final String REQUIRES_REGISTRATION = "requiresregistration";
+ private static final String REGISTRATION_DETAILS = "registrationdetails";
+
+ private ProducerConfigurationService configService;
+ private UIWsrpRegistrationDetails registrationDetails;
+ private UIFormCheckBoxInput regReqForDesc;
+ private UIFormCheckBoxInput strictMode;
+ private UIFormCheckBoxInput<Boolean> regRequired;
+
+ public UIWsrpProducerEditor() throws Exception
+ {
+ configService =
Util.getUIPortalApplication().getApplicationComponent(ProducerConfigurationService.class);
+
+ regReqForDesc = new UIFormCheckBoxInput(REG_REQUIRED_FOR_DESCRIPTION,
REG_REQUIRED_FOR_DESCRIPTION, null);
+ addUIFormInput(regReqForDesc);
+ strictMode = new UIFormCheckBoxInput(STRICT_MODE, STRICT_MODE, null);
+ addUIFormInput(strictMode);
+
+ // registration required check box with onChange event
+ regRequired = new UIFormCheckBoxInput<Boolean>(REQUIRES_REGISTRATION,
REQUIRES_REGISTRATION, null);
+ regRequired.setOnChange("RegistrationOnChange");
+ addUIFormInput(regRequired);
+ // because when we use setOnChange method, new eventListener will add to this form,
we must re-set the actions of this form.
+ // thif form has no action, so i'll put empty string array
+ setActions(new String[]{});
+
+ // registration details
+ // form set to gather registration information
+ registrationDetails = addChild(UIWsrpRegistrationDetails.class, null,
REGISTRATION_DETAILS);
+
+ init(false);
+ }
+
+ ProducerConfigurationService getService()
+ {
+ return configService;
+ }
+
+ private void init(boolean getRegistrationRequiredFromCheckBox) throws Exception
+ {
+ ProducerConfiguration configuration = configService.getConfiguration();
+
+ ProducerRegistrationRequirements registrationRequirements =
configuration.getRegistrationRequirements();
+
regReqForDesc.setValue(registrationRequirements.isRegistrationRequiredForFullDescription());
+ strictMode.setValue(configuration.isUsingStrictMode());
+
+ boolean registrationRequired = getRegistrationRequiredFromCheckBox ?
+ regRequired.getValue() :
+ registrationRequirements.isRegistrationRequired();
+ regRequired.setValue(registrationRequired);
+
+ // if registration is required then we display more information
+ if (registrationRequired)
+ {
+ registrationDetails.init(registrationRequirements);
+ registrationDetails.setRendered(true);
+ }
+ else
+ {
+ registrationDetails.setRendered(false);
+ }
+ }
+
+
+ static public class SaveActionListener extends
EventListener<UIWsrpProducerEditor>
+ {
+ public void execute(Event<UIWsrpProducerEditor> event) throws Exception
+ {
+ UIWsrpProducerEditor source = event.getSource();
+ ProducerConfigurationService service = source.getService();
+ ProducerConfiguration producerConfiguration = service.getConfiguration();
+ ProducerRegistrationRequirements registrationRequirements =
producerConfiguration.getRegistrationRequirements();
+
registrationRequirements.setRegistrationRequiredForFullDescription(Boolean.parseBoolean(source.regReqForDesc.getValue().toString()));
+
producerConfiguration.setUsingStrictMode(Boolean.parseBoolean(source.strictMode.getValue().toString()));
+
+ boolean requiresReg =
Boolean.parseBoolean(source.regRequired.getValue().toString());
+ registrationRequirements.setRegistrationRequired(requiresReg);
+ if (requiresReg)
+ {
+
source.registrationDetails.updateRegistrationDetailsFromForm(registrationRequirements);
+ }
+
+ try
+ {
+ service.saveConfiguration();
+ }
+ catch (Exception e)
+ {
+ UIApplication uiApp = event.getRequestContext().getUIApplication();
+ uiApp.addMessage(new ApplicationMessage("Producer Modification
Error", null, ApplicationMessage.ERROR));
+ e.printStackTrace();
+ }
+
+ source.init(false);
+ }
+ }
+
+ /*public static class RegistrationOnChangeActionListener extends
EventListener<UIFormCheckBoxInput>
+ {
+ public void execute(Event<UIFormCheckBoxInput> event) throws Exception
+ {
+ UIFormCheckBoxInput source = event.getSource();
+ UIWsrpProducerEditor parent =
source.getAncestorOfType(UIWsrpProducerEditor.class);
+ parent.init();
+
+ //update only the parent, avoid updating the full portlet
+ event.getRequestContext().addUIComponentToUpdateByAjax(parent);
+ }
+ }*/
+
+ public static class RegistrationOnChangeActionListener extends
EventListener<UIWsrpProducerEditor>
+ {
+ public void execute(Event<UIWsrpProducerEditor> event) throws Exception
+ {
+ UIWsrpProducerEditor source = event.getSource();
+ source.init(true);
+
+ //update only the parent, avoid updating the full portlet
+ event.getRequestContext().addUIComponentToUpdateByAjax(source);
+ }
+ }
+
+}
Copied:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpProducerOverview.java
(from rev 1378,
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerOverview.java)
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpProducerOverview.java
(rev 0)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpProducerOverview.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.wsrp.webui.component.producer;
+
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.core.UIContainer;
+import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle;
+
+/**
+ * @author Wesley Hales
+ * @author Chris Laprun
+ */
+@ComponentConfig(
+ lifecycle = UIApplicationLifecycle.class,
+ template = "app:/groovy/wsrp/webui/component/UIWsrpProducerOverview.gtmpl"
+)
+public class UIWsrpProducerOverview extends UIContainer
+{
+ private UIWsrpProducerEditor producerForm;
+
+ public UIWsrpProducerOverview() throws Exception
+ {
+ producerForm = createUIComponent(UIWsrpProducerEditor.class, null, "Producer
Editor");
+ addChild(producerForm);
+ }
+}
Copied:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpProducerPropertyEditor.java
(from rev 1378,
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpProducerPropertyEditor.java)
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpProducerPropertyEditor.java
(rev 0)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpProducerPropertyEditor.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -0,0 +1,145 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.exoplatform.wsrp.webui.component.producer;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.core.UIApplication;
+import org.exoplatform.webui.core.UIPopupWindow;
+import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.webui.form.UIForm;
+import org.exoplatform.webui.form.UIFormStringInput;
+import org.exoplatform.webui.form.validator.MandatoryValidator;
+import org.gatein.wsrp.producer.config.ProducerConfiguration;
+import org.gatein.wsrp.producer.config.ProducerConfigurationService;
+import org.gatein.wsrp.registration.LocalizedString;
+import org.gatein.wsrp.registration.RegistrationPropertyDescription;
+
+
+/** @author Wesley Hales */
+@ComponentConfig(template =
"app:/groovy/wsrp/webui/component/UIWsrpProducerPropertyEditor.gtmpl", lifecycle
= UIFormLifecycle.class,
+ events = {
+ @EventConfig(listeners = UIWsrpProducerPropertyEditor.SaveActionListener.class)})
+public class UIWsrpProducerPropertyEditor extends UIForm
+{
+ protected static final String DESCRIPTION = "description";
+ protected static final String LABEL = "label";
+ protected static final String HINT = "hint";
+ private RegistrationPropertyDescription registrationPropertyDescription_;
+
+ public UIWsrpProducerPropertyEditor() throws Exception
+ {
+ addUIFormInput(new UIFormStringInput(DESCRIPTION, DESCRIPTION,
null).addValidator(MandatoryValidator.class));
+ addUIFormInput(new UIFormStringInput(LABEL, LABEL,
null).addValidator(MandatoryValidator.class));
+ addUIFormInput(new UIFormStringInput(HINT, HINT,
null).addValidator(MandatoryValidator.class));
+ }
+
+ public void setRegistrationPropertyDescription(RegistrationPropertyDescription
registrationPropertyDescription) throws Exception
+ {
+
+ this.registrationPropertyDescription_ = registrationPropertyDescription;
+
+ if (registrationPropertyDescription_ == null)
+ {
+ getUIStringInput(DESCRIPTION).setEditable(UIFormStringInput.ENABLE);
+ reset();
+ return;
+ }
+ getUIStringInput(DESCRIPTION).setEditable(UIFormStringInput.ENABLE);
+
+ invokeGetBindingBean(registrationPropertyDescription_);
+
+ }
+
+ public RegistrationPropertyDescription getRegistrationPropertyDescription()
+ {
+ return registrationPropertyDescription_;
+ }
+
+ static public class SaveActionListener extends
EventListener<UIWsrpProducerPropertyEditor>
+ {
+ public void execute(Event<UIWsrpProducerPropertyEditor> event) throws
Exception
+ {
+ UIWsrpProducerPropertyEditor source = event.getSource();
+ source.save(event.getRequestContext());
+ UIPopupWindow popup = source.getParent();
+ popup.setRendered(false);
+ popup.setShow(false);
+ }
+ }
+
+ public boolean save(WebuiRequestContext context) throws Exception
+ {
+
+ ProducerConfigurationService pconfService = getProducerConfigurationService();
+ ProducerConfiguration producerConfiguration = pconfService.getConfiguration();
+
+
+ RegistrationPropertyDescription regPropDesc =
getRegistrationPropertyDescription();
+ if (regPropDesc != null)
+ {
+ System.out.println("---------old1: " + regPropDesc.getDescription());
+ RegistrationPropertyDescription oldRegPropDesc =
producerConfiguration.getRegistrationRequirements().getRegistrationProperties().get(regPropDesc);
+ invokeSetBindingBean(oldRegPropDesc);
+ System.out.println("---------new1: " +
oldRegPropDesc.getNameAsString());
+ //return;
+ }
+ else
+ {
+
+ RegistrationPropertyDescription newRegProcDesc = new
RegistrationPropertyDescription();
+ newRegProcDesc.setDescription(new
LocalizedString(getUIStringInput(DESCRIPTION).getValue()));
+ newRegProcDesc.setDescription(new
LocalizedString(getUIStringInput(LABEL).getValue()));
+ newRegProcDesc.setDescription(new
LocalizedString(getUIStringInput(HINT).getValue()));
+ System.out.println("---------new2: " + newRegProcDesc);
+
producerConfiguration.getRegistrationRequirements().addRegistrationProperty(newRegProcDesc);
+ }
+
+ UIApplication uiApp = context.getUIApplication();
+
+ try
+ {
+ pconfService.saveConfiguration();
+ uiApp.addMessage(new ApplicationMessage("Producer Successfully
Changed", null));
+ }
+ catch (Exception e)
+ {
+ uiApp.addMessage(new ApplicationMessage("Producer Modification Error",
null));
+
+ }
+
+ return true;
+ }
+
+ public ProducerConfigurationService getProducerConfigurationService() throws
Exception
+ {
+ ExoContainer manager = ExoContainerContext.getCurrentContainer();
+ return
(ProducerConfigurationService)manager.getComponentInstanceOfType(ProducerConfigurationService.class);
+ }
+}
Copied:
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpRegistrationDetails.java
(from rev 1378,
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/UIWsrpRegistrationDetails.java)
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpRegistrationDetails.java
(rev 0)
+++
portal/trunk/portlet/exoadmin/src/main/java/org/exoplatform/wsrp/webui/component/producer/UIWsrpRegistrationDetails.java 2010-01-19
16:58:27 UTC (rev 1383)
@@ -0,0 +1,324 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.wsrp.webui.component.producer;
+
+import org.exoplatform.commons.utils.LazyPageList;
+import org.exoplatform.commons.utils.ListAccess;
+import org.exoplatform.portal.webui.util.Util;
+import org.exoplatform.web.application.ApplicationMessage;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.config.annotation.ComponentConfig;
+import org.exoplatform.webui.config.annotation.ComponentConfigs;
+import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.core.UIApplication;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.core.UIGrid;
+import org.exoplatform.webui.core.UIPopupWindow;
+import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle;
+import org.exoplatform.webui.core.renderers.ValueRenderer;
+import org.exoplatform.webui.event.Event;
+import org.exoplatform.webui.event.EventListener;
+import org.exoplatform.webui.form.UIForm;
+import org.exoplatform.webui.form.UIFormInputBase;
+import org.exoplatform.webui.form.UIFormInputSet;
+import org.exoplatform.webui.form.UIFormStringInput;
+import org.gatein.registration.RegistrationPolicy;
+import org.gatein.registration.policies.DefaultRegistrationPolicy;
+import org.gatein.wsrp.producer.config.ProducerConfigurationService;
+import org.gatein.wsrp.producer.config.ProducerRegistrationRequirements;
+import org.gatein.wsrp.registration.LocalizedString;
+import org.gatein.wsrp.registration.RegistrationPropertyDescription;
+
+import javax.xml.namespace.QName;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+@ComponentConfigs({
+ @ComponentConfig(id = UIWsrpRegistrationDetails.REGISTRATION_PROPERTIES, type =
UIGrid.class, template = "system:/groovy/webui/core/UIGrid.gtmpl"),
+ @ComponentConfig(
+ lifecycle = UIContainerLifecycle.class,
+ events = {
+ @EventConfig(listeners =
UIWsrpRegistrationDetails.AddPropertyActionListener.class),
+ @EventConfig(listeners =
UIWsrpRegistrationDetails.EditPropertyActionListener.class),
+ @EventConfig(listeners =
UIWsrpRegistrationDetails.DeletePropertyActionListener.class)
+ })
+})
+public class UIWsrpRegistrationDetails extends UIFormInputSet
+{
+ private UIFormInputBase<String> policy;
+ private UIFormInputBase<String> validator;
+ private UIGrid registrationProperties;
+ private static final String NAME = "name";
+ static String[] FIELDS = {NAME, "description", "label",
"hint"};
+// static String[] PROPERTIES_ACTIONS = {"EditProperty",
"DeleteProperty"};
+ static String[] PROPERTIES_ACTIONS = {};
+ static final String POLICY_CLASS = "policyClassName";
+ static final String VALIDATOR_CLASS = "validatorClassName";
+ static final String REGISTRATION_PROPERTIES = "registrationproperties";
+ static final String REGISTRATION_PROPERTIES_ITERATOR =
"registrationpropertiesiterator";
+
+ public UIWsrpRegistrationDetails() throws Exception
+ {
+ //super(name);
+
+ // policy
+ policy = new UIFormStringInput(POLICY_CLASS, POLICY_CLASS, null);
+ addUIFormInput(policy);
+
+ // validator
+ validator = new UIFormStringInput(VALIDATOR_CLASS, VALIDATOR_CLASS, null);
+ addUIFormInput(validator);
+
+ // registration properties
+ registrationProperties = addChild(UIGrid.class, REGISTRATION_PROPERTIES,
REGISTRATION_PROPERTIES);
+
+ // add renderer for LocalizedString
+ ValueRenderer<LocalizedString> renderer = new
ValueRenderer<LocalizedString>()
+ {
+ @Override
+ public String render(LocalizedString value)
+ {
+ return value.getValue();
+ }
+ };
+ registrationProperties.registerRendererFor(renderer, LocalizedString.class);
+
+ //configure the edit and delete buttons based on an id from the data list - this
will also be passed as param to listener
+ registrationProperties.configure(NAME, FIELDS, PROPERTIES_ACTIONS);
+
registrationProperties.getUIPageIterator().setId(REGISTRATION_PROPERTIES_ITERATOR);
+ registrationProperties.getUIPageIterator().setRendered(false);
+ addChild(registrationProperties.getUIPageIterator());
+
+ init(getService().getConfiguration().getRegistrationRequirements());
+
+ //add the popup for property edit and adding new properties
+ UIPopupWindow popup = addChild(UIPopupWindow.class, null, null);
+ popup.setWindowSize(400, 300);
+ UIWsrpProducerPropertyEditor propertyForm =
createUIComponent(UIWsrpProducerPropertyEditor.class, null, "Producer Property
Editor");
+ popup.setUIComponent(propertyForm);
+ popup.setRendered(false);
+ }
+
+ void init(ProducerRegistrationRequirements registrationRequirements) throws Exception
+ {
+ RegistrationPolicy policy = registrationRequirements.getPolicy();
+ String policyClassName = policy.getClass().getName();
+ this.policy.setValue(policyClassName);
+
+ // if policy is the default one, display information about the validator
+ if
(ProducerRegistrationRequirements.DEFAULT_POLICY_CLASS_NAME.equals(policyClassName))
+ {
+ DefaultRegistrationPolicy defaultPolicy = (DefaultRegistrationPolicy)policy;
+ validator.setValue(defaultPolicy.getValidator().getClass().getName());
+ validator.setRendered(true);
+ }
+ else
+ {
+ validator.setRendered(false);
+ }
+
+ // registration properties
+ Map<QName, RegistrationPropertyDescription> regProps =
registrationRequirements.getRegistrationProperties();
+
registrationProperties.getUIPageIterator().setPageList(createPageList(getPropertyList(regProps)));
+ }
+
+ ProducerConfigurationService getService()
+ {
+ return
Util.getUIPortalApplication().getApplicationComponent(ProducerConfigurationService.class);
+ }
+
+ private List<RegistrationPropertyDescription> getPropertyList(Map<QName,
RegistrationPropertyDescription> descriptions) throws Exception
+ {
+ Comparator<RegistrationPropertyDescription> descComparator = new
Comparator<RegistrationPropertyDescription>()
+ {
+ public int compare(RegistrationPropertyDescription o1,
RegistrationPropertyDescription o2)
+ {
+ return o1.getName().toString().compareTo(o2.getName().toString());
+ }
+ };
+
+ List<RegistrationPropertyDescription> result = new
ArrayList<RegistrationPropertyDescription>(descriptions.values());
+ Collections.sort(result, descComparator);
+ return result;
+ }
+
+ private LazyPageList<RegistrationPropertyDescription> createPageList(final
List<RegistrationPropertyDescription> pageList)
+ {
+ return new LazyPageList<RegistrationPropertyDescription>(new
ListAccess<RegistrationPropertyDescription>()
+ {
+
+ public int getSize() throws Exception
+ {
+ return pageList.size();
+ }
+
+ public RegistrationPropertyDescription[] load(int index, int length) throws
Exception, IllegalArgumentException
+ {
+ RegistrationPropertyDescription[] pcs = new
RegistrationPropertyDescription[pageList.size()];
+
+ if (index < 0)
+ {
+ throw new IllegalArgumentException("Illegal index: index must be a
positive number");
+ }
+
+ if (length < 0)
+ {
+ throw new IllegalArgumentException("Illegal length: length must be a
positive number");
+ }
+
+ if (index + length > pageList.size())
+ {
+ throw new IllegalArgumentException(
+ "Illegal index or length: sum of the index and the length cannot
be greater than the list size");
+ }
+
+ for (int i = 0; i < length; i++)
+ {
+ pcs[i] = pageList.get(i + index);
+ }
+
+ return pcs;
+ }
+
+ }, 10);
+ }
+
+ @Override
+ public void processRender(WebuiRequestContext context) throws Exception
+ {
+ /*if (getComponentConfig() != null)
+ {
+ super.processRender(context);
+ return;
+ }*/
+
+ Writer w = context.getWriter();
+ w.write("<div class=\"UIFormInputSet\">");
+
+ ResourceBundle res = context.getApplicationResourceBundle();
+ UIForm uiForm = getAncestorOfType(UIForm.class);
+ for (UIComponent inputEntry : getChildren())
+ {
+ if (inputEntry.isRendered())
+ {
+ w.write("<div class=\"row\">");
+
+ String label;
+ try
+ {
+ label = uiForm.getLabel(res, inputEntry.getId());
+ }
+ catch (MissingResourceException ex)
+ {
+ label = inputEntry.getName();
+ System.err.println("\n " + uiForm.getId() + ".label."
+ inputEntry.getId() + " not found value");
+ }
+
+ w.write("<label>" + label + "</label>");
+ renderUIComponent(inputEntry);
+
+ w.write("</div>");
+ }
+ }
+ w.write("</div>");
+ }
+
+ public void updateRegistrationDetailsFromForm(ProducerRegistrationRequirements
registrationRequirements)
+ {
+ registrationRequirements.reloadPolicyFrom(policy.getValue(),
validator.getValue());
+ }
+
+ static public class EditPropertyActionListener extends
EventListener<UIWsrpRegistrationDetails>
+ {
+ public void execute(Event<UIWsrpRegistrationDetails> event) throws Exception
+ {
+ UIWsrpRegistrationDetails source = event.getSource();
+ UIPopupWindow popup = source.getChild(UIPopupWindow.class);
+ UIWsrpProducerPropertyEditor editor =
(UIWsrpProducerPropertyEditor)popup.getUIComponent();
+ String id = event.getRequestContext().getRequestParameter(OBJECTID);
+ try
+ {
+
editor.setRegistrationPropertyDescription(source.getService().getConfiguration().getRegistrationRequirements().getRegistrationPropertyWith(id));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ popup.setUIComponent(editor);
+ popup.setRendered(true);
+ popup.setShow(true);
+
+ }
+ }
+
+ static public class DeletePropertyActionListener extends
EventListener<UIWsrpRegistrationDetails>
+ {
+ public void execute(Event<UIWsrpRegistrationDetails> event)
+ {
+ UIWsrpRegistrationDetails source = event.getSource();
+ String id = event.getRequestContext().getRequestParameter(OBJECTID);
+ try
+ {
+ ProducerConfigurationService service = source.getService();
+
service.getConfiguration().getRegistrationRequirements().removeRegistrationProperty(id);
+ service.saveConfiguration();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ UIApplication uiApp = event.getRequestContext().getUIApplication();
+ uiApp.addMessage(new ApplicationMessage("Failed to delete Producer
Property. Cause: " + e.getCause(), null, ApplicationMessage.ERROR));
+ }
+
+ }
+ }
+
+ static public class AddPropertyActionListener extends
EventListener<UIWsrpRegistrationDetails>
+ {
+ public void execute(Event<UIWsrpRegistrationDetails> event) throws Exception
+ {
+ UIWsrpRegistrationDetails source = event.getSource();
+ UIPopupWindow popup = source.getChild(UIPopupWindow.class);
+ UIWsrpProducerPropertyEditor editor =
(UIWsrpProducerPropertyEditor)popup.getUIComponent();
+
+ //reset the form
+ editor.setRegistrationPropertyDescription(null);
+ popup.setRendered(true);
+ popup.setShow(true);
+ popup.setShowCloseButton(true);
+ //popup.setShowMask(true);
+
+ }
+ }
+}
Modified:
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/wsrp/webui/component/UIWsrpProducerOverview.gtmpl
===================================================================
---
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/wsrp/webui/component/UIWsrpProducerOverview.gtmpl 2010-01-19
16:55:52 UTC (rev 1382)
+++
portal/trunk/portlet/exoadmin/src/main/webapp/groovy/wsrp/webui/component/UIWsrpProducerOverview.gtmpl 2010-01-19
16:58:27 UTC (rev 1383)
@@ -1,6 +1,6 @@
<%
- import org.exoplatform.wsrp.webui.component.UIWsrpProducerEditor;
- import org.exoplatform.wsrp.webui.component.UIWsrpRegistrationDetails;
+ import org.exoplatform.wsrp.webui.component.producer.UIWsrpProducerEditor;
+ import org.exoplatform.wsrp.webui.component.producer.UIWsrpRegistrationDetails;
%>
<div class="<%=uicomponent.getId()%>"
id="<%=uicomponent.getId()%>">