Author: theute
Date: 2011-10-11 08:24:59 -0400 (Tue, 11 Oct 2011)
New Revision: 7712
Modified:
epp/portal/branches/EPP_5_2_Branch/gadgets/gwtGadgets/src/main/java/org/gatein/management/gadget/mop/exportimport/client/Application.java
epp/portal/branches/EPP_5_2_Branch/gadgets/gwtGadgets/src/main/java/org/gatein/management/gadget/mop/exportimport/server/FileUploadServlet.java
Log:
JBEPP-1275: Export/Import Gadget uses incorrect importMode attribute.
JBEPP-1276: Allow use of all import modes in MOP Export/Import Gadget
JBEPP-1269: Inconsistency in Export/Import Gadget UI after attempting to import invalid
file
JBEPP-1268: Export/Import Gadget CSS Problems
Modified:
epp/portal/branches/EPP_5_2_Branch/gadgets/gwtGadgets/src/main/java/org/gatein/management/gadget/mop/exportimport/client/Application.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/gadgets/gwtGadgets/src/main/java/org/gatein/management/gadget/mop/exportimport/client/Application.java 2011-10-11
12:16:40 UTC (rev 7711)
+++
epp/portal/branches/EPP_5_2_Branch/gadgets/gwtGadgets/src/main/java/org/gatein/management/gadget/mop/exportimport/client/Application.java 2011-10-11
12:24:59 UTC (rev 7712)
@@ -23,6 +23,8 @@
package org.gatein.management.gadget.mop.exportimport.client;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.logical.shared.OpenEvent;
@@ -40,7 +42,6 @@
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.DecoratedTabPanel;
import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.DialogBox;
@@ -50,11 +51,13 @@
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.NamedFrame;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.TreeItem;
+import gwtupload.client.IUploadStatus;
import gwtupload.client.IUploader;
import gwtupload.client.MultiUploader;
@@ -73,7 +76,7 @@
* @version 1.0
*/
@ModulePrefs(title = "Export/Import Tool", author = "Nabil
Benothman", author_email = "nbenothm(a)redhat.com",
- description = "This gadget allows the administrator to export/import
sites")
+ description = "This gadget allows the administrator to export/import sites",
width = 870, height = 480)
@Gadget.AllowHtmlQuirksMode(false)
@Gadget.UseLongManifestName(false)
public class Application extends Gadget<UserPreferences>
@@ -105,9 +108,6 @@
TreeImages images = GWT.create(TreeImages.class);
RootPanel rootPanel = RootPanel.get();
- rootPanel.setSize("885px", "490px");
- rootPanel.addStyleName("rootpanelstyle");
-
DecoratedTabPanel decoratedTabPanel = new DecoratedTabPanel();
decoratedTabPanel.setAnimationEnabled(true);
rootPanel.add(decoratedTabPanel, 10, 10);
@@ -222,7 +222,14 @@
absolutePanel.setSize("400px", "220px");
final Button importButton = new Button("Import");
- final CheckBox overwriteBox = new CheckBox("Overwrite the existing
site");
+ final Label importModeLabel = new Label("Import Mode:");
+ final ListBox importModeListBox = new ListBox(false);
+ importModeListBox.addItem("Conserve", "conserve");
+ importModeListBox.addItem("Insert", "insert");
+ importModeListBox.addItem("Merge", "merge");
+ importModeListBox.addItem("Overwrite", "overwrite");
+ importModeListBox.setSelectedIndex(2); // set default to 'merge'
+
final HTML statusImg = new
HTML(" ", true);
final Label statusLabel = new Label("status label");
final Label headerLabel = new Label("Select file to import :");
@@ -280,7 +287,7 @@
break;
}
- overwriteBox.setEnabled(true);
+ importModeListBox.setEnabled(true);
importButton.setEnabled(true);
}
});
@@ -292,37 +299,40 @@
public void onStart(IUploader uploader)
{
- statusLabel.setText("Process in progress...");
- statusLabel.setStyleName("progress-style");
- statusImg.setStyleName("progress-style-icon");
- overwriteBox.setEnabled(false);
- importButton.setEnabled(false);
- if (!isShwon)
+ if (uploader.getStatus() == IUploadStatus.Status.INPROGRESS)
{
- statusPanel.setStyleName("status-panel");
- statusPanel.setSize("380px", "0px");
- absolutePanel.add(statusPanel, 10, 120);
-
- Timer t = new Timer()
+ statusLabel.setText("Process in progress...");
+ statusLabel.setStyleName("progress-style");
+ statusImg.setStyleName("progress-style-icon");
+ importModeListBox.setEnabled(false);
+ importButton.setEnabled(false);
+ if (!isShwon)
{
+ statusPanel.setStyleName("status-panel");
+ statusPanel.setSize("380px", "0px");
+ absolutePanel.add(statusPanel, 10, 120);
- int dx = 5;
- int height = 0;
+ Timer t = new Timer()
+ {
- public void run()
- {
- height += dx;
- statusPanel.setHeight(height + "px");
- if (height >= 45)
+ int dx = 5;
+ int height = 0;
+
+ public void run()
{
- cancel(); // Stop the timer
+ height += dx;
+ statusPanel.setHeight(height + "px");
+ if (height >= 45)
+ {
+ cancel(); // Stop the timer
+ }
}
- }
- };
+ };
- // Schedule the timer to run once in 100 milliseconds.
- t.scheduleRepeating(100);
- isShwon = true;
+ // Schedule the timer to run once in 100 milliseconds.
+ t.scheduleRepeating(100);
+ isShwon = true;
+ }
}
}
});
@@ -331,18 +341,19 @@
// You can add customized parameters to servlet call
uploader.setServletPath(UPLOAD_ACTION_URL + "?pc=" +
getPortalContainerName());
- overwriteBox.setTitle("If you want to force overwriting an existing site,
check this checkbox");
- overwriteBox.addClickHandler(new ClickHandler()
+ importModeListBox.setTitle("The import mode to use during import.");
+ importModeListBox.addChangeHandler(new ChangeHandler()
{
-
- public void onClick(ClickEvent event)
+ @Override
+ public void onChange(ChangeEvent changeEvent)
{
- String url = UPLOAD_ACTION_URL + "?pc=" + getPortalContainerName()
+ "&overwrite=" + overwriteBox.getValue();
+ String url = UPLOAD_ACTION_URL + "?pc=" + getPortalContainerName()
+ "&importMode=" +
importModeListBox.getValue(importModeListBox.getSelectedIndex());
uploader.setServletPath(url);
}
});
- absolutePanel.add(overwriteBox, 10, 84);
+ absolutePanel.add(importModeLabel, 10, 88);
+ absolutePanel.add(importModeListBox, 95, 84);
Button closeButton = new Button("Close", new ClickHandler()
{
Modified:
epp/portal/branches/EPP_5_2_Branch/gadgets/gwtGadgets/src/main/java/org/gatein/management/gadget/mop/exportimport/server/FileUploadServlet.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/gadgets/gwtGadgets/src/main/java/org/gatein/management/gadget/mop/exportimport/server/FileUploadServlet.java 2011-10-11
12:16:40 UTC (rev 7711)
+++
epp/portal/branches/EPP_5_2_Branch/gadgets/gwtGadgets/src/main/java/org/gatein/management/gadget/mop/exportimport/server/FileUploadServlet.java 2011-10-11
12:24:59 UTC (rev 7712)
@@ -97,11 +97,10 @@
receivedFiles.put(item.getFieldName(), file);
receivedContentTypes.put(item.getFieldName(), item.getContentType());
- String overwriteVal = request.getParameter("overwrite");
- boolean overwrite = Boolean.parseBoolean(overwriteVal);
+ String importMode = request.getParameter("importMode");
// process the uploaded file
- processImport(request.getParameter("pc"), new
FileInputStream(file), overwrite);
+ processImport(request.getParameter("pc"), new
FileInputStream(file), importMode);
// Compose a xml message with the full file information which can be
parsed in client side
response.append("<file-").append(count).append("-field>").append(item.getFieldName()).append("</file-").append(count).append("-field>\n");
@@ -159,7 +158,7 @@
}
}
- private void processImport(final String containerName, final InputStream in, final
boolean overwrite) throws Exception
+ private void processImport(final String containerName, final InputStream in, final
String importMode) throws Exception
{
doInRequest(containerName, new ContainerCallback<Void>()
@@ -170,12 +169,9 @@
{
ManagementController controller = getComponent(container,
ManagementController.class);
- Map<String, List<String>> attributes = Collections.emptyMap();
- if (overwrite)
- {
- attributes = new HashMap<String, List<String>>(1);
- attributes.put("import-strategy",
Collections.singletonList("overwrite"));
- }
+ Map<String, List<String>> attributes = new HashMap<String,
List<String>>(1);
+ attributes.put("importMode",
Collections.singletonList(importMode));
+
ManagedRequest request = ManagedRequest.Factory.create(
OperationNames.IMPORT_RESOURCE, PathAddress.pathAddress("mop"),
attributes, in, ContentType.ZIP);