DNA SVN: r1141 - in branches/eclipse/org.jboss.dna.publish.ui.swt: icons/objects and 6 other directories.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-07-31 12:52:11 -0400 (Fri, 31 Jul 2009)
New Revision: 1141
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/checkmark.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/delete_server.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java
Removed:
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/checkbox.gif
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/.classpath
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/repository.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/new_server.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/wizards/dna_wizard_banner.png
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/I18n.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/DeleteServerAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/i18n.properties
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/ServerPage.java
Log:
Some new icons. Finished up the publishing results dialog.Fixed a bug in ServerPage that wouldn't allow update to server if the password was changed.
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/.classpath
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/.classpath 2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/.classpath 2009-07-31 16:52:11 UTC (rev 1141)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry exported="true" kind="lib" path="dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar"/>
+ <classpathentry exported="true" kind="lib" path="dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar" sourcepath="dna-web-jcr-rest-client-0.6-SNAPSHOT-sources.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/checkmark.gif
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/checkmark.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/repository.gif
===================================================================
(Binary files differ)
Deleted: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/checkbox.gif
===================================================================
(Binary files differ)
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/delete_server.gif
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/delete_server.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif 2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif 2009-07-31 16:52:11 UTC (rev 1141)
@@ -1,3 +1,2 @@
-GIF89a
-*�7
\ No newline at end of file
+GIF89a
+6��F]xQ��V��P�l��qpa%��Jd^Đ'�����8+�,+�:�,hq� D��*�shC
\ No newline at end of file
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/new_server.gif
===================================================================
(Binary files differ)
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/wizards/dna_wizard_banner.png
===================================================================
(Binary files differ)
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/I18n.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/I18n.java 2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/I18n.java 2009-07-31 16:52:11 UTC (rev 1141)
@@ -56,9 +56,12 @@
public static String NewServerActionText;
public static String NewServerActionToolTip;
- public static String PublishOperationPublishNotAttemptedMsg;
+ public static String PublishingResultsPublishNotAttemptedMsg;
+ public static String PublishingResultsTooManyResultsMsg;
+ public static String PublishingResultsUnknownSeverityMsg;
+ public static String PublishingResultsUnpublishNotAttemptedMsg;
+
public static String PublishOperationPublishTaskName;
- public static String PublishOperationUnpublishNotAttemptedMsg;
public static String PublishOperationUnpublishTaskName;
public static String PublishPagePublishTitle;
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java 2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java 2009-07-31 16:52:11 UTC (rev 1141)
@@ -44,6 +44,8 @@
String OBJECT_ICONS_FOLDER = ICON_PATH + "objects/"; //$NON-NLS-1$
+ String CHECKMARK_IMAGE_PATH = OBJECT_ICONS_FOLDER + "checkmark.gif"; //$NON-NLS-1$
+
String REPOSITORY_IMAGE_PATH = OBJECT_ICONS_FOLDER + "repository.gif"; //$NON-NLS-1$
String SERVER_IMAGE_PATH = OBJECT_ICONS_FOLDER + "server.gif"; //$NON-NLS-1$
@@ -56,10 +58,10 @@
String VIEWS_ICON_FOLDER = ICON_PATH + "views/"; //$NON-NLS-1$
- String CHECKBOX_IMAGE_PATH = VIEWS_ICON_FOLDER + "checkbox.gif"; //$NON-NLS-1$
-
String COLLAPSE_ALL_IMAGE_PATH = VIEWS_ICON_FOLDER + "collapse_all.gif"; //$NON-NLS-1$
+ String DELETE_SERVER_IMAGE_PATH = VIEWS_ICON_FOLDER + "delete_server.gif"; //$NON-NLS-1$
+
String DNA_WINDOW_IMAGE_PATH = VIEWS_ICON_FOLDER + "dna_window.png"; //$NON-NLS-1$
String EDIT_SERVER_IMAGE_PATH = VIEWS_ICON_FOLDER + "edit_server.gif"; //$NON-NLS-1$
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/DeleteServerAction.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/DeleteServerAction.java 2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/DeleteServerAction.java 2009-07-31 16:52:11 UTC (rev 1141)
@@ -23,6 +23,7 @@
*/
package org.jboss.dna.web.jcr.rest.client.swt.actions;
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DELETE_SERVER_IMAGE_PATH;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.dialogs.Dialog;
@@ -30,7 +31,6 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
import org.jboss.dna.web.jcr.rest.client.ServerManager;
import org.jboss.dna.web.jcr.rest.client.Status;
@@ -85,8 +85,7 @@
ServerManager serverManager ) {
super(I18n.DeleteServerActionText);
setToolTipText(I18n.DeleteServerActionToolTip);
- setImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
- setDisabledImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
+ setImageDescriptor(Activator.getDefault().getImageDescriptor(DELETE_SERVER_IMAGE_PATH));
setEnabled(false);
this.serversToDelete = new ArrayList<Server>(5);
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java 2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java 2009-07-31 16:52:11 UTC (rev 1141)
@@ -23,7 +23,7 @@
*/
package org.jboss.dna.web.jcr.rest.client.swt.dialogs;
-import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.CHECKBOX_IMAGE_PATH;
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.CHECKMARK_IMAGE_PATH;
import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_WINDOW_IMAGE_PATH;
import java.util.List;
import org.eclipse.core.resources.IFile;
@@ -49,6 +49,7 @@
import org.jboss.dna.web.jcr.rest.client.swt.I18n;
import org.jboss.dna.web.jcr.rest.client.swt.Utils;
import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation;
+import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishingResults;
/**
* The <code>DeleteServerDialog</code> class provides a UI for deleting a {@link Server server}.
@@ -62,10 +63,25 @@
// Constants
// ===========================================================================================================================
+ /**
+ * The table column index of the column where the file name is displayed.
+ *
+ * @since 0.6
+ */
private static final int FILE_COL = 0;
+ /**
+ * The table column index of the column where the status severity is displayed.
+ *
+ * @since 0.6
+ */
private static final int SEVERITY_COL = 1;
+ /**
+ * The table column index of the column where the error message is displayed.
+ *
+ * @since 0.6
+ */
private static final int MESSAGE_COL = 2;
// ===========================================================================================================================
@@ -80,46 +96,26 @@
private Throwable error;
/**
- * The list of files that were published or unpublished.
+ * The results of the publishing operation.
*
* @since 0.6
*/
- private final List<IFile> files;
+ private final PublishingResults results;
- /**
- * The status of the publish or unpublish operation for each file.
- *
- * @since 0.6
- */
- private final List<Status> statuses;
-
- /**
- * The operation type.
- *
- * @since 0.6
- */
- private final PublishOperation.Type type;
-
// ===========================================================================================================================
// Constructors
// ===========================================================================================================================
/**
* @param parentShell the dialog parent
- * @param type the operation type (publish or unpublish)
- * @param files the files used in the operation
- * @param statuses the operation status of each file
+ * @param results the results being displayed (never <code>null</code>)
* @since 0.6
*/
public PublishingResultsDialog( Shell parentShell,
- PublishOperation.Type type,
- List<IFile> files,
- List<Status> statuses ) {
+ PublishingResults results ) {
super(parentShell, I18n.PublishResultsDialogTitle, Activator.getDefault().getImage(DNA_WINDOW_IMAGE_PATH), null,
MessageDialog.INFORMATION, new String[] {IDialogConstants.OK_LABEL}, 0);
- this.files = files;
- this.statuses = statuses;
- this.type = type;
+ this.results = results;
// make sure dialog is resizable
setShellStyle(getShellStyle() | SWT.RESIZE);
@@ -127,22 +123,16 @@
/**
* @param parentShell the dialog parent
- * @param type the operation type (publish or unpublish)
- * @param files the files used in the operation
- * @param statuses the operation status of each file
+ * @param results the results being displayed (never <code>null</code>)
* @param error an unexpected error caught during the publish operation
* @since 0.6
*/
public PublishingResultsDialog( Shell parentShell,
- PublishOperation.Type type,
- List<IFile> files,
- List<Status> statuses,
+ PublishingResults results,
Throwable error ) {
super(parentShell, I18n.PublishResultsDialogTitle, Activator.getDefault().getImage(DNA_WINDOW_IMAGE_PATH), null,
MessageDialog.ERROR, new String[] {IDialogConstants.OK_LABEL}, 0);
- this.files = files;
- this.statuses = statuses;
- this.type = type;
+ this.results = results;
this.error = error;
// make sure dialog is resizable
@@ -164,12 +154,15 @@
super.configureShell(shell);
// now set message
- if (this.type == PublishOperation.Type.PUBLISH) {
- this.message = ((this.error == null) ? I18n.PublishResultsDialogPublishMsg : I18n.bind(I18n.PublishResultsDialogErrorPublishingMsg,
- this.error.getLocalizedMessage()));
+ Object[] counts = new Object[] {this.results.getOksCount(), this.results.getErrorCount(), this.results.getInfoCount(),
+ this.results.getWarningsCount()};
+
+ if (this.results.getType() == PublishOperation.Type.PUBLISH) {
+ this.message = ((this.error == null) ? I18n.bind(I18n.PublishResultsDialogPublishMsg, counts) : I18n.bind(I18n.PublishResultsDialogErrorPublishingMsg,
+ this.error.getLocalizedMessage()));
} else {
- this.message = ((this.error == null) ? I18n.PublishResultsDialogUnpublishMsg : I18n.bind(I18n.PublishResultsDialogErrorUnpublishingMsg,
- this.error.getLocalizedMessage()));
+ this.message = ((this.error == null) ? I18n.bind(I18n.PublishResultsDialogUnpublishMsg, counts) : I18n.bind(I18n.PublishResultsDialogErrorUnpublishingMsg,
+ this.error.getLocalizedMessage()));
}
}
@@ -195,7 +188,7 @@
protected Control createCustomArea( Composite parent ) {
Composite pnl = new Composite(parent, SWT.NONE);
pnl.setLayout(new GridLayout());
- GridData gd = new GridData(SWT.LEFT, SWT.CENTER, true, true);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
pnl.setLayoutData(gd);
TableViewer viewer = new TableViewer(pnl, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
@@ -205,14 +198,14 @@
Table table = viewer.getTable();
table.setLayout(new GridLayout());
- table.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true));
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn col = new TableColumn(table, SWT.LEFT);
col.setText(I18n.PublishResultsDialogFileHeader);
- col = new TableColumn(table, SWT.LEFT);
+ col = new TableColumn(table, SWT.CENTER);
col.setResizable(false);
col = new TableColumn(table, SWT.LEFT);
@@ -235,16 +228,16 @@
* @since 0.6
*/
List<IFile> getFiles() {
- return this.files;
+ return this.results.getFiles();
}
/**
- * @param index the index of the status being requested
- * @return the status
+ * @param file the file whose status is being requested
+ * @return the status or <code>null</code> if not found
* @since 0.6
*/
- Status getStatus( int index ) {
- return this.statuses.get(index);
+ Status getStatus( IFile file ) {
+ return this.results.getStatus(file);
}
// ===========================================================================================================================
@@ -270,10 +263,10 @@
public Image getColumnImage( Object element,
int columnIndex ) {
if (columnIndex == SEVERITY_COL) {
- Status status = getStatus(getFiles().indexOf(element));
+ Status status = getStatus((IFile)element);
if (status.isOk()) {
- return Activator.getDefault().getImage(CHECKBOX_IMAGE_PATH);
+ return Activator.getDefault().getImage(CHECKMARK_IMAGE_PATH);
}
return Utils.getImage(status);
@@ -296,7 +289,7 @@
}
if (columnIndex == MESSAGE_COL) {
- Status status = getStatus(getFiles().indexOf(element));
+ Status status = getStatus((IFile)element);
if (!status.isOk()) {
return status.getMessage();
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/i18n.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/i18n.properties 2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/i18n.properties 2009-07-31 16:52:11 UTC (rev 1141)
@@ -34,7 +34,7 @@
DeleteServerDialogOneServerMsg = Are you sure you want to delete the "{0}" server?
DeleteServerDialogTitle = Confirm Delete Server
-EditServerActionText = Edit Server
+EditServerActionText = Server Properties
EditServerActionToolTip = Edit server properties
ErrorDialogTitle = Error
@@ -42,12 +42,14 @@
MissingImage = The following image cannot be found "{0}"
NewServerActionText = New Server
-NewServerActionToolTip = Create and register a new server
+NewServerActionToolTip = Create a new server
-PublishOperationPublishNotAttemptedMsg = Publishing not attempted
-PublishOperationUnpublishNotAttemptedMsg = Unpublishing not attempted
+PublishingResultsPublishNotAttemptedMsg = Publishing not attempted
+PublishingResultsTooManyResultsMsg = Adding a status to the results failed since there is not enough files involved in the publishing operation.
+PublishingResultsUnknownSeverityMsg = "{0}" is an unknown status severity
+PublishingResultsUnpublishNotAttemptedMsg = Unpublishing not attempted
+
PublishOperationPublishTaskName = Publishing resources
-PublishOperationUnpublishNotAttemptedMsg = Unpublishing not attempted
PublishOperationUnpublishTaskName = Unpublishing resources
PublishPagePublishTitle = Publish the selected resources
@@ -81,9 +83,9 @@
PublishResultsDialogErrorUnpublishingMsg = There was a problem publishing some or all of the files. See results below and the log for more details. Error message: "{0}."
PublishResultsDialogFileHeader = File
PublishResultsDialogMessageHeader = Message
-PublishResultsDialogPublishMsg = Here are the results of the publishing request.
+PublishResultsDialogPublishMsg = The operation completed with {0} file(s) being published. There were {1} error(s), {2} info(s), and {3} warning(s).
PublishResultsDialogTitle = Results
-PublishResultsDialogUnpublishMsg = Here are the results of the unpublishing request.
+PublishResultsDialogUnpublishMsg = The operation completed with {0} file(s) being unpublished. There were {1} error(s), {2} info(s), and {3} warning(s).
PublishWizardPublishErrorMsg = Error Publishing
PublishWizardPublishTitle = Publish
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java 2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java 2009-07-31 16:52:11 UTC (rev 1141)
@@ -25,12 +25,11 @@
import java.io.File;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.dna.web.jcr.rest.client.Status;
-import org.jboss.dna.web.jcr.rest.client.Status.Severity;
+import org.jboss.dna.web.jcr.rest.client.Utils;
import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
import org.jboss.dna.web.jcr.rest.client.swt.Activator;
import org.jboss.dna.web.jcr.rest.client.swt.I18n;
@@ -66,22 +65,6 @@
UNPUBLISH
}
- /**
- * Status indicating the file was not attempted to be published.
- *
- * @since 0.6
- */
- private static final Status PUBLISH_NOT_ATTEMPTED_STATUS = new Status(Severity.INFO,
- I18n.PublishOperationPublishNotAttemptedMsg, null);
-
- /**
- * Status indicating the file was not attempted to be published.
- *
- * @since 0.6
- */
- private static final Status UNPUBLISH_NOT_ATTEMPTED_STATUS = new Status(Severity.INFO,
- I18n.PublishOperationUnpublishNotAttemptedMsg, null);
-
// ===========================================================================================================================
// Fields
// ===========================================================================================================================
@@ -101,11 +84,11 @@
private final Type type;
/**
- * The operation status for each file.
+ * The results of the publishing operation.
*
* @since 0.6
*/
- private List<Status> statuses;
+ private PublishingResults results;
/**
* The workspace to use when publishing or unpublishing.
@@ -127,6 +110,10 @@
public PublishOperation( Type type,
List<IFile> files,
Workspace workspace ) {
+ Utils.nullArgumentCheck("type", type); //$NON-NLS-1$
+ Utils.nullArgumentCheck("files", files); //$NON-NLS-1$
+ Utils.nullArgumentCheck("workspace", workspace); //$NON-NLS-1$
+
this.type = type;
this.files = files;
this.workspace = workspace;
@@ -137,11 +124,11 @@
// ===========================================================================================================================
/**
- * @return the operation status of each file (never <code>null</code> and always one status for each file)
+ * @return the results of the publishing operation or <code>null</code> if operation has not been executed
* @since 0.6
*/
- public List<Status> getStatus() {
- return this.statuses;
+ public PublishingResults getResults() {
+ return this.results;
}
/**
@@ -169,30 +156,34 @@
public void execute( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException {
assert (this.workspace != null);
- this.statuses = new ArrayList<Status>(this.files.size());
+ this.results = new PublishingResults(this.type, this.files);
try {
String name = (isPublishing() ? I18n.PublishOperationPublishTaskName : I18n.PublishOperationUnpublishTaskName);
monitor.beginTask(name, this.files.size());
monitor.setTaskName(name);
- for (IFile eclipseFile : this.files) {
+ for (IFile eclipseFile : this.files) {
if (monitor.isCanceled()) {
throw new InterruptedException();
}
File file = eclipseFile.getLocation().toFile();
+ Status status = null;
+
// TODO call publisher here (timeout?)
if (isPublishing()) {
- this.statuses.add(Activator.getDefault().getServerManager().publish(this.workspace,
- eclipseFile.getFullPath().toString(),
- file));
+ status = Activator.getDefault().getServerManager().publish(this.workspace,
+ eclipseFile.getFullPath().toString(),
+ file);
} else {
- this.statuses.add(Activator.getDefault().getServerManager().unpublish(this.workspace,
- eclipseFile.getFullPath().toString(),
- file));
+ status = Activator.getDefault().getServerManager().unpublish(this.workspace,
+ eclipseFile.getFullPath().toString(),
+ file);
}
+
+ results.addStatus(status);
monitor.worked(1);
}
} catch (InterruptedException e) {
@@ -200,15 +191,7 @@
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
- // ensure there is a status for each file
- if (this.files.size() != this.statuses.size()) {
- Status status = (isPublishing() ? PUBLISH_NOT_ATTEMPTED_STATUS : UNPUBLISH_NOT_ATTEMPTED_STATUS);
-
- for (int count = this.files.size() - this.statuses.size(), i = 0; i < count; ++i) {
- this.statuses.add(status);
- }
- }
-
+ results.closeOut();
monitor.done();
}
}
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java 2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java 2009-07-31 16:52:11 UTC (rev 1141)
@@ -36,6 +36,7 @@
import org.eclipse.jface.wizard.Wizard;
import org.jboss.dna.web.jcr.rest.client.ServerManager;
import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.Utils;
import org.jboss.dna.web.jcr.rest.client.Status.Severity;
import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
import org.jboss.dna.web.jcr.rest.client.swt.Activator;
@@ -79,7 +80,7 @@
// ===========================================================================================================================
/**
- * @param type the publishing or unpublishing indicator
+ * @param type the publishing or unpublishing indicator (never <code>null</code>)
* @param resources the resources being published or unpublished (never <code>null</code>)
* @param serverManager the server manager in charge of the server registry (never <code>null</code>)
* @throws CoreException if there is a problem processing the resources
@@ -88,6 +89,10 @@
public PublishWizard( Type type,
List<IResource> resources,
ServerManager serverManager ) throws CoreException {
+ Utils.nullArgumentCheck("type", type); //$NON-NLS-1$
+ Utils.nullArgumentCheck("resources", resources); //$NON-NLS-1$
+ Utils.nullArgumentCheck("serverManager", serverManager); //$NON-NLS-1$
+
this.type = type;
this.page = new PublishPage(type, resources);
this.serverManager = serverManager;
@@ -186,9 +191,9 @@
PublishingResultsDialog resultsDialog = null;
if (error == null) {
- resultsDialog = new PublishingResultsDialog(getShell(), this.type, files, operation.getStatus());
+ resultsDialog = new PublishingResultsDialog(getShell(), operation.getResults());
} else {
- resultsDialog = new PublishingResultsDialog(getShell(), this.type, files, operation.getStatus(), error);
+ resultsDialog = new PublishingResultsDialog(getShell(), operation.getResults(), error);
}
resultsDialog.open();
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java (rev 0)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java 2009-07-31 16:52:11 UTC (rev 1141)
@@ -0,0 +1,260 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.jboss.dna.web.jcr.rest.client.swt.wizards;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.Utils;
+import org.jboss.dna.web.jcr.rest.client.Status.Severity;
+import org.jboss.dna.web.jcr.rest.client.swt.I18n;
+import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation.Type;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class PublishingResults {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ /**
+ * Status indicating the file was not attempted to be published.
+ *
+ * @since 0.6
+ */
+ private static final Status PUBLISH_NOT_ATTEMPTED_STATUS = new Status(Severity.INFO,
+ I18n.PublishingResultsPublishNotAttemptedMsg, null);
+
+ /**
+ * Status indicating the file was not attempted to be published.
+ *
+ * @since 0.6
+ */
+ private static final Status UNPUBLISH_NOT_ATTEMPTED_STATUS = new Status(Severity.INFO,
+ I18n.PublishingResultsUnpublishNotAttemptedMsg, null);
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * Indicates if a status for each file has been added.
+ *
+ * @since 0.6
+ */
+ private boolean complete;
+
+ /**
+ * The files involved in the publishing operation.
+ *
+ * @since 0.6
+ */
+ private final List<IFile> files;
+
+ /**
+ * The number of {@link Status status} objects that have an {@link Severity#ERROR error} severity.
+ *
+ * @since 0.6
+ */
+ private int numErrors;
+
+ /**
+ * The number of {@link Status status} objects that have an {@link Severity#INFO info} severity.
+ *
+ * @since 0.6
+ */
+ private int numInfos;
+
+ /**
+ * The number of {@link Status status} objects that have an {@link Severity#OK OK} severity.
+ *
+ * @since 0.6
+ */
+ private int numOks;
+
+ /**
+ * The number of {@link Status status} objects that have a {@link Severity#WARNING warning} severity.
+ *
+ * @since 0.6
+ */
+ private int numWarnings;
+
+ /**
+ * When complete there will be one status for each file.
+ *
+ * @since 0.6
+ */
+ private final List<Status> statuses;
+
+ /**
+ * The type of publishing operation these results pertain to.
+ *
+ * @since 0.6
+ */
+ private final Type type;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param type the type of publishing operation
+ * @param files the files involved in the publishing operation (never <code>null</code>)
+ * @since 0.6
+ */
+ public PublishingResults( Type type,
+ List<IFile> files ) {
+ Utils.nullArgumentCheck("type", type); //$NON-NLS-1$
+ Utils.nullArgumentCheck("files", files); //$NON-NLS-1$
+
+ this.type = type;
+ this.files = files;
+ this.statuses = new ArrayList<Status>(this.files.size());
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * @param status the status being added
+ * @throws RuntimeException if the number of status objects is greater than the number of files
+ * @since 0.6
+ */
+ public void addStatus( Status status ) {
+ if (this.files.size() < (this.statuses.size() + 1)) {
+ throw new RuntimeException(I18n.PublishingResultsTooManyResultsMsg);
+ }
+
+ this.statuses.add(status);
+
+ if (status.isError()) ++this.numErrors;
+ else if (status.isInfo()) ++this.numInfos;
+ else if (status.isOk()) ++this.numOks;
+ else if (status.isWarning()) ++this.numWarnings;
+ else throw new RuntimeException(I18n.bind(I18n.PublishingResultsUnknownSeverityMsg, status.getSeverity()));
+
+ this.complete = (this.files.size() == this.statuses.size());
+ }
+
+ /**
+ * Finalizes the results by making sure there is one status object for each file. No need to call if all files have a status.
+ *
+ * @since 0.6
+ */
+ public void closeOut() {
+ if (this.files.size() != this.statuses.size()) {
+ Status status = ((Type.PUBLISH == this.type) ? PUBLISH_NOT_ATTEMPTED_STATUS : UNPUBLISH_NOT_ATTEMPTED_STATUS);
+
+ for (int count = this.files.size() - this.statuses.size(), i = 0; i < count; ++i) {
+ addStatus(status);
+ }
+ }
+ }
+
+ /**
+ * @return the number of errors in the result
+ * @since 0.6
+ */
+ public int getErrorCount() {
+ return this.numErrors;
+ }
+
+ /**
+ * @return the files involved in the publishing operation
+ * @since 0.6
+ */
+ public List<IFile> getFiles() {
+ return this.files;
+ }
+
+ /**
+ * @return the number of infos in the result
+ * @since 0.6
+ */
+ public int getInfoCount() {
+ return this.numInfos;
+ }
+
+ /**
+ * @return the number of OKs in the result
+ * @since 0.6
+ */
+ public int getOksCount() {
+ return this.numOks;
+ }
+
+ /**
+ * @param file the file whose status is being requested (never <code>null</code>)
+ * @return the status or <code>null</code> if there is no status for the specified file
+ * @since 0.6
+ */
+ public Status getStatus( IFile file ) {
+ Utils.nullArgumentCheck("file", file); //$NON-NLS-1$
+ int index = this.files.indexOf(file);
+
+ if (index == -1) {
+ return null;
+ }
+
+ return this.statuses.get(index);
+ }
+
+ /**
+ * @return the status of each file involved in the publishing operation
+ * @since 0.6
+ */
+ public List<Status> getStatuses() {
+ return this.statuses;
+ }
+
+ /**
+ * @return the publishing operation type
+ * @since 0.6
+ */
+ public Type getType() {
+ return this.type;
+ }
+
+ /**
+ * @return the number of warnings in the result
+ * @since 0.6
+ */
+ public int getWarningsCount() {
+ return this.numWarnings;
+ }
+
+ /**
+ * @return <code>true</code> if there is one status object for each file
+ * @since 0.6
+ */
+ public boolean isComplete() {
+ return this.complete;
+ }
+
+}
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/ServerPage.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/ServerPage.java 2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/ServerPage.java 2009-07-31 16:52:11 UTC (rev 1141)
@@ -407,7 +407,7 @@
this.status = ServerValidator.isValid(this.url, this.user, this.password, this.savePassword);
// if server is valid and is different from what we started with validate and check the registry
- if (this.status.isOk() && !this.server.equals(getServer())) {
+ if (this.status.isOk() && !this.server.hasSameKey(getServer())) {
this.status = ServerValidator.isValid(this.url, this.user, this.password, this.savePassword, getServerManager());
}
}
16 years, 5 months
DNA SVN: r1140 - in branches/eclipse/dna-web-jcr-rest-client: src/main/java/org/jboss/dna/web/jcr/rest/client and 3 other directories.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-07-29 19:01:57 -0400 (Wed, 29 Jul 2009)
New Revision: 1140
Modified:
branches/eclipse/dna-web-jcr-rest-client/pom.xml
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/RepositoryNode.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java
branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java
Log:
Added assembly build to pom in order to package dependenies into jar. Now doing URL encoding/decoding using JDK classes. Logger now does not throw exception if a logging adapter is not found. Setting URL authenticator before every call to open connection.
Modified: branches/eclipse/dna-web-jcr-rest-client/pom.xml
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/pom.xml 2009-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/pom.xml 2009-07-29 23:01:57 UTC (rev 1140)
@@ -18,16 +18,16 @@
those defined in the dependencyManagement section of the parent pom.
-->
<dependencies>
+ <!--
+ Testing (note the scope)
+ -->
<dependency>
<groupId>org.jboss.dna</groupId>
<artifactId>dna-web-jcr-rest-war</artifactId>
<type>war</type>
<version>${pom.version}</version>
+ <scope>integration-test</scope>
</dependency>
-
- <!--
- Testing (note the scope)
- -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -54,10 +54,12 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
+ <scope>integration-test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
+ <scope>integration-test</scope>
</dependency>
<!--
Java Concurrency in Practice annotations
@@ -87,6 +89,28 @@
</plugins>
</reporting>
<build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies
+ </descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>create-project-bundle</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java 2009-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/Logger.java 2009-07-29 23:01:57 UTC (rev 1140)
@@ -80,7 +80,14 @@
*/
public static void log( Class<?> clazz,
Status status ) {
- org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
+ org.slf4j.Logger delegate = null;
+
+ try {
+ delegate = LoggerFactory.getLogger(clazz);
+ } catch (Throwable e) {
+ // adapter not found
+ return;
+ }
if (status.isError() && delegate.isErrorEnabled()) {
if (status.getException() == null) {
@@ -114,7 +121,14 @@
public static void log( Class<?> clazz,
Status status,
Object... arguments ) {
- org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
+ org.slf4j.Logger delegate = null;
+
+ try {
+ delegate = LoggerFactory.getLogger(clazz);
+ } catch (Throwable e) {
+ // adapter not found
+ return;
+ }
if (status.isError() && delegate.isErrorEnabled()) {
String msg = getMessage(clazz, status, arguments);
@@ -154,7 +168,14 @@
public static void trace( Class<?> clazz,
Throwable e,
String msg ) {
- org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
+ org.slf4j.Logger delegate = null;
+
+ try {
+ delegate = LoggerFactory.getLogger(clazz);
+ } catch (Throwable error) {
+ // adapter not found
+ return;
+ }
if (delegate.isTraceEnabled()) {
if (e == null) {
@@ -176,7 +197,14 @@
Throwable e,
String pattern,
Object... arguments ) {
- org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
+ org.slf4j.Logger delegate = null;
+
+ try {
+ delegate = LoggerFactory.getLogger(clazz);
+ } catch (Throwable error) {
+ // adapter not found
+ return;
+ }
if (delegate.isTraceEnabled()) {
if (e == null) {
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java 2009-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Repository.java 2009-07-29 23:01:57 UTC (rev 1140)
@@ -28,7 +28,6 @@
import org.jboss.dna.web.jcr.rest.client.Status;
import org.jboss.dna.web.jcr.rest.client.Utils;
import org.jboss.dna.web.jcr.rest.client.domain.validation.RepositoryValidator;
-import org.jboss.dna.web.jcr.rest.client.json.JsonUtils;
/**
* The Repository class is the business object for a DNA repository.
@@ -134,9 +133,7 @@
* @since 0.6
*/
public String getShortDescription() {
- return Utils.getMessage(RepositoryShortDescription,
- JsonUtils.decodeEscaping(this.name),
- this.server.getShortDescription());
+ return Utils.getMessage(RepositoryShortDescription, this.name, this.server.getShortDescription());
}
/**
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java 2009-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/domain/Workspace.java 2009-07-29 23:01:57 UTC (rev 1140)
@@ -28,7 +28,6 @@
import org.jboss.dna.web.jcr.rest.client.Status;
import org.jboss.dna.web.jcr.rest.client.Utils;
import org.jboss.dna.web.jcr.rest.client.domain.validation.WorkspaceValidator;
-import org.jboss.dna.web.jcr.rest.client.json.JsonUtils;
/**
* The Workspace class is the business object for a DNA repository workspace.
@@ -140,9 +139,7 @@
* @since 0.6
*/
public String getShortDescription() {
- return Utils.getMessage(WorkspaceShortDescription,
- JsonUtils.decodeEscaping(this.name),
- this.repository.getShortDescription());
+ return Utils.getMessage(WorkspaceShortDescription, this.name, this.repository.getShortDescription());
}
/**
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java 2009-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClient.java 2009-07-29 23:01:57 UTC (rev 1140)
@@ -30,9 +30,11 @@
import static org.jboss.dna.web.jcr.rest.client.IMessages.GetWorkspacesFailedMsg;
import static org.jboss.dna.web.jcr.rest.client.IMessages.PublishFailedMsg;
import static org.jboss.dna.web.jcr.rest.client.IMessages.UnpublishFailedMsg;
+import static org.jboss.dna.web.jcr.rest.client.IMessages.UnpublishNeverPublishedMsg;
import java.io.File;
-import java.io.IOException;
+import java.net.Authenticator;
import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
import java.net.URL;
import java.util.Collection;
import javax.ws.rs.core.MediaType;
@@ -72,7 +74,7 @@
null,
"createFileNode: workspace=" + workspace.getName() + ", path=" + path + ", file=" + file.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
FileNode fileNode = new FileNode(workspace, path, file);
- HttpURLConnection connection = openConnection(fileNode.getUrl(), RequestMethod.POST);
+ HttpURLConnection connection = openConnection(workspace.getServer(), fileNode.getUrl(), RequestMethod.POST);
try {
Logger.trace(JsonRestClient.class, null, "createFileNode: create node=" + fileNode); //$NON-NLS-1$
@@ -96,7 +98,7 @@
}
} finally {
if (connection != null) {
- Logger.trace(JsonRestClient.class, null, "createFileNode: " + connection.getResponseMessage()); //$NON-NLS-1$
+ Logger.trace(JsonRestClient.class, null, "createFileNode: leaving"); //$NON-NLS-1$
connection.disconnect();
}
}
@@ -114,7 +116,7 @@
String path ) throws Exception {
Logger.trace(JsonRestClient.class, null, "createFolderNode: workspace=" + workspace.getName() + ", path=" + path); //$NON-NLS-1$//$NON-NLS-2$
FolderNode folderNode = new FolderNode(workspace, path);
- HttpURLConnection connection = openConnection(folderNode.getUrl(), RequestMethod.POST);
+ HttpURLConnection connection = openConnection(workspace.getServer(), folderNode.getUrl(), RequestMethod.POST);
try {
Logger.trace(JsonRestClient.class, null, "createFolderNode: create node=" + folderNode); //$NON-NLS-1$
@@ -134,7 +136,7 @@
}
} finally {
if (connection != null) {
- Logger.trace(JsonRestClient.class, null, "createFolderNode: " + connection.getResponseMessage()); //$NON-NLS-1$
+ Logger.trace(JsonRestClient.class, null, "createFolderNode: leaving"); //$NON-NLS-1$
connection.disconnect();
}
}
@@ -153,7 +155,7 @@
Logger.trace(JsonRestClient.class, null, "ensureFolderExists: workspace=" + workspace.getName() + ", path=" + folderPath); //$NON-NLS-1$//$NON-NLS-2$
FolderNode folderNode = new FolderNode(workspace, folderPath);
- if (!pathExists(folderNode.getUrl())) {
+ if (!pathExists(workspace.getServer(), folderNode.getUrl())) {
StringBuilder path = new StringBuilder();
for (char c : folderPath.toCharArray()) {
@@ -161,7 +163,7 @@
if (path.length() > 1) {
folderNode = new FolderNode(workspace, path.toString());
- if (!pathExists(folderNode.getUrl())) {
+ if (!pathExists(workspace.getServer(), folderNode.getUrl())) {
createFolderNode(workspace, folderNode.getPath());
}
}
@@ -173,7 +175,7 @@
if (path.length() == folderPath.length()) {
folderNode = new FolderNode(workspace, path.toString());
- if (!pathExists(folderNode.getUrl())) {
+ if (!pathExists(workspace.getServer(), folderNode.getUrl())) {
createFolderNode(workspace, folderNode.getPath());
}
}
@@ -193,7 +195,7 @@
Logger.trace(JsonRestClient.class, null, "getRepositories: server=" + server); //$NON-NLS-1$
ServerNode serverNode = new ServerNode(server);
- HttpURLConnection connection = openConnection(serverNode.getFindRepositoriesUrl(), RequestMethod.GET);
+ HttpURLConnection connection = openConnection(server, serverNode.getFindRepositoriesUrl(), RequestMethod.GET);
try {
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
@@ -211,7 +213,7 @@
throw new RuntimeException(msg);
} finally {
if (connection != null) {
- Logger.trace(JsonRestClient.class, null, "getRepositories: " + connection.getResponseMessage()); //$NON-NLS-1$
+ Logger.trace(JsonRestClient.class, null, "getRepositories: leaving"); //$NON-NLS-1$
connection.disconnect();
}
}
@@ -228,7 +230,7 @@
Logger.trace(JsonRestClient.class, null, "getWorkspaces: repository=" + repository); //$NON-NLS-1$
RepositoryNode repositoryNode = new RepositoryNode(repository);
- HttpURLConnection connection = openConnection(repositoryNode.getUrl(), RequestMethod.GET);
+ HttpURLConnection connection = openConnection(repository.getServer(), repositoryNode.getUrl(), RequestMethod.GET);
try {
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
@@ -249,22 +251,25 @@
throw new RuntimeException(msg);
} finally {
if (connection != null) {
- Logger.trace(JsonRestClient.class, null, "getWorkspaces: " + connection.getResponseMessage()); //$NON-NLS-1$
+ Logger.trace(JsonRestClient.class, null, "getWorkspaces: leaving"); //$NON-NLS-1$
connection.disconnect();
}
}
}
/**
+ * @param server the server where the connection will be established
* @param url the URL where the connection will be established
* @param method the request method
* @return the open connection which <strong>MUST</strong> be disconnected
* @throws Exception if there is a problem establishing the connection
* @since 0.6
*/
- private HttpURLConnection openConnection( URL url,
+ private HttpURLConnection openConnection( Server server,
+ URL url,
RequestMethod method ) throws Exception {
Logger.trace(JsonRestClient.class, null, "openConnection: url=" + url + ", method=" + method); //$NON-NLS-1$ //$NON-NLS-2$
+ setAuthentication(server.getUser(), server.getPassword());
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod(method.toString());
@@ -273,20 +278,22 @@
}
/**
+ * @param server the server where the URL will be used (never <code>null</code>)
* @param url the path being checked (never <code>null</code>)
* @return <code>true</code> if the path exists
* @throws Exception if there is a problem checking the existence of the path
* @since 0.6
*/
- protected boolean pathExists( URL url ) throws Exception {
+ protected boolean pathExists( Server server,
+ URL url ) throws Exception {
Logger.trace(JsonRestClient.class, null, "pathExists: url=" + url); //$NON-NLS-1$
- HttpURLConnection connection = openConnection(url, RequestMethod.GET);
+ HttpURLConnection connection = openConnection(server, url, RequestMethod.GET);
try {
return (connection.getResponseCode() == HttpURLConnection.HTTP_OK);
} finally {
if (connection != null) {
- Logger.trace(JsonRestClient.class, null, "pathExists: " + connection.getResponseMessage()); //$NON-NLS-1$
+ Logger.trace(JsonRestClient.class, null, "pathExists: leaving"); //$NON-NLS-1$
connection.disconnect();
}
}
@@ -304,7 +311,7 @@
String path,
File file ) throws Exception {
FileNode fileNode = new FileNode(workspace, path, file);
- return pathExists(fileNode.getUrl());
+ return pathExists(workspace.getServer(), fileNode.getUrl());
}
/**
@@ -345,6 +352,19 @@
return Status.OK_STATUS;
}
+ private void setAuthentication( final String user,
+ final String password ) {
+ final String pswd = ((password == null) ? "" : password); //$NON-NLS-1$
+
+ // TODO setAuthentication() make authenticator work with multi-threads
+ Authenticator.setDefault(new Authenticator() {
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(user, pswd.toCharArray());
+ }
+ });
+ }
+
/**
* {@inheritDoc}
*
@@ -366,13 +386,13 @@
try {
FileNode fileNode = new FileNode(workspace, path, file);
- connection = openConnection(fileNode.getUrl(), RequestMethod.DELETE);
+ connection = openConnection(workspace.getServer(), fileNode.getUrl(), RequestMethod.DELETE);
int responseCode = connection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_NO_CONTENT) {
// check to see if the file was never published
- if (!pathExists(fileNode.getUrl())) {
- return new Status(Severity.INFO, Utils.getMessage(PublishFailedMsg,
+ if (!pathExists(workspace.getServer(), fileNode.getUrl())) {
+ return new Status(Severity.INFO, Utils.getMessage(UnpublishNeverPublishedMsg,
file.getAbsolutePath(),
workspace.getName(),
path), null);
@@ -395,12 +415,7 @@
file.getAbsolutePath()), e);
} finally {
if (connection != null) {
- try {
- Logger.trace(JsonRestClient.class, null, "unpublish: " + connection.getResponseMessage()); //$NON-NLS-1$
- } catch (IOException e) {
- Logger.log(JsonRestClient.class, new Status(Severity.ERROR, null, e));
- }
-
+ Logger.trace(JsonRestClient.class, null, "unpublish: leaving"); //$NON-NLS-1$
connection.disconnect();
}
}
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java 2009-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/JsonUtils.java 2009-07-29 23:01:57 UTC (rev 1140)
@@ -25,7 +25,10 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
import org.jboss.dna.web.jcr.rest.client.Utils;
/**
@@ -37,18 +40,41 @@
// ===========================================================================================================================
// Class Methods
// ===========================================================================================================================
+
+ /**
+ * The default character set being used.
+ *
+ * @since 0.6
+ */
+ private static final String DEFAULT_CHARSET = "UTF-8"; //$NON-NLS-1$ // TODO need to property drive charset
+ // ===========================================================================================================================
+ // Class Methods
+ // ===========================================================================================================================
+
/**
* @param text the text whose escape sequences will be replaced with the actual characters (never <code>null</code>)
* @return the decoded text
+ * @throws UnsupportedEncodingException
* @since 0.6
*/
- public static String decodeEscaping( String text ) {
+ public static String decodeEscaping( String text ) throws UnsupportedEncodingException {
Utils.nullArgumentCheck("text", text); //$NON-NLS-1$
- return text.replace("%3a", ":"); //$NON-NLS-1$ //$NON-NLS-2$
+ return URLDecoder.decode(text, DEFAULT_CHARSET);
}
/**
+ * @param text the text whose escape sequences will be replaced with the actual characters (never <code>null</code>)
+ * @return the decoded text
+ * @throws UnsupportedEncodingException
+ * @since 0.6
+ */
+ public static String encodeEscaping( String text ) throws UnsupportedEncodingException {
+ Utils.nullArgumentCheck("text", text); //$NON-NLS-1$
+ return URLEncoder.encode(text, DEFAULT_CHARSET);
+ }
+
+ /**
* Note: The connection is not disconnected during this method.
*
* @param connection the connection whose input stream is going to be read from (never <code>null</code>)
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/RepositoryNode.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/RepositoryNode.java 2009-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/RepositoryNode.java 2009-07-29 23:01:57 UTC (rev 1140)
@@ -80,7 +80,7 @@
StringBuilder url = new StringBuilder(serverNode.getUrl().toString());
// add repository path
- url.append('/').append(repository.getName());
+ url.append('/').append(JsonUtils.encodeEscaping(repository.getName()));
return new URL(url.toString());
}
@@ -98,7 +98,8 @@
// keys are the repository names
for (Iterator<String> itr = jsonObj.keys(); itr.hasNext();) {
- Workspace workspace = new Workspace(itr.next(), this.repository);
+ String name = JsonUtils.decodeEscaping(itr.next());
+ Workspace workspace = new Workspace(name, this.repository);
workspaces.add(workspace);
}
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java 2009-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/ServerNode.java 2009-07-29 23:01:57 UTC (rev 1140)
@@ -112,7 +112,8 @@
// keys are the repository names
for (Iterator<String> itr = jsonObj.keys(); itr.hasNext();) {
- Repository repository = new Repository(itr.next(), this.server);
+ String name = JsonUtils.decodeEscaping(itr.next());
+ Repository repository = new Repository(name, this.server);
repositories.add(repository);
Logger.trace(ServerNode.class, null, "getRepositories: adding repository=" + repository); //$NON-NLS-1$
}
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java 2009-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/json/WorkspaceNode.java 2009-07-29 23:01:57 UTC (rev 1140)
@@ -64,9 +64,9 @@
public URL getUrl() throws Exception {
RepositoryNode repositoryNode = new RepositoryNode(this.workspace.getRepository());
StringBuilder url = new StringBuilder(repositoryNode.getUrl().toString());
-
+
// add workspace path
- url.append('/').append(workspace.getName()).append(IJsonConstants.WORKSPACE_CONTEXT);
+ url.append('/').append(JsonUtils.encodeEscaping(workspace.getName())).append(IJsonConstants.WORKSPACE_CONTEXT);
return new URL(url.toString());
}
Modified: branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java 2009-07-29 22:37:55 UTC (rev 1139)
+++ branches/eclipse/dna-web-jcr-rest-client/src/test/java/org/jboss/dna/web/jcr/rest/client/json/JsonRestClientTest.java 2009-07-29 23:01:57 UTC (rev 1140)
@@ -54,7 +54,7 @@
private static final String USER = "dnauser"; //$NON-NLS-1$
private static final Server SERVER = new Server("http://localhost:8080", USER, PSWD, false); //$NON-NLS-1$
- private static final String REPOSITORY_NAME = "dna%3arepository"; //$NON-NLS-1$
+ private static final String REPOSITORY_NAME = "dna:repository"; //$NON-NLS-1$
private static final Repository REPOSITORY1 = new Repository(REPOSITORY_NAME, SERVER);
private static final String WORKSPACE_NAME = "default"; //$NON-NLS-1$
private static final Workspace WORKSPACE1 = new Workspace(WORKSPACE_NAME, REPOSITORY1);
16 years, 5 months
DNA SVN: r1139 - in branches/eclipse: org.jboss.dna.publish.ui.swt/META-INF and 9 other directories.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-07-29 18:37:55 -0400 (Wed, 29 Jul 2009)
New Revision: 1139
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/checkbox.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/refresh.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java
Removed:
branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT.jar
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/.classpath
branches/eclipse/org.jboss.dna.publish.ui.swt/META-INF/MANIFEST.MF
branches/eclipse/org.jboss.dna.publish.ui.swt/build.properties
branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-sources.jar
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/I18n.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/BasePublishingAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/EditServerAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/NewServerAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/i18n.properties
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerContentProvider.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerView.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java
branches/eclipse/org.jboss.dna.web.jcr.rest.client.swt.updatesite/artifacts.xml
branches/eclipse/org.jboss.dna.web.jcr.rest.client.swt.updatesite/content.xml
branches/eclipse/org.jboss.dna.web.jcr.rest.client.swt.updatesite/features/org.jboss.dna.web.jcr.rest.client.swt.feature_1.0.0.v20090708.jar
branches/eclipse/org.jboss.dna.web.jcr.rest.client.swt.updatesite/plugins/org.jboss.dna.web.jcr.rest.client.swt_1.0.0.jar
Log:
Finished implementation of PublishOperation. Added refresh to ServerView. Added popup dialogs for when there is a problem accessing a server. Now depending on a jar of the non-UI maven project that has all its dependencies included in the jar. Using URLDecoder and URLEncoder instead of methods I had written. Did some work with sizing and setting location of dialogs. Added a results dialog after a publish or unpublish operation is finished (regardless if an error occurred). Setting DNA image on dialog title bars.
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/.classpath
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/.classpath 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/.classpath 2009-07-29 22:37:55 UTC (rev 1139)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry exported="true" kind="lib" path="dna-web-jcr-rest-client-0.6-SNAPSHOT.jar" sourcepath="dna-web-jcr-rest-client-0.6-SNAPSHOT-sources.jar"/>
+ <classpathentry exported="true" kind="lib" path="dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/META-INF/MANIFEST.MF
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/META-INF/MANIFEST.MF 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/META-INF/MANIFEST.MF 2009-07-29 22:37:55 UTC (rev 1139)
@@ -11,5 +11,5 @@
org.eclipse.core.resources
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: dna-web-jcr-rest-client-0.6-SNAPSHOT.jar,
+Bundle-ClassPath: dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar,
dnaPublishUi.jar
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/build.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/build.properties 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/build.properties 2009-07-29 22:37:55 UTC (rev 1139)
@@ -10,9 +10,9 @@
plugin.properties,\
icons/,\
plugin.xml,\
- dna-web-jcr-rest-client-0.6-SNAPSHOT.jar,\
LEGAL.txt,\
- AUTHORS.txt
+ AUTHORS.txt,\
+ dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar
src.includes = src/,\
LEGAL.txt
source.dnaPublishUi.jar = src/
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-sources.jar
===================================================================
(Binary files differ)
Deleted: branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT.jar
===================================================================
(Binary files differ)
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/checkbox.gif
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/checkbox.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif
===================================================================
(Binary files differ)
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif (rev 0)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif 2009-07-29 22:37:55 UTC (rev 1139)
@@ -0,0 +1,3 @@
+GIF89a
+*�7
\ No newline at end of file
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/refresh.gif
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/refresh.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/I18n.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/I18n.java 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/I18n.java 2009-07-29 22:37:55 UTC (rev 1139)
@@ -56,10 +56,10 @@
public static String NewServerActionText;
public static String NewServerActionToolTip;
+ public static String PublishOperationPublishNotAttemptedMsg;
public static String PublishOperationPublishTaskName;
- public static String PublishOperationPublishTitle;
+ public static String PublishOperationUnpublishNotAttemptedMsg;
public static String PublishOperationUnpublishTaskName;
- public static String PublishOperationUnpublishTitle;
public static String PublishPagePublishTitle;
public static String PublishPageLocationGroupTitle;
@@ -87,12 +87,25 @@
public static String PublishPageWorkspaceLabel;
public static String PublishPageWorkspacePublishToolTip;
public static String PublishPageWorkspaceUnpublishToolTip;
+
+ public static String PublishResultsDialogErrorPublishingMsg;
+ public static String PublishResultsDialogErrorUnpublishingMsg;
+ public static String PublishResultsDialogFileHeader;
+ public static String PublishResultsDialogMessageHeader;
+ public static String PublishResultsDialogPublishMsg;
+ public static String PublishResultsDialogTitle;
+ public static String PublishResultsDialogUnpublishMsg;
public static String PublishWizardPublishErrorMsg;
public static String PublishWizardPublishTitle;
public static String PublishWizardUnpublishTitle;
public static String PublishWizardUnpublishErrorMsg;
-
+
+ public static String RefreshActionToolTip;
+
+ public static String ServerManagerGetRepositoriesExceptionMsg;
+ public static String ServerManagerGetWorkspacesExceptionMsg;
+
public static String ServerPageAuthenticationGroupTitle;
public static String ServerPageInvalidServerProperties;
public static String ServerPageOkStatusMsg;
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java 2009-07-29 22:37:55 UTC (rev 1139)
@@ -56,6 +56,8 @@
String VIEWS_ICON_FOLDER = ICON_PATH + "views/"; //$NON-NLS-1$
+ String CHECKBOX_IMAGE_PATH = VIEWS_ICON_FOLDER + "checkbox.gif"; //$NON-NLS-1$
+
String COLLAPSE_ALL_IMAGE_PATH = VIEWS_ICON_FOLDER + "collapse_all.gif"; //$NON-NLS-1$
String DNA_WINDOW_IMAGE_PATH = VIEWS_ICON_FOLDER + "dna_window.png"; //$NON-NLS-1$
@@ -64,6 +66,8 @@
String NEW_SERVER_IMAGE_PATH = VIEWS_ICON_FOLDER + "new_server.gif"; //$NON-NLS-1$
+ String REFRESH_IMAGE_PATH = VIEWS_ICON_FOLDER + "refresh.gif"; //$NON-NLS-1$
+
//
// /icons/wizards/
//
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java 2009-07-29 22:37:55 UTC (rev 1139)
@@ -24,6 +24,11 @@
package org.jboss.dna.web.jcr.rest.client.swt;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISharedImages;
import org.jboss.dna.web.jcr.rest.client.Status;
import org.jboss.dna.web.jcr.rest.client.Status.Severity;
@@ -38,6 +43,42 @@
// ===========================================================================================================================
/**
+ * Sizes the shell to the minimum of it's current size or the width and height display percentages.
+ *
+ * @param shell the shell being resized if necessary and located
+ * @param widthPercentage a number between 1 and 100 indicating a percentage of the screen size (defaults to 50 if bad value)
+ * @param heightPercentage a number between 1 and 100 indicating a percentage of the screen size (defaults to 50 if bad value)
+ * @since 0.6
+ */
+ public static void sizeShellRelativeToDisplayAndCentery( Shell shell,
+ int widthPercentage,
+ int heightPercentage ) {
+ if ((widthPercentage < 1) || (widthPercentage > 100)) {
+ widthPercentage = 50;
+ }
+
+ if ((heightPercentage < 1) || (heightPercentage > 100)) {
+ heightPercentage = 50;
+ }
+
+ // size
+ Rectangle shellBounds = shell.getBounds();
+ Rectangle displayBounds = shell.getDisplay().getClientArea();
+ int scaledWidth = displayBounds.width * widthPercentage / 100;
+ int scaledHeight = displayBounds.height * heightPercentage / 100;
+ shell.setSize(Math.min(scaledWidth, shellBounds.width), Math.min(scaledHeight, shellBounds.height));
+ Point size = shell.getSize();
+
+ // center
+ int excessX = displayBounds.width - size.x;
+ int excessY = displayBounds.height - size.y;
+ int x = displayBounds.x + (excessX / 2);
+ int y = displayBounds.y + (excessY / 2);
+
+ shell.setLocation(x, y);
+ }
+
+ /**
* Converts the non-Eclipse status severity to an Eclipse severity level. An {@link Status.Severity#UNKNOWN unknown status} is
* converted to {@link IStatus#CANCEL cancel}. A {@link Status.Severity} is
*
@@ -70,6 +111,31 @@
return Severity.UNKNOWN;
}
+ /**
+ * The OK status does not have an image.
+ *
+ * @param status the status whose image is being requested
+ * @return the image or <code>null</code> if no associated image for the status severity
+ * @since 0.6
+ */
+ public static Image getImage( Status status ) {
+ String imageId = null;
+
+ if (status.isError()) {
+ imageId = ISharedImages.IMG_OBJS_ERROR_TSK;
+ } else if (status.isInfo()) {
+ imageId = ISharedImages.IMG_OBJS_INFO_TSK;
+ } else if (status.isWarning()) {
+ imageId = ISharedImages.IMG_OBJS_WARN_TSK;
+ }
+
+ if (imageId != null) {
+ return Activator.getDefault().getSharedImage(imageId);
+ }
+
+ return null;
+ }
+
// ===========================================================================================================================
// Constructors
// ===========================================================================================================================
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/BasePublishingAction.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/BasePublishingAction.java 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/BasePublishingAction.java 2009-07-29 22:37:55 UTC (rev 1139)
@@ -23,6 +23,7 @@
*/
package org.jboss.dna.web.jcr.rest.client.swt.actions;
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_WINDOW_IMAGE_PATH;
import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IResource;
@@ -111,7 +112,16 @@
// run wizard
try {
- new WizardDialog(shell, new PublishWizard(this.type, resources, Activator.getDefault().getServerManager())).open();
+ WizardDialog dialog = new WizardDialog(shell, new PublishWizard(this.type, resources,
+ Activator.getDefault().getServerManager())) {
+ @Override
+ protected void configureShell( Shell newShell ) {
+ super.configureShell(newShell);
+ newShell.setImage(Activator.getDefault().getImage(DNA_WINDOW_IMAGE_PATH));
+ }
+ };
+
+ dialog.open();
} catch (CoreException e) {
String msg = null;
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/EditServerAction.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/EditServerAction.java 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/EditServerAction.java 2009-07-29 22:37:55 UTC (rev 1139)
@@ -23,6 +23,7 @@
*/
package org.jboss.dna.web.jcr.rest.client.swt.actions;
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_WINDOW_IMAGE_PATH;
import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.EDIT_SERVER_IMAGE_PATH;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
@@ -98,7 +99,15 @@
@Override
public void run() {
ServerWizard wizard = new ServerWizard(this.serverManager, this.serverBeingEdited);
- new WizardDialog(this.shell, wizard).open();
+ WizardDialog dialog = new WizardDialog(this.shell, wizard) {
+ @Override
+ protected void configureShell( Shell newShell ) {
+ super.configureShell(newShell);
+ newShell.setImage(Activator.getDefault().getImage(DNA_WINDOW_IMAGE_PATH));
+ }
+ };
+
+ dialog.open();
}
/**
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/NewServerAction.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/NewServerAction.java 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/NewServerAction.java 2009-07-29 22:37:55 UTC (rev 1139)
@@ -23,6 +23,7 @@
*/
package org.jboss.dna.web.jcr.rest.client.swt.actions;
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_WINDOW_IMAGE_PATH;
import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.NEW_SERVER_IMAGE_PATH;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
@@ -88,7 +89,15 @@
@Override
public void run() {
ServerWizard wizard = new ServerWizard(this.serverManager);
- new WizardDialog(this.shell, wizard).open();
+ WizardDialog dialog = new WizardDialog(this.shell, wizard) {
+ @Override
+ protected void configureShell( Shell newShell ) {
+ super.configureShell(newShell);
+ newShell.setImage(Activator.getDefault().getImage(DNA_WINDOW_IMAGE_PATH));
+ }
+ };
+
+ dialog.open();
}
}
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java (rev 0)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java 2009-07-29 22:37:55 UTC (rev 1139)
@@ -0,0 +1,336 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you 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.
+ *
+ * JBoss DNA 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.jboss.dna.web.jcr.rest.client.swt.dialogs;
+
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.CHECKBOX_IMAGE_PATH;
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_WINDOW_IMAGE_PATH;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.swt.Activator;
+import org.jboss.dna.web.jcr.rest.client.swt.I18n;
+import org.jboss.dna.web.jcr.rest.client.swt.Utils;
+import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation;
+
+/**
+ * The <code>DeleteServerDialog</code> class provides a UI for deleting a {@link Server server}.
+ *
+ * @author Dan Florian
+ * @since 0.6
+ */
+public class PublishingResultsDialog extends MessageDialog {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ private static final int FILE_COL = 0;
+
+ private static final int SEVERITY_COL = 1;
+
+ private static final int MESSAGE_COL = 2;
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * An error caught during the publish operation (may be <code>null</code>).
+ *
+ * @since 0.6
+ */
+ private Throwable error;
+
+ /**
+ * The list of files that were published or unpublished.
+ *
+ * @since 0.6
+ */
+ private final List<IFile> files;
+
+ /**
+ * The status of the publish or unpublish operation for each file.
+ *
+ * @since 0.6
+ */
+ private final List<Status> statuses;
+
+ /**
+ * The operation type.
+ *
+ * @since 0.6
+ */
+ private final PublishOperation.Type type;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param parentShell the dialog parent
+ * @param type the operation type (publish or unpublish)
+ * @param files the files used in the operation
+ * @param statuses the operation status of each file
+ * @since 0.6
+ */
+ public PublishingResultsDialog( Shell parentShell,
+ PublishOperation.Type type,
+ List<IFile> files,
+ List<Status> statuses ) {
+ super(parentShell, I18n.PublishResultsDialogTitle, Activator.getDefault().getImage(DNA_WINDOW_IMAGE_PATH), null,
+ MessageDialog.INFORMATION, new String[] {IDialogConstants.OK_LABEL}, 0);
+ this.files = files;
+ this.statuses = statuses;
+ this.type = type;
+
+ // make sure dialog is resizable
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ }
+
+ /**
+ * @param parentShell the dialog parent
+ * @param type the operation type (publish or unpublish)
+ * @param files the files used in the operation
+ * @param statuses the operation status of each file
+ * @param error an unexpected error caught during the publish operation
+ * @since 0.6
+ */
+ public PublishingResultsDialog( Shell parentShell,
+ PublishOperation.Type type,
+ List<IFile> files,
+ List<Status> statuses,
+ Throwable error ) {
+ super(parentShell, I18n.PublishResultsDialogTitle, Activator.getDefault().getImage(DNA_WINDOW_IMAGE_PATH), null,
+ MessageDialog.ERROR, new String[] {IDialogConstants.OK_LABEL}, 0);
+ this.files = files;
+ this.statuses = statuses;
+ this.type = type;
+ this.error = error;
+
+ // make sure dialog is resizable
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.MessageDialog#configureShell(org.eclipse.swt.widgets.Shell)
+ * @since 0.6
+ */
+ @Override
+ protected void configureShell( Shell shell ) {
+ super.configureShell(shell);
+
+ // now set message
+ if (this.type == PublishOperation.Type.PUBLISH) {
+ this.message = ((this.error == null) ? I18n.PublishResultsDialogPublishMsg : I18n.bind(I18n.PublishResultsDialogErrorPublishingMsg,
+ this.error.getLocalizedMessage()));
+ } else {
+ this.message = ((this.error == null) ? I18n.PublishResultsDialogUnpublishMsg : I18n.bind(I18n.PublishResultsDialogErrorUnpublishingMsg,
+ this.error.getLocalizedMessage()));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.window.Window#constrainShellSize()
+ * @since 0.6
+ */
+ @Override
+ protected void constrainShellSize() {
+ super.constrainShellSize();
+ Utils.sizeShellRelativeToDisplayAndCentery(getShell(), 50, 50);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
+ * @since 0.6
+ */
+ @Override
+ protected Control createCustomArea( Composite parent ) {
+ Composite pnl = new Composite(parent, SWT.NONE);
+ pnl.setLayout(new GridLayout());
+ GridData gd = new GridData(SWT.LEFT, SWT.CENTER, true, true);
+ pnl.setLayoutData(gd);
+
+ TableViewer viewer = new TableViewer(pnl, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
+ ResultsProvider provider = new ResultsProvider();
+ viewer.setContentProvider(provider);
+ viewer.setLabelProvider(provider);
+
+ Table table = viewer.getTable();
+ table.setLayout(new GridLayout());
+ table.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true));
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ TableColumn col = new TableColumn(table, SWT.LEFT);
+ col.setText(I18n.PublishResultsDialogFileHeader);
+
+ col = new TableColumn(table, SWT.LEFT);
+ col.setResizable(false);
+
+ col = new TableColumn(table, SWT.LEFT);
+ col.setText(I18n.PublishResultsDialogMessageHeader);
+
+ // populate the table
+ viewer.setInput(this);
+
+ // size columns
+ for (TableColumn column : table.getColumns()) {
+ column.pack();
+ column.setWidth(column.getWidth() + 2);
+ }
+
+ return pnl;
+ }
+
+ /**
+ * @return the files that were involved in the publishing operation
+ * @since 0.6
+ */
+ List<IFile> getFiles() {
+ return this.files;
+ }
+
+ /**
+ * @param index the index of the status being requested
+ * @return the status
+ * @since 0.6
+ */
+ Status getStatus( int index ) {
+ return this.statuses.get(index);
+ }
+
+ // ===========================================================================================================================
+ // Inner Class
+ // ===========================================================================================================================
+
+ /**
+ * The <code>ResultsProvider</code> class is the label provider and content provider for the table that is shown in the
+ * dialog.
+ *
+ * @author Dan Florian
+ * @since 0.6
+ */
+ class ResultsProvider extends LabelProvider implements IStructuredContentProvider, ITableLabelProvider {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ * @since 0.6
+ */
+ @Override
+ public Image getColumnImage( Object element,
+ int columnIndex ) {
+ if (columnIndex == SEVERITY_COL) {
+ Status status = getStatus(getFiles().indexOf(element));
+
+ if (status.isOk()) {
+ return Activator.getDefault().getImage(CHECKBOX_IMAGE_PATH);
+ }
+
+ return Utils.getImage(status);
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
+ * @since 0.6
+ */
+ @Override
+ public String getColumnText( Object element,
+ int columnIndex ) {
+ if (columnIndex == FILE_COL) {
+ return ((IFile)element).getFullPath().toString();
+ }
+
+ if (columnIndex == MESSAGE_COL) {
+ Status status = getStatus(getFiles().indexOf(element));
+
+ if (!status.isOk()) {
+ return status.getMessage();
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public Object[] getElements( Object inputElement ) {
+ return getFiles().toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object,
+ * java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public void inputChanged( Viewer viewer,
+ Object oldInput,
+ Object newInput ) {
+ // nothing to do
+ }
+
+ }
+
+}
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/i18n.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/i18n.properties 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/i18n.properties 2009-07-29 22:37:55 UTC (rev 1139)
@@ -44,10 +44,11 @@
NewServerActionText = New Server
NewServerActionToolTip = Create and register a new server
+PublishOperationPublishNotAttemptedMsg = Publishing not attempted
+PublishOperationUnpublishNotAttemptedMsg = Unpublishing not attempted
PublishOperationPublishTaskName = Publishing resources
-PublishOperationPublishTitle = Publish
+PublishOperationUnpublishNotAttemptedMsg = Unpublishing not attempted
PublishOperationUnpublishTaskName = Unpublishing resources
-PublishOperationUnpublishTitle = Unpublish
PublishPagePublishTitle = Publish the selected resources
PublishPageLocationGroupTitle = Location
@@ -60,7 +61,7 @@
PublishPageNoAvailableWorkspacesStatusMsg = There are no workspaces available on that server and repository
PublishPageNoResourcesToPublishStatusMsg = There are no files that can be published
PublishPageNoResourcesToUnpublishStatusMsg = There are no files that can be unpublished
-PublishPagePublishOkStatusMsg = Choose the server, repository, and workspace where the selected resources will be published.
+PublishPagePublishOkStatusMsg = Choose the server, repository, and workspace where the selected resources will be published. Then click "Finish" to execute the publish operation.
PublishPagePublishResourcesLabel = These resources will be published to the specified DNA repository:
PublishPageRecurseCheckBox = Recurse folders and projects
PublishPageRecurseCheckBoxToolTip = Add all files under folders recursively under selected projects and folders
@@ -69,18 +70,31 @@
PublishPageRepositoryToolTip = The repository where the workspace is located
PublishPageServerLabel = Server:
PublishPageServerToolTip = The server where the repository is located
-PublishPageUnpublishOkStatusMsg = Choose the server, repository, and workspace where the selected resources will be unpublished.
+PublishPageUnpublishOkStatusMsg = Choose the server, repository, and workspace where the selected resources will be unpublished. Then click "Finish" to execute the unpublish operation.
PublishPageUnpublishResourcesLabel = These resources will be unpublished from the specified DNA repository:
PublishPageUnpublishTitle = Unpublish the selected resources
PublishPageWorkspaceLabel = Workspace:
PublishPageWorkspacePublishToolTip = The workspace where the resources are being published
PublishPageWorkspaceUnpublishToolTip = The workspace where the resources are being unpublished
+PublishResultsDialogErrorPublishingMsg = There was a problem publishing some or all of the files. See results below and the log for more details. Error message: "{0}."
+PublishResultsDialogErrorUnpublishingMsg = There was a problem publishing some or all of the files. See results below and the log for more details. Error message: "{0}."
+PublishResultsDialogFileHeader = File
+PublishResultsDialogMessageHeader = Message
+PublishResultsDialogPublishMsg = Here are the results of the publishing request.
+PublishResultsDialogTitle = Results
+PublishResultsDialogUnpublishMsg = Here are the results of the unpublishing request.
+
PublishWizardPublishErrorMsg = Error Publishing
PublishWizardPublishTitle = Publish
PublishWizardUnpublishErrorMsg = Error Unpublishing
PublishWizardUnpublishTitle = Unpublish
+RefreshActionToolTip = Refresh
+
+ServerManagerGetRepositoriesExceptionMsg = There was a problem obtaining repositories for the server "{0}."
+ServerManagerGetWorkspacesExceptionMsg = There was a problem obtaining workspaces for repository "{0}."
+
ServerPageAuthenticationGroupTitle = Authentication
ServerPageInvalidServerProperties = Cannot construct a server because all server properties are not valid
ServerPageOkStatusMsg = Define the server information where the DNA repositories are located.
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerContentProvider.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerContentProvider.java 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerContentProvider.java 2009-07-29 22:37:55 UTC (rev 1139)
@@ -23,17 +23,21 @@
*/
package org.jboss.dna.web.jcr.rest.client.swt.views;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;
import org.jboss.dna.web.jcr.rest.client.ServerManager;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.Status.Severity;
import org.jboss.dna.web.jcr.rest.client.domain.IDnaObject;
import org.jboss.dna.web.jcr.rest.client.domain.Repository;
import org.jboss.dna.web.jcr.rest.client.domain.Server;
import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
import org.jboss.dna.web.jcr.rest.client.swt.Activator;
+import org.jboss.dna.web.jcr.rest.client.swt.I18n;
/**
* The ServerContentProvider is a content and label provider for DNA repositories.
@@ -47,8 +51,20 @@
// Fields
// ===========================================================================================================================
+ /**
+ * The server manager where the server registry is managed.
+ *
+ * @since 0.6
+ */
private final ServerManager serverManager;
+ /**
+ * The viewer using this content provider.
+ *
+ * @since 0.6
+ */
+ private Viewer viewer;
+
// ===========================================================================================================================
// Constructors
// ===========================================================================================================================
@@ -97,12 +113,30 @@
public Object[] getChildren( Object parentElement ) {
assert (parentElement instanceof IDnaObject);
- if (parentElement instanceof Server) {
- return this.serverManager.getRepositories((Server)parentElement).toArray();
+ try {
+ if (parentElement instanceof Server) {
+ return this.serverManager.getRepositories((Server)parentElement).toArray();
+ }
+ } catch (Exception e) {
+ String msg = I18n.bind(I18n.ServerManagerGetRepositoriesExceptionMsg, ((Server)parentElement).getShortDescription());
+ Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
+
+ if (this.viewer.getControl().isVisible()) {
+ MessageDialog.openError(this.viewer.getControl().getShell(), I18n.ErrorDialogTitle, msg);
+ }
}
- if (parentElement instanceof Repository) {
- return this.serverManager.getWorkspaces((Repository)parentElement).toArray();
+ try {
+ if (parentElement instanceof Repository) {
+ return this.serverManager.getWorkspaces((Repository)parentElement).toArray();
+ }
+ } catch (Exception e) {
+ String msg = I18n.ServerManagerGetWorkspacesExceptionMsg;
+ Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
+
+ if (this.viewer.getControl().isVisible()) {
+ MessageDialog.openError(this.viewer.getControl().getShell(), I18n.ErrorDialogTitle, msg);
+ }
}
return new Object[0];
@@ -163,10 +197,10 @@
assert (element instanceof IDnaObject);
return ((IDnaObject)element).getName();
}
-
+
/**
* {@inheritDoc}
- *
+ *
* @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipImage(java.lang.Object)
* @since 0.6
*/
@@ -192,7 +226,7 @@
/**
* {@inheritDoc}
- *
+ *
* @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipTimeDisplayed(java.lang.Object)
* @since 0.6
*/
@@ -223,7 +257,7 @@
public void inputChanged( Viewer viewer,
Object oldInput,
Object newInput ) {
- // nothing to do
+ this.viewer = viewer;
}
/**
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerView.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerView.java 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerView.java 2009-07-29 22:37:55 UTC (rev 1139)
@@ -24,6 +24,7 @@
package org.jboss.dna.web.jcr.rest.client.swt.views;
import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.COLLAPSE_ALL_IMAGE_PATH;
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.REFRESH_IMAGE_PATH;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
@@ -99,8 +100,15 @@
private ServerContentProvider provider;
/**
+ * Refreshes the tree.
+ *
* @since 0.6
*/
+ private IAction refreshAction;
+
+ /**
+ * @since 0.6
+ */
private TreeViewer viewer;
// ===========================================================================================================================
@@ -122,6 +130,17 @@
this.collapseAllAction.setToolTipText(I18n.CollapseActionToolTip);
this.collapseAllAction.setImageDescriptor(Activator.getDefault().getImageDescriptor(COLLAPSE_ALL_IMAGE_PATH));
+ // the refresh action is always enabled
+ this.refreshAction = new Action() {
+ @Override
+ public void run() {
+ getViewer().refresh();
+ }
+ };
+
+ this.refreshAction.setToolTipText(I18n.RefreshActionToolTip);
+ this.refreshAction.setImageDescriptor(Activator.getDefault().getImageDescriptor(REFRESH_IMAGE_PATH));
+
// the shell used for dialogs that the actions display
Shell shell = this.getSite().getShell();
@@ -161,6 +180,7 @@
toolBar.add(this.newAction);
toolBar.add(this.editAction);
toolBar.add(this.deleteAction);
+ toolBar.add(this.refreshAction);
toolBar.add(this.collapseAllAction);
}
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java 2009-07-29 22:37:55 UTC (rev 1139)
@@ -25,44 +25,63 @@
import java.io.File;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.Status.Severity;
import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+import org.jboss.dna.web.jcr.rest.client.swt.Activator;
import org.jboss.dna.web.jcr.rest.client.swt.I18n;
/**
* @author Dan Florian
* @since 0.6
*/
-public class PublishOperation implements IRunnableWithProgress {
+public class PublishOperation {
// ===========================================================================================================================
// Constants
// ===========================================================================================================================
/**
- * The wizard type.
+ * The operation type.
*
* @since 0.6
*/
public enum Type {
/**
- * Indicates the wizard will be used to publish.
+ * Indicates a publish operation.
*
* @since 0.6
*/
PUBLISH,
/**
- * Indicates the wizard will be used to unpublish.
+ * Indicates an unpublish operation.
*
* @since 0.6
*/
UNPUBLISH
}
+ /**
+ * Status indicating the file was not attempted to be published.
+ *
+ * @since 0.6
+ */
+ private static final Status PUBLISH_NOT_ATTEMPTED_STATUS = new Status(Severity.INFO,
+ I18n.PublishOperationPublishNotAttemptedMsg, null);
+
+ /**
+ * Status indicating the file was not attempted to be published.
+ *
+ * @since 0.6
+ */
+ private static final Status UNPUBLISH_NOT_ATTEMPTED_STATUS = new Status(Severity.INFO,
+ I18n.PublishOperationUnpublishNotAttemptedMsg, null);
+
// ===========================================================================================================================
// Fields
// ===========================================================================================================================
@@ -82,6 +101,13 @@
private final Type type;
/**
+ * The operation status for each file.
+ *
+ * @since 0.6
+ */
+ private List<Status> statuses;
+
+ /**
* The workspace to use when publishing or unpublishing.
*
* @since 0.6
@@ -93,9 +119,9 @@
// ===========================================================================================================================
/**
- * @param type the operation type
- * @param files the files being published or unpublished
- * @param workspace the workspace to use when publishing or unpublishing
+ * @param type the operation type (never <code>null</code>)
+ * @param files the files being published or unpublished (never <code>null</code>)
+ * @param workspace the workspace to use when publishing or unpublishing (never <code>null</code>)
* @since 0.6
*/
public PublishOperation( Type type,
@@ -111,11 +137,11 @@
// ===========================================================================================================================
/**
- * @return the operation title
+ * @return the operation status of each file (never <code>null</code> and always one status for each file)
* @since 0.6
*/
- public String getTitle() {
- return ((this.type == Type.PUBLISH) ? I18n.PublishOperationPublishTitle : I18n.PublishOperationUnpublishTitle);
+ public List<Status> getStatus() {
+ return this.statuses;
}
/**
@@ -135,31 +161,54 @@
}
/**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
+ * @param monitor the progress monitor
+ * @throws InvocationTargetException if an unexpected error occurs
+ * @throws InterruptedException if the user cancels the monitor
* @since 0.6
*/
- @Override
- public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException {
+ public void execute( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException {
assert (this.workspace != null);
+ this.statuses = new ArrayList<Status>(this.files.size());
+
try {
String name = (isPublishing() ? I18n.PublishOperationPublishTaskName : I18n.PublishOperationUnpublishTaskName);
monitor.beginTask(name, this.files.size());
+ monitor.setTaskName(name);
- for (IFile eclipseFile : this.files) {
+ for (IFile eclipseFile : this.files) {
+
+ if (monitor.isCanceled()) {
+ throw new InterruptedException();
+ }
+
File file = eclipseFile.getLocation().toFile();
// TODO call publisher here (timeout?)
+ if (isPublishing()) {
+ this.statuses.add(Activator.getDefault().getServerManager().publish(this.workspace,
+ eclipseFile.getFullPath().toString(),
+ file));
+ } else {
+ this.statuses.add(Activator.getDefault().getServerManager().unpublish(this.workspace,
+ eclipseFile.getFullPath().toString(),
+ file));
+ }
monitor.worked(1);
-
- if (monitor.isCanceled()) {
- break;
- }
}
+ } catch (InterruptedException e) {
+ throw e;
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
+ // ensure there is a status for each file
+ if (this.files.size() != this.statuses.size()) {
+ Status status = (isPublishing() ? PUBLISH_NOT_ATTEMPTED_STATUS : UNPUBLISH_NOT_ATTEMPTED_STATUS);
+
+ for (int count = this.files.size() - this.statuses.size(), i = 0; i < count; ++i) {
+ this.statuses.add(status);
+ }
+ }
+
monitor.done();
}
}
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java 2009-07-29 22:37:55 UTC (rev 1139)
@@ -614,7 +614,10 @@
loadFiles();
} catch (CoreException e) {
Activator.getDefault().log(new Status(Severity.ERROR, I18n.PublishPageRecurseProcessingErrorMsg, e));
- MessageDialog.openError(getShell(), I18n.ErrorDialogTitle, I18n.PublishPageRecurseProcessingErrorMsg);
+
+ if (getControl().isVisible()) {
+ MessageDialog.openError(getShell(), I18n.ErrorDialogTitle, I18n.PublishPageRecurseProcessingErrorMsg);
+ }
}
}
@@ -738,7 +741,17 @@
if (this.server == null) {
this.repositories = Collections.emptyList();
} else {
- this.repositories = new ArrayList<Repository>(getServerManager().getRepositories(this.server));
+ try {
+ this.repositories = new ArrayList<Repository>(getServerManager().getRepositories(this.server));
+ } catch (Exception e) {
+ this.repositories = Collections.emptyList();
+ String msg = I18n.bind(I18n.ServerManagerGetRepositoriesExceptionMsg, this.server.getShortDescription());
+ Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
+
+ if (getControl().isVisible()) {
+ MessageDialog.openError(getShell(), I18n.ErrorDialogTitle, msg);
+ }
+ }
}
// uninstall listeners to prevent handling events
@@ -840,7 +853,17 @@
if (this.repository == null) {
this.workspaces = Collections.emptyList();
} else {
- this.workspaces = new ArrayList<Workspace>(getServerManager().getWorkspaces(this.repository));
+ try {
+ this.workspaces = new ArrayList<Workspace>(getServerManager().getWorkspaces(this.repository));
+ } catch (Exception e) {
+ this.workspaces = Collections.emptyList();
+ String msg = I18n.ServerManagerGetWorkspacesExceptionMsg;
+ Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
+
+ if (getControl().isVisible()) {
+ MessageDialog.openError(getShell(), I18n.ErrorDialogTitle, msg);
+ }
+ }
}
// uninstall listeners to prevent handling events
@@ -921,19 +944,15 @@
// set initial status
validate();
+ // update OK/Finish button enablement
+ setPageComplete(!this.status.isError());
+
// set initial message
- String initialMsg = ((this.type == Type.PUBLISH) ? I18n.PublishPagePublishOkStatusMsg : I18n.PublishPageUnpublishOkStatusMsg);
-
- // if no resources to publish set the message to that else set to initial message
- if (!this.status.isOk()) {
- if (I18n.PublishPageNoResourcesToPublishStatusMsg.equals(this.status.getMessage())
- || I18n.PublishPageNoResourcesToUnpublishStatusMsg.equals(this.status.getMessage())) {
- setErrorMessage(this.status.getMessage());
- } else {
- setMessage(initialMsg);
- }
+ if (this.status.isOk()) {
+ String msg = ((this.type == Type.PUBLISH) ? I18n.PublishPagePublishOkStatusMsg : I18n.PublishPageUnpublishOkStatusMsg);
+ setMessage(msg);
} else {
- setMessage(initialMsg);
+ setErrorMessage(this.status.getMessage());
}
}
}
@@ -995,7 +1014,7 @@
} else if (this.status.isInfo()) {
setMessage(this.status.getMessage(), IMessageProvider.INFORMATION);
} else {
- setMessage(I18n.ServerPageOkStatusMsg);
+ setMessage(this.status.getMessage());
}
}
}
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java 2009-07-29 22:37:55 UTC (rev 1139)
@@ -29,8 +29,10 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.Wizard;
import org.jboss.dna.web.jcr.rest.client.ServerManager;
import org.jboss.dna.web.jcr.rest.client.Status;
@@ -38,6 +40,7 @@
import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
import org.jboss.dna.web.jcr.rest.client.swt.Activator;
import org.jboss.dna.web.jcr.rest.client.swt.I18n;
+import org.jboss.dna.web.jcr.rest.client.swt.dialogs.PublishingResultsDialog;
import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation.Type;
/**
@@ -148,19 +151,47 @@
*/
@Override
public boolean performFinish() {
+ Throwable error = null;
Workspace workspace = this.page.getWorkspace();
List<IFile> files = this.page.getFiles();
- PublishOperation operation = new PublishOperation(this.type, files, workspace);
+ final PublishOperation operation = new PublishOperation(this.type, files, workspace);
+ // display progress dialog
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+ @Override
+ public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException {
+ operation.execute(monitor);
+ }
+ };
+
+ ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
+
try {
- getContainer().run(true, true, operation);
- } catch (InterruptedException e) {
- return false;
- } catch (InvocationTargetException e) {
- String message = (operation.isPublishing() ? I18n.PublishWizardPublishErrorMsg : I18n.PublishWizardUnpublishErrorMsg);
- Activator.getDefault().log(new Status(Severity.ERROR, message, e.getTargetException()));
- MessageDialog.openError(getContainer().getShell(), I18n.ErrorDialogTitle, message);
- return false;
+ dialog.run(true, true, op);
+ } catch (Throwable e) {
+ if (!(e instanceof InterruptedException)) {
+ error = e;
+
+ if (e instanceof InvocationTargetException) {
+ error = ((InvocationTargetException)e).getTargetException();
+ }
+
+ String message = (operation.isPublishing() ? I18n.PublishWizardPublishErrorMsg : I18n.PublishWizardUnpublishErrorMsg);
+ Activator.getDefault().log(new Status(Severity.ERROR, message, error));
+ }
+ } finally {
+ dialog.getProgressMonitor().done();
+
+ // show results
+ PublishingResultsDialog resultsDialog = null;
+
+ if (error == null) {
+ resultsDialog = new PublishingResultsDialog(getShell(), this.type, files, operation.getStatus());
+ } else {
+ resultsDialog = new PublishingResultsDialog(getShell(), this.type, files, operation.getStatus(), error);
+ }
+
+ resultsDialog.open();
}
return true;
Modified: branches/eclipse/org.jboss.dna.web.jcr.rest.client.swt.updatesite/artifacts.xml
===================================================================
--- branches/eclipse/org.jboss.dna.web.jcr.rest.client.swt.updatesite/artifacts.xml 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.web.jcr.rest.client.swt.updatesite/artifacts.xml 2009-07-29 22:37:55 UTC (rev 1139)
@@ -3,14 +3,21 @@
<repository name='JBoss DNA REST Eclipse SWT Client' type='org.eclipse.equinox.p2.artifact.repository.simpleRepository' version='1.0.0'>
<properties size='2'>
<property name='p2.compressed' value='false'/>
- <property name='p2.timestamp' value='1247070330809'/>
+ <property name='p2.timestamp' value='1248905146973'/>
</properties>
<mappings size='3'>
<rule filter='(& (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
<rule filter='(& (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
<rule filter='(& (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
</mappings>
- <artifacts size='5'>
+ <artifacts size='6'>
+ <artifact classifier='osgi.bundle' id='org.jboss.dna.web.jcr.rest.client.swt' version='1.0.0'>
+ <properties size='3'>
+ <property name='artifact.size' value='85068'/>
+ <property name='download.size' value='85068'/>
+ <property name='download.contentType' value='application/zip'/>
+ </properties>
+ </artifact>
<artifact classifier='org.eclipse.update.feature' id='org.jboss.dna.web.jcr.rest.client.swt.feature' version='1.0.0.v20090708'>
<properties size='2'>
<property name='artifact.size' value='1859'/>
@@ -19,15 +26,15 @@
</artifact>
<artifact classifier='osgi.bundle' id='org.jboss.dna.web.jcr.rest.client.swt' version='1.0.0'>
<properties size='3'>
- <property name='artifact.size' value='85068'/>
- <property name='download.size' value='85068'/>
+ <property name='artifact.size' value='85010'/>
+ <property name='download.size' value='85010'/>
<property name='download.contentType' value='application/zip'/>
</properties>
</artifact>
<artifact classifier='osgi.bundle' id='org.jboss.dna.web.jcr.rest.client.swt' version='1.0.0'>
<properties size='3'>
- <property name='artifact.size' value='85010'/>
- <property name='download.size' value='85010'/>
+ <property name='artifact.size' value='10911490'/>
+ <property name='download.size' value='10911490'/>
<property name='download.contentType' value='application/zip'/>
</properties>
</artifact>
Modified: branches/eclipse/org.jboss.dna.web.jcr.rest.client.swt.updatesite/content.xml
===================================================================
--- branches/eclipse/org.jboss.dna.web.jcr.rest.client.swt.updatesite/content.xml 2009-07-29 21:33:49 UTC (rev 1138)
+++ branches/eclipse/org.jboss.dna.web.jcr.rest.client.swt.updatesite/content.xml 2009-07-29 22:37:55 UTC (rev 1139)
@@ -3,7 +3,7 @@
<repository name='JBoss DNA REST Eclipse SWT Client' type='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1.0.0'>
<properties size='2'>
<property name='p2.compressed' value='false'/>
- <property name='p2.timestamp' value='1247070330817'/>
+ <property name='p2.timestamp' value='1248905147025'/>
</properties>
<units size='8'>
<unit id='org.jboss.dna.web.jcr.rest.client.swt.feature.feature.jar' version='1.0.0.v20090708'>
Modified: branches/eclipse/org.jboss.dna.web.jcr.rest.client.swt.updatesite/features/org.jboss.dna.web.jcr.rest.client.swt.feature_1.0.0.v20090708.jar
===================================================================
(Binary files differ)
Modified: branches/eclipse/org.jboss.dna.web.jcr.rest.client.swt.updatesite/plugins/org.jboss.dna.web.jcr.rest.client.swt_1.0.0.jar
===================================================================
(Binary files differ)
16 years, 5 months
DNA SVN: r1138 - in trunk: extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem and 1 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-07-29 17:33:49 -0400 (Wed, 29 Jul 2009)
New Revision: 1138
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
trunk/extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem/FileSystemConnectorCreateWorkspacesTest.java
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/DnaJcrDeployer.java
trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
Log:
DNA-496 Fixed a number of non-critical compiler errors and warnings that show up in Eclipse but not the Maven builds.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-07-26 18:25:46 UTC (rev 1137)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-07-29 21:33:49 UTC (rev 1138)
@@ -57,7 +57,6 @@
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NameFactory;
import org.jboss.dna.graph.property.Path;
-import org.jboss.dna.graph.property.PathFactory;
import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.property.PropertyFactory;
@@ -3036,9 +3035,9 @@
@Override
protected Batch submit( String workspaceName,
- Location on,
- Name property,
- List<Object> values ) {
+ Location on,
+ Name property,
+ List<Object> values ) {
requests.addValues(workspaceName, on, property, values);
return nextRequests.and();
}
@@ -3050,15 +3049,15 @@
@Override
protected Batch submit( String workspaceName,
- Location on,
- Name property,
- List<Object> values ) {
+ Location on,
+ Name property,
+ List<Object> values ) {
requests.removeValues(workspaceName, on, property, values);
return nextRequests.and();
}
};
}
-
+
/**
* Set the properties on a node.
*
@@ -5064,12 +5063,12 @@
public abstract class AddValueAction<T> extends AbstractAction<T> implements AddValue<T> {
- private final String workspaceName;
- private final List<Object> values = new LinkedList<Object>();
+ protected final String workspaceName;
+ protected final List<Object> values = new LinkedList<Object>();
protected AddValueAction( T afterConjunction,
- String workspaceName,
- Object firstValue ) {
+ String workspaceName,
+ Object firstValue ) {
super(afterConjunction);
this.workspaceName = workspaceName;
@@ -5082,9 +5081,7 @@
}
public On<T> to( String name ) {
- NameFactory nameFactory = context.getValueFactories().getNameFactory();
-
- return to(nameFactory.create(name));
+ return to(createName(name));
}
public On<T> to( final Name name ) {
@@ -5112,8 +5109,7 @@
}
public T on( String toPath ) {
- PathFactory pathFactory = context.getValueFactories().getPathFactory();
- return on(Location.create(pathFactory.create(toPath)));
+ return on(Location.create(createPath(toPath)));
}
public T on( UUID to ) {
@@ -5131,8 +5127,8 @@
public abstract class RemoveValueAction<T> extends AbstractAction<T> implements RemoveValue<T> {
- private final String workspaceName;
- private final List<Object> values = new LinkedList<Object>();
+ protected final String workspaceName;
+ protected final List<Object> values = new LinkedList<Object>();
protected RemoveValueAction( T afterConjunction,
String workspaceName,
@@ -5149,9 +5145,7 @@
}
public On<T> from( String name ) {
- NameFactory nameFactory = context.getValueFactories().getNameFactory();
-
- return from(nameFactory.create(name));
+ return from(createName(name));
}
public On<T> from( final Name name ) {
@@ -5179,8 +5173,7 @@
}
public T on( String toPath ) {
- PathFactory pathFactory = context.getValueFactories().getPathFactory();
- return on(Location.create(pathFactory.create(toPath)));
+ return on(Location.create(createPath(toPath)));
}
public T on( UUID to ) {
@@ -5188,12 +5181,12 @@
}
};
}
-
+
protected abstract T submit( String workspaceName,
- Location on,
- Name property,
- List<Object> values );
-
+ Location on,
+ Name property,
+ List<Object> values );
+
}
/**
Modified: trunk/extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem/FileSystemConnectorCreateWorkspacesTest.java
===================================================================
--- trunk/extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem/FileSystemConnectorCreateWorkspacesTest.java 2009-07-26 18:25:46 UTC (rev 1137)
+++ trunk/extensions/dna-connector-filesystem/src/test/java/org/jboss/dna/connector/filesystem/FileSystemConnectorCreateWorkspacesTest.java 2009-07-29 21:33:49 UTC (rev 1138)
@@ -25,7 +25,6 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import org.jboss.dna.graph.Graph;
@@ -92,7 +91,7 @@
}
@Test
- public void shouldReturnListOfWorkspacesMatchingAbsoluteCanonicalPathsToDirectories() throws IOException {
+ public void shouldReturnListOfWorkspacesMatchingAbsoluteCanonicalPathsToDirectories() {
// The the actual names of the workspaces ...
Set<String> workspaceNames = new HashSet<String>();
for (String workspaceName : graph.getWorkspaces()) {
@@ -101,7 +100,7 @@
}
// The actual names should be the absolute paths to the directories representing the root ...
String absolutePathToRepositories = "./src/test/resources/repositories/";
-
+
assertThat(workspaceNames.remove(absolutePathToRepositories + "airplanes"), is(true));
assertThat(workspaceNames.remove(absolutePathToRepositories + "cars"), is(true));
assertThat(workspaceNames.isEmpty(), is(true));
Modified: trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/DnaJcrDeployer.java
===================================================================
--- trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/DnaJcrDeployer.java 2009-07-26 18:25:46 UTC (rev 1137)
+++ trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/DnaJcrDeployer.java 2009-07-29 21:33:49 UTC (rev 1138)
@@ -25,17 +25,17 @@
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
+import net.jcip.annotations.NotThreadSafe;
import org.jboss.dna.web.jcr.rest.spi.RepositoryProvider;
-import net.jcip.annotations.NotThreadSafe;
-
/**
- * Servlet context listener that is responsible for {@link RepositoryFactory#initialize(javax.servlet.ServletContext) initializing}
- * the {@link RepositoryFactory repository factory}.
+ * Servlet context listener that is responsible for {@link RepositoryFactory#initialize(javax.servlet.ServletContext)
+ * initializing} the {@link RepositoryFactory repository factory}.
* <p>
- * This class is not thread safe, but in practice this does not matter as the servlet container must ensure that only
- * a single instance of this exists per web context and that it is only called in a single-threaded manner.
+ * This class is not thread safe, but in practice this does not matter as the servlet container must ensure that only a single
+ * instance of this exists per web context and that it is only called in a single-threaded manner.
* </p>
+ *
* @see RepositoryFactory
*/
@NotThreadSafe
@@ -43,6 +43,8 @@
/**
* Alerts the repository factory that the web application is shutting down
+ *
+ * @param event the servlet context event
* @see RepositoryFactory#shutdown()
* @see RepositoryProvider#shutdown()
*/
@@ -52,6 +54,8 @@
/**
* Initializes the repository factory
+ *
+ * @param event the servlet context event
* @see RepositoryFactory#initialize(javax.servlet.ServletContext)
*/
public void contextInitialized( ServletContextEvent event ) {
Modified: trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java
===================================================================
--- trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java 2009-07-26 18:25:46 UTC (rev 1137)
+++ trunk/extensions/dna-web-jcr-rest/src/main/java/org/jboss/dna/web/jcr/rest/JcrResources.java 2009-07-29 21:33:49 UTC (rev 1138)
@@ -128,7 +128,7 @@
*/
private Session getSession( HttpServletRequest request,
String rawRepositoryName,
- String rawWorkspaceName ) throws NotFoundException, RepositoryException {
+ String rawWorkspaceName ) throws RepositoryException {
assert request != null;
assert request.getUserPrincipal() != null : "Request must be authorized";
@@ -477,21 +477,21 @@
values[i] = jsonValues.getString(i);
}
} else {
- values = new String[] { (String)value };
+ values = new String[] {(String)value};
}
if (propName.equals(JcrResources.MIXIN_TYPES_PROPERTY)) {
Set<String> toBeMixins = new HashSet<String>(Arrays.asList(values));
Set<String> asIsMixins = new HashSet<String>();
-
+
for (NodeType nodeType : node.getMixinNodeTypes()) {
asIsMixins.add(nodeType.getName());
}
-
+
Set<String> mixinsToAdd = new HashSet<String>(toBeMixins);
mixinsToAdd.removeAll(asIsMixins);
asIsMixins.removeAll(toBeMixins);
-
+
for (String nodeType : mixinsToAdd) {
node.addMixin(nodeType);
}
@@ -502,9 +502,8 @@
} else {
if (values.length == 1) {
node.setProperty(propName, values[0]);
-
- }
- else {
+
+ } else {
node.setProperty(propName, values);
}
}
16 years, 5 months
DNA SVN: r1137 - trunk/dna-graph/src/main/java/org/jboss/dna/graph.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-07-26 14:25:46 -0400 (Sun, 26 Jul 2009)
New Revision: 1137
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
Log:
Removed superfluous @Override annotations to fix broken build
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-07-26 16:33:57 UTC (rev 1136)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-07-26 18:25:46 UTC (rev 1137)
@@ -5090,39 +5090,32 @@
public On<T> to( final Name name ) {
return new On<T>() {
- @Override
public T on( Iterable<Property> idProperties ) {
return on(Location.create(idProperties));
}
- @Override
public T on( Location to ) {
return submit(workspaceName, to, name, values);
}
- @Override
public T on( Path to ) {
return on(Location.create(to));
}
- @Override
public T on( Property firstIdProperty,
Property... additionalIdProperties ) {
return on(Location.create(firstIdProperty, additionalIdProperties));
}
- @Override
public T on( Property idProperty ) {
return on(Location.create(idProperty));
}
- @Override
public T on( String toPath ) {
PathFactory pathFactory = context.getValueFactories().getPathFactory();
return on(Location.create(pathFactory.create(toPath)));
}
- @Override
public T on( UUID to ) {
return on(Location.create(to));
}
@@ -5164,39 +5157,32 @@
public On<T> from( final Name name ) {
return new On<T>() {
- @Override
public T on( Iterable<Property> idProperties ) {
return on(Location.create(idProperties));
}
- @Override
public T on( Location to ) {
return submit(workspaceName, to, name, values);
}
- @Override
public T on( Path to ) {
return on(Location.create(to));
}
- @Override
public T on( Property firstIdProperty,
Property... additionalIdProperties ) {
return on(Location.create(firstIdProperty, additionalIdProperties));
}
- @Override
public T on( Property idProperty ) {
return on(Location.create(idProperty));
}
- @Override
public T on( String toPath ) {
PathFactory pathFactory = context.getValueFactories().getPathFactory();
return on(Location.create(pathFactory.create(toPath)));
}
- @Override
public T on( UUID to ) {
return on(Location.create(to));
}
16 years, 5 months
DNA SVN: r1136 - in trunk/dna-graph/src: main/java/org/jboss/dna/graph/request and 2 other directories.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-07-26 12:33:57 -0400 (Sun, 26 Jul 2009)
New Revision: 1136
Added:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RequestBuilder.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/WritableConnectorTest.java
Log:
DNA-397 Graph API should allow adding and removing property values
Committed patch that implements adding and removing values using addValue(value).andValue(value).to(propertyName).on(location) and removeValue(value).removeValue(value).from(propertyName).on(location) using a new request (UpdateValuesRequest) that has a reasonably efficient default implementation on RequestProcessor. The operations had to be named addValue/removeValue instead of add/remove to disambiguate the operations from the existing remove(String... propertyNames) grammar. The patch also includes a few new tests in WritableConnectorTest to validate the behavior.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-07-26 04:10:00 UTC (rev 1135)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-07-26 16:33:57 UTC (rev 1136)
@@ -57,6 +57,7 @@
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NameFactory;
import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.PathFactory;
import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.property.PropertyFactory;
@@ -1218,6 +1219,34 @@
};
}
+ public AddValue<Graph> addValue( Object value ) {
+ return new AddValueAction<Graph>(this, this.getCurrentWorkspaceName(), value) {
+
+ @Override
+ protected Graph submit( String workspaceName,
+ Location on,
+ Name property,
+ List<Object> values ) {
+ requests.addValues(workspaceName, on, property, values);
+ return nextGraph.and();
+ }
+ };
+ }
+
+ public RemoveValue<Graph> removeValue( Object value ) {
+ return new RemoveValueAction<Graph>(this, this.getCurrentWorkspaceName(), value) {
+
+ @Override
+ protected Graph submit( String workspaceName,
+ Location on,
+ Name property,
+ List<Object> values ) {
+ requests.removeValues(workspaceName, on, property, values);
+ return nextGraph.and();
+ }
+ };
+ }
+
/**
* Set the properties on a node.
*
@@ -3002,6 +3031,34 @@
};
}
+ public AddValue<Batch> addValue( Object value ) {
+ return new AddValueAction<Batch>(this, this.getCurrentWorkspaceName(), value) {
+
+ @Override
+ protected Batch submit( String workspaceName,
+ Location on,
+ Name property,
+ List<Object> values ) {
+ requests.addValues(workspaceName, on, property, values);
+ return nextRequests.and();
+ }
+ };
+ }
+
+ public RemoveValue<Batch> removeValue( Object value ) {
+ return new RemoveValueAction<Batch>(this, this.getCurrentWorkspaceName(), value) {
+
+ @Override
+ protected Batch submit( String workspaceName,
+ Location on,
+ Name property,
+ List<Object> values ) {
+ requests.removeValues(workspaceName, on, property, values);
+ return nextRequests.and();
+ }
+ };
+ }
+
/**
* Set the properties on a node.
*
@@ -4080,6 +4137,32 @@
}
/**
+ * A component that defines the name of a property to which a value should be added.
+ *
+ * @param <Next> The interface that is to be returned when this request is completed
+ */
+ public interface ToName<Next> {
+
+ public Next to( String name );
+
+ public Next to( Name name );
+
+ }
+
+ /**
+ * A component that defines the name of a property from which a value should be removed.
+ *
+ * @param <Next> The interface that is to be returned when this request is completed
+ */
+ public interface FromName<Next> {
+
+ public Next from( String name );
+
+ public Next from( Name name );
+
+ }
+
+ /**
* A component that defines the location to which a node should be copied or moved.
*
* @param <Next> The interface that is to be returned when this request is completed
@@ -4945,6 +5028,189 @@
}
/**
+ * The interface for defining the node on which an {@link Graph#addValue(Object)} operation applies and what additional values
+ * (if any) should be added.
+ *
+ * @param <Next> The interface that is to be returned when the request is completed
+ */
+ public interface AddValue<Next> extends ToName<On<Next>> {
+ /**
+ * Specifies an additional value to be added
+ *
+ * @param value the value to be added
+ * @return an object that allows additional values to be specified for removal or for their location to be specified
+ */
+ AddValue<Next> andValue( Object value );
+
+ }
+
+ /**
+ * The interface for defining the node on which an {@link Graph#removeValue(Object)} operation applies and what additional
+ * values (if any) should be removed.
+ *
+ * @param <Next> The interface that is to be returned when the request is completed
+ */
+ public interface RemoveValue<Next> extends FromName<On<Next>> {
+
+ /**
+ * Specifies an additional value to be removed
+ *
+ * @param value the value to be removed
+ * @return an object that allows additional values to be specified for removal or for their location to be specified
+ */
+ RemoveValue<Next> andValue( Object value );
+
+ }
+
+ public abstract class AddValueAction<T> extends AbstractAction<T> implements AddValue<T> {
+
+ private final String workspaceName;
+ private final List<Object> values = new LinkedList<Object>();
+
+ protected AddValueAction( T afterConjunction,
+ String workspaceName,
+ Object firstValue ) {
+ super(afterConjunction);
+
+ this.workspaceName = workspaceName;
+ this.values.add(firstValue);
+ }
+
+ public AddValue<T> andValue( Object nextValue ) {
+ this.values.add(nextValue);
+ return this;
+ }
+
+ public On<T> to( String name ) {
+ NameFactory nameFactory = context.getValueFactories().getNameFactory();
+
+ return to(nameFactory.create(name));
+ }
+
+ public On<T> to( final Name name ) {
+ return new On<T>() {
+
+ @Override
+ public T on( Iterable<Property> idProperties ) {
+ return on(Location.create(idProperties));
+ }
+
+ @Override
+ public T on( Location to ) {
+ return submit(workspaceName, to, name, values);
+ }
+
+ @Override
+ public T on( Path to ) {
+ return on(Location.create(to));
+ }
+
+ @Override
+ public T on( Property firstIdProperty,
+ Property... additionalIdProperties ) {
+ return on(Location.create(firstIdProperty, additionalIdProperties));
+ }
+
+ @Override
+ public T on( Property idProperty ) {
+ return on(Location.create(idProperty));
+ }
+
+ @Override
+ public T on( String toPath ) {
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
+ return on(Location.create(pathFactory.create(toPath)));
+ }
+
+ @Override
+ public T on( UUID to ) {
+ return on(Location.create(to));
+ }
+ };
+ }
+
+ protected abstract T submit( String workspaceName,
+ Location on,
+ Name property,
+ List<Object> values );
+
+ }
+
+ public abstract class RemoveValueAction<T> extends AbstractAction<T> implements RemoveValue<T> {
+
+ private final String workspaceName;
+ private final List<Object> values = new LinkedList<Object>();
+
+ protected RemoveValueAction( T afterConjunction,
+ String workspaceName,
+ Object firstValue ) {
+ super(afterConjunction);
+
+ this.workspaceName = workspaceName;
+ this.values.add(firstValue);
+ }
+
+ public RemoveValue<T> andValue( Object nextValue ) {
+ this.values.add(nextValue);
+ return this;
+ }
+
+ public On<T> from( String name ) {
+ NameFactory nameFactory = context.getValueFactories().getNameFactory();
+
+ return from(nameFactory.create(name));
+ }
+
+ public On<T> from( final Name name ) {
+ return new On<T>() {
+
+ @Override
+ public T on( Iterable<Property> idProperties ) {
+ return on(Location.create(idProperties));
+ }
+
+ @Override
+ public T on( Location to ) {
+ return submit(workspaceName, to, name, values);
+ }
+
+ @Override
+ public T on( Path to ) {
+ return on(Location.create(to));
+ }
+
+ @Override
+ public T on( Property firstIdProperty,
+ Property... additionalIdProperties ) {
+ return on(Location.create(firstIdProperty, additionalIdProperties));
+ }
+
+ @Override
+ public T on( Property idProperty ) {
+ return on(Location.create(idProperty));
+ }
+
+ @Override
+ public T on( String toPath ) {
+ PathFactory pathFactory = context.getValueFactories().getPathFactory();
+ return on(Location.create(pathFactory.create(toPath)));
+ }
+
+ @Override
+ public T on( UUID to ) {
+ return on(Location.create(to));
+ }
+ };
+ }
+
+ protected abstract T submit( String workspaceName,
+ Location on,
+ Name property,
+ List<Object> values );
+
+ }
+
+ /**
* A component used to set the values on a property.
*
* @param <Next> the next command
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RequestBuilder.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RequestBuilder.java 2009-07-26 04:10:00 UTC (rev 1135)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/RequestBuilder.java 2009-07-26 16:33:57 UTC (rev 1136)
@@ -25,6 +25,7 @@
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.jboss.dna.graph.Location;
import org.jboss.dna.graph.NodeConflictBehavior;
@@ -578,4 +579,41 @@
String workspaceName ) {
return process(new DeleteBranchRequest(at, workspaceName));
}
+
+ /**
+ * Add a request to add values to a property on an existing node
+ *
+ * @param workspaceName the name of the workspace containing the node; may not be null
+ * @param on the location of the node; may not be null
+ * @param property the name of the property; may not be null
+ * @param values the new values to add; may not be null
+ * @return the request; never null
+ */
+ public UpdateValuesRequest addValues( String workspaceName,
+ Location on,
+ Name property,
+ List<Object> values ) {
+ UpdateValuesRequest request = new UpdateValuesRequest(workspaceName, on, property, values, null);
+ process(request);
+ return request;
+ }
+
+ /**
+ * Add a request to remove values from a property on an existing node
+ *
+ * @param workspaceName the name of the workspace containing the node; may not be null
+ * @param on the location of the node; may not be null
+ * @param property the name of the property; may not be null
+ * @param values the new values to remove; may not be null
+ * @return the request; never null
+ */
+ public UpdateValuesRequest removeValues( String workspaceName,
+ Location on,
+ Name property,
+ List<Object> values ) {
+ UpdateValuesRequest request = new UpdateValuesRequest(workspaceName, on, property, null, values);
+ process(request);
+ return request;
+ }
+
}
Added: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java (rev 0)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java 2009-07-26 16:33:57 UTC (rev 1136)
@@ -0,0 +1,176 @@
+package org.jboss.dna.graph.request;
+
+import java.util.Collections;
+import java.util.List;
+import org.jboss.dna.graph.GraphI18n;
+import org.jboss.dna.graph.Location;
+import org.jboss.dna.graph.property.Name;
+import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.Property;
+
+/**
+ * Instruction to update the values for a certain property on the node at the specified location.
+ * <p>
+ * This request is capable of specifying specific values for the property that will be added or removed. Other values for the
+ * property not be affected by this request. The request contains a workspace name and a location that uniquely identify a node in
+ * the workspace as well as the name of property (that may or may not previously exist) on the node. The request also contains
+ * zero or more values to add and zero or more values to remove from the property. All values will be appended to the list of
+ * values. Removals are processed before additions.
+ * </p>
+ * <p>
+ * Even if the property has no values after this call, the property itself will not be removed by this request.
+ * </p>
+ * <p>
+ * Note that the number of values in a property (e.g., {@link Property#size()}, {@link Property#isEmpty()},
+ * {@link Property#isSingle()}, and {@link Property#isMultiple()}) has no influence on whether the property should be removed. It
+ * is possible for a property to have no values.
+ * </p>
+ */
+public class UpdateValuesRequest extends ChangeRequest {
+
+ private static final long serialVersionUID = 1L;
+
+ private final String workspaceName;
+ private final Location on;
+ private final Name propertyName;
+ private final List<Object> addedValues;
+ private final List<Object> removedValues;
+
+ private Location actualLocation;
+ private List<Object> actualAddedValues;
+ private List<Object> actualRemovedValues;
+
+
+ public UpdateValuesRequest( String workspaceName,
+ Location on,
+ Name propertyName,
+ List<Object> addedValues,
+ List<Object> removedValues ) {
+ super();
+
+ assert workspaceName != null;
+ assert on != null;
+ assert propertyName != null;
+
+ this.workspaceName = workspaceName;
+ this.on = on;
+ this.propertyName = propertyName;
+ this.addedValues = addedValues == null ? Collections.emptyList() : addedValues;
+ this.removedValues = removedValues == null ? Collections.emptyList() : removedValues;
+ }
+
+ /**
+ * Get the location defining the node that is to be updated.
+ *
+ * @return the location of the node; never null
+ */
+ public Location on() {
+ return on;
+ }
+
+ /**
+ * Get the name of the property that is to be updated.
+ *
+ * @return the name of the property; never null
+ */
+ public Name property() {
+ return propertyName;
+ }
+
+ /**
+ * Get the name of the workspace in which the node exists.
+ *
+ * @return the name of the workspace; never null
+ */
+ public String inWorkspace() {
+ return workspaceName;
+ }
+
+ /**
+ * Get the list of values to be added.
+ *
+ * @return the values (if any) to be added; never null
+ */
+ public List<Object> addedValues() {
+ return addedValues;
+ }
+
+ /**
+ * Get the list of values to be removed.
+ *
+ * @return the values (if any) to be removed; never null
+ */
+ public List<Object> removedValues() {
+ return removedValues;
+ }
+
+ @Override
+ public Location changedLocation() {
+ return on;
+ }
+
+ @Override
+ public String changedWorkspace() {
+ return workspaceName;
+ }
+
+ @Override
+ public boolean changes( String workspace,
+ Path path ) {
+ return workspaceName.equals(workspace) && on.hasPath() && on.getPath().equals(path);
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return addedValues.isEmpty() && removedValues.isEmpty();
+ }
+
+ public void setActualLocation(Location actual, List<Object> actualAddedValues, List<Object> actualRemovedValues) {
+ checkNotFrozen();
+ if (!on.isSame(actual)) { // not same if actual is null
+ throw new IllegalArgumentException(GraphI18n.actualLocationIsNotSameAsInputLocation.text(actual, on));
+ }
+ assert actual != null;
+ if (!actual.hasPath()) {
+ throw new IllegalArgumentException(GraphI18n.actualLocationMustHavePath.text(actual));
+ }
+ this.actualLocation = actual;
+ assert actualLocation != null;
+
+ assert actualAddedValues != null;
+ assert actualAddedValues.size() <= addedValues.size();
+ assert actualRemovedValues != null;
+ assert actualRemovedValues.size() <= actualRemovedValues.size();
+
+ this.actualAddedValues = actualAddedValues;
+ this.actualRemovedValues = actualRemovedValues;
+ }
+
+ /**
+ * Get the actual location of the node that was updated.
+ *
+ * @return the actual location, or null if the actual location was not set
+ */
+ public Location getActualLocationOfNode() {
+ return actualLocation;
+ }
+
+ /**
+ * Get the actual added values. This should always be identical to the list of values that were requested to be added.
+ *
+ * @return the values that were added to the node when this request was processed; never null
+ */
+ public List<Object> getActualAddedValues() {
+ return actualAddedValues;
+ }
+
+ /**
+ * Get the actual removed values. This will differ from the values that were requested to be removed if some of the values
+ * that were requested to be removed were not already values for the property.
+ *
+ * @return the values that were removed from the node when this request was processed; never null
+ */
+ public List<Object> getActualRemovedValues() {
+ return actualRemovedValues;
+ }
+}
Property changes on: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/UpdateValuesRequest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-07-26 04:10:00 UTC (rev 1135)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/processor/RequestProcessor.java 2009-07-26 16:33:57 UTC (rev 1136)
@@ -23,7 +23,10 @@
*/
package org.jboss.dna.graph.request.processor;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -68,6 +71,7 @@
import org.jboss.dna.graph.request.SetPropertyRequest;
import org.jboss.dna.graph.request.UnsupportedRequestException;
import org.jboss.dna.graph.request.UpdatePropertiesRequest;
+import org.jboss.dna.graph.request.UpdateValuesRequest;
import org.jboss.dna.graph.request.VerifyNodeExistsRequest;
import org.jboss.dna.graph.request.VerifyWorkspaceRequest;
@@ -259,6 +263,8 @@
process((CloneWorkspaceRequest)request);
} else if (request instanceof DestroyWorkspaceRequest) {
process((DestroyWorkspaceRequest)request);
+ } else if (request instanceof UpdateValuesRequest) {
+ process((UpdateValuesRequest)request);
} else {
processUnknownRequest(request);
}
@@ -749,6 +755,59 @@
public abstract void process( UpdatePropertiesRequest request );
/**
+ * Process a request to add and/or remove the specified values from a property on the given node.
+ * <p>
+ * This method does nothing if the request is null.
+ * </p>
+ *
+ * @param request the remove request
+ */
+ public void process( UpdateValuesRequest request ) {
+ String workspaceName = request.inWorkspace();
+ Location on = request.on();
+ Name propertyName = request.property();
+
+ // Read in the current values
+ ReadPropertyRequest readProperty = new ReadPropertyRequest(on, workspaceName, propertyName);
+ process(readProperty);
+
+ if (readProperty.hasError()) {
+ request.setError(readProperty.getError());
+ return;
+ }
+
+ Property property = readProperty.getProperty();
+ List<Object> actualRemovedValues = new ArrayList<Object>(request.removedValues().size());
+ List<Object> newValues = property == null ? new LinkedList<Object>() : new LinkedList<Object>(
+ Arrays.asList(property.getValuesAsArray()));
+ // Calculate what the new values should be
+ for (Object removedValue : request.removedValues()) {
+ for (Iterator<Object> iter = newValues.iterator(); iter.hasNext();) {
+ if (iter.next().equals(removedValue)) {
+ iter.remove();
+ actualRemovedValues.add(removedValue);
+ break;
+ }
+ }
+ }
+
+ newValues.addAll(request.addedValues());
+ Property newProperty = getExecutionContext().getPropertyFactory().create(propertyName, newValues);
+
+ // Update the current values
+ SetPropertyRequest setProperty = new SetPropertyRequest(on, workspaceName, newProperty);
+ process(setProperty);
+
+ if (setProperty.hasError()) {
+ request.setError(setProperty.getError());
+ } else {
+ // Set the actual location ...
+ request.setActualLocation(setProperty.getActualLocationOfNode(), request.addedValues(), actualRemovedValues);
+ }
+
+ }
+
+ /**
* Process a request to rename a node specified location into a different location.
* <p>
* This method does nothing if the request is null. Unless overridden, this method converts the rename into a
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/WritableConnectorTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/WritableConnectorTest.java 2009-07-26 04:10:00 UTC (rev 1135)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/connector/test/WritableConnectorTest.java 2009-07-26 16:33:57 UTC (rev 1136)
@@ -1849,4 +1849,101 @@
"The quick brown fox jumped over the moon. What? "));
}
+ @Test
+ public void shouldAddValuesToExistingProperty() {
+
+ String initialPath = "";
+ int depth = 1;
+ int numChildrenPerNode = 1;
+ int numPropertiesPerNode = 1;
+ Stopwatch sw = new Stopwatch();
+ boolean batch = true;
+ createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null);
+
+ assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));
+ Subgraph subgraph = graph.getSubgraphOfDepth(2).at("/");
+ assertThat(subgraph, is(notNullValue()));
+
+ assertThat(subgraph.getNode("node1"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+
+ graph.addValue("foo").andValue("bar").to("property1").on("node1");
+
+ assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));
+ subgraph = graph.getSubgraphOfDepth(2).at("/");
+ assertThat(subgraph, is(notNullValue()));
+
+ assertThat(subgraph.getNode("node1"), hasProperty("property1",
+ "The quick brown fox jumped over the moon. What? ",
+ "foo",
+ "bar"));
+ }
+
+ @Test
+ public void shouldAddValuesToNonExistantProperty() {
+
+ String initialPath = "";
+ int depth = 1;
+ int numChildrenPerNode = 1;
+ int numPropertiesPerNode = 1;
+ Stopwatch sw = new Stopwatch();
+ boolean batch = true;
+ createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null);
+
+ assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));
+
+ graph.addValue("foo").andValue("bar").to("newProperty").on("node1");
+
+ assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));
+ Subgraph subgraph = graph.getSubgraphOfDepth(2).at("/");
+ assertThat(subgraph, is(notNullValue()));
+
+ assertThat(subgraph.getNode("node1"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ assertThat(subgraph.getNode("node1"), hasProperty("newProperty", "foo", "bar"));
+
+ }
+
+ @Test
+ public void shouldRemoveValuesFromExistingProperty() {
+
+ String initialPath = "";
+ int depth = 1;
+ int numChildrenPerNode = 1;
+ int numPropertiesPerNode = 1;
+ Stopwatch sw = new Stopwatch();
+ boolean batch = true;
+ createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null);
+
+ assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));
+
+ graph.removeValue("The quick brown fox jumped over the moon. What? ").andValue("bar").from("property1").on("node1");
+
+ assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));
+ Subgraph subgraph = graph.getSubgraphOfDepth(2).at("/");
+ assertThat(subgraph, is(notNullValue()));
+
+ assertThat(subgraph.getNode("node1"), hasProperty("property1"));
+ }
+
+ @Test
+ public void shouldNotRemoveValuesFromNonExistantProperty() {
+
+ String initialPath = "";
+ int depth = 1;
+ int numChildrenPerNode = 1;
+ int numPropertiesPerNode = 1;
+ Stopwatch sw = new Stopwatch();
+ boolean batch = true;
+ createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null);
+
+ assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));
+
+ graph.removeValue("The quick brown fox jumped over the moon. What? ").from("noSuchProperty").on("node1");
+
+ assertThat(graph.getChildren().of("/"), hasChildren(segment("node1")));
+ Subgraph subgraph = graph.getSubgraphOfDepth(2).at("/");
+ assertThat(subgraph, is(notNullValue()));
+
+ assertThat(subgraph.getNode("node1"), hasProperty("property1", "The quick brown fox jumped over the moon. What? "));
+ }
+
}
16 years, 5 months
DNA SVN: r1135 - trunk/docs/examples/gettingstarted/sequencers/src/main/resources.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-07-26 00:10:00 -0400 (Sun, 26 Jul 2009)
New Revision: 1135
Added:
trunk/docs/examples/gettingstarted/sequencers/src/main/resources/test.jar
Log:
Added missing file from prior commit
Added: trunk/docs/examples/gettingstarted/sequencers/src/main/resources/test.jar
===================================================================
(Binary files differ)
Property changes on: trunk/docs/examples/gettingstarted/sequencers/src/main/resources/test.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
16 years, 5 months
DNA SVN: r1134 - trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-07-25 20:59:02 -0400 (Sat, 25 Jul 2009)
New Revision: 1134
Modified:
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
Log:
Replaced a method call that doesn't exist in Java5
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-07-26 00:43:59 UTC (rev 1133)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-07-26 00:59:02 UTC (rev 1134)
@@ -254,7 +254,7 @@
}
while (!nodesToVisit.isEmpty()) {
- Node node = nodesToVisit.pop();
+ Node node = nodesToVisit.remove();
String nodeType = "nt:file".equals(node.getPrimaryNodeType()) ? "file" : "folder";
infos.add(new MediaInfo(node.getPath(), node.getName(), nodeType, new Properties()));
16 years, 5 months
DNA SVN: r1133 - in trunk: docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer and 4 other directories.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-07-25 20:43:59 -0400 (Sat, 25 Jul 2009)
New Revision: 1133
Modified:
trunk/docs/examples/gettingstarted/sequencers/pom.xml
trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
trunk/docs/examples/gettingstarted/sequencers/src/main/resources/sequencing.cnd
trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java
trunk/extensions/dna-sequencer-zip/src/main/java/org/jboss/dna/sequencer/zip/ZipSequencer.java
trunk/extensions/dna-sequencer-zip/src/test/java/org/jboss/dna/sequencer/zip/ZipSequencerTest.java
Log:
DNA-495 ZipSequencer Output Cannot Be Read Through JCR
Committed patch that populates missing required properties with best-guess default values and adds ZipSequencer to sequencer example from the getting started section.
Modified: trunk/docs/examples/gettingstarted/sequencers/pom.xml
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/pom.xml 2009-07-24 20:22:31 UTC (rev 1132)
+++ trunk/docs/examples/gettingstarted/sequencers/pom.xml 2009-07-26 00:43:59 UTC (rev 1133)
@@ -46,6 +46,12 @@
<version>${pom.version}</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-sequencer-zip</artifactId>
+ <version>${pom.version}</version>
+ <scope>test</scope>
+ </dependency>
<!--
Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing)
-->
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-07-24 20:22:31 UTC (rev 1132)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java 2009-07-26 00:43:59 UTC (rev 1133)
@@ -26,6 +26,7 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Calendar;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -245,6 +246,25 @@
}
}
+ if (root.hasNode("zips")) {
+ LinkedList<Node> nodesToVisit = new LinkedList<Node>();
+
+ for (NodeIterator i = root.getNode("zips").getNodes(); i.hasNext();) {
+ nodesToVisit.addLast(i.nextNode());
+ }
+
+ while (!nodesToVisit.isEmpty()) {
+ Node node = nodesToVisit.pop();
+
+ String nodeType = "nt:file".equals(node.getPrimaryNodeType()) ? "file" : "folder";
+ infos.add(new MediaInfo(node.getPath(), node.getName(), nodeType, new Properties()));
+
+ for (NodeIterator i = node.getNodes(); i.hasNext();) {
+ nodesToVisit.addLast(i.nextNode());
+ }
+
+ }
+ }
if (root.hasNode("java")) {
Map<String, List<Properties>> tree = new TreeMap<String, List<Properties>>();
// Find the compilation unit node ...
@@ -443,6 +463,7 @@
if (filename.endsWith(".jpeg")) return "image/jpeg";
if (filename.endsWith(".ras")) return "image/x-cmu-raster";
if (filename.endsWith(".mp3")) return "audio/mpeg";
+ if (filename.endsWith(".jar")) return "application/java-archive";
if (filename.endsWith(".java")) return "text/x-java-source";
return null;
}
Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/resources/sequencing.cnd
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/resources/sequencing.cnd 2009-07-24 20:22:31 UTC (rev 1132)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/resources/sequencing.cnd 2009-07-26 00:43:59 UTC (rev 1133)
@@ -4,6 +4,7 @@
<image='http://jboss.org/dna/images/1.0'>
<mp3='http://jboss.org/dna/mp3/1.0'>
<java='http://www.jboss.org/dna/java/1.0'>
+<zip='http://jboss.org/dna/zip/1.0'>
// ----------------------------------------------------------
// JCR Pre-defined Mixin Types that are not loaded by default
@@ -263,4 +264,23 @@
+ java:package (java:packageDeclaration) = java:packageDeclaration
+ java:import (java:importDeclaration) = java:importDeclaration
+ java:unitType (java:classDeclaration, java:interfaceDeclaration)
+
+
+// -------------------
+// DNA Zip Sequencer
+// -------------------
+
+/**
+ * JCR Pre-defined Mixin Types that are not loaded by default
+ */
+[mix:mimeType] mixin
+ - jcr:mimeType (string)
+ - jcr:encoding (string)
+
+/**
+ * Primary type for root of generated structure
+ */
+[zip:content] > nt:unstructured, mix:mimeTyped
+ + * (nt:folder)
+ + * (nt:file)
\ No newline at end of file
Modified: trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java 2009-07-24 20:22:31 UTC (rev 1132)
+++ trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencer/SequencingClientTest.java 2009-07-26 00:43:59 UTC (rev 1133)
@@ -37,6 +37,7 @@
import org.jboss.dna.jcr.JcrRepository;
import org.jboss.dna.sequencer.java.JavaMetadataSequencer;
import org.jboss.dna.sequencer.mp3.Mp3MetadataSequencer;
+import org.jboss.dna.sequencer.zip.ZipSequencer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -50,6 +51,7 @@
private URL pictImageUrl;
private URL jpegImageUrl;
private URL mp3Url;
+ private URL jarUrl;
private URL javaSourceUrl;
private SequencingClient client;
@@ -59,6 +61,7 @@
this.pictImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.pict");
this.jpegImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.jpg");
this.mp3Url = Thread.currentThread().getContextClassLoader().getResource("sample1.mp3");
+ this.jarUrl = Thread.currentThread().getContextClassLoader().getResource("test.jar");
// Get the URL of source (MySource.java), that have to be sequencing
this.javaSourceUrl = FileUtil.convertFileToURL("workspace/project1/src/org/acme/MySource.java");
@@ -88,6 +91,12 @@
.setDescription("Sequences mp3 files to extract the id3 tags of the audio file")
.sequencingFrom("//(*.mp3[*])/jcr:content[@jcr:data]")
.andOutputtingTo("/mp3s/$1");
+ // Set up the zip sequencer ...
+ config.sequencer("Zip Sequencer")
+ .usingClass(ZipSequencer.class)
+ .setDescription("Sequences Zip, WAR, and JAR files to extract the contents")
+ .sequencingFrom("//(*.(zip|war|jar)[*])/jcr:content[@jcr:data]")
+ .andOutputtingTo("/zips/$1");
// Set up the Java source file sequencer ...
config.sequencer("Java Sequencer")
.usingClass(JavaMetadataSequencer.class)
@@ -159,6 +168,19 @@
}
@Test
+ public void shouldUploadAndSequenceZipFile() throws Exception {
+ client.setUserInterface(new MockUserInterface(this.jarUrl, "/a/b/test.jar", 168));
+ client.startRepository();
+ client.uploadFile();
+
+ waitUntilSequencedNodesIs(1);
+
+ // The sequencers should have run, so perform the search.
+ // The mock user interface checks the results.
+ client.search();
+ }
+
+ @Test
public void shouldUploadAndSequenceJavaSourceFile() throws Exception {
client.setUserInterface(new MockUserInterface(this.javaSourceUrl, "/a/b/MySource.java", 1));
client.startRepository();
Modified: trunk/extensions/dna-sequencer-zip/src/main/java/org/jboss/dna/sequencer/zip/ZipSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-zip/src/main/java/org/jboss/dna/sequencer/zip/ZipSequencer.java 2009-07-24 20:22:31 UTC (rev 1132)
+++ trunk/extensions/dna-sequencer-zip/src/main/java/org/jboss/dna/sequencer/zip/ZipSequencer.java 2009-07-26 00:43:59 UTC (rev 1133)
@@ -28,9 +28,11 @@
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import org.jboss.dna.graph.sequencer.StreamSequencerContext;
+import org.jboss.dna.graph.property.BinaryFactory;
+import org.jboss.dna.graph.property.DateTimeFactory;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
/**
* @author Michael Trezzi
@@ -47,6 +49,9 @@
public void sequence( InputStream stream,
SequencerOutput output,
StreamSequencerContext context ) {
+ BinaryFactory binaryFactory = context.getValueFactories().getBinaryFactory();
+ DateTimeFactory dateFactory = context.getValueFactories().getDateFactory();
+
try {
ZipInputStream in = new ZipInputStream(stream);
ZipEntry entry = in.getNextEntry();
@@ -59,14 +64,27 @@
if (entry.isDirectory()) { // If entry is directory, create nt:folder node
output.setProperty("zip:content/" + entry.getName(), "jcr:primaryType", "nt:folder");
} else { // If entry is File, create nt:file
- output.setProperty("zip:content/" + entry.getName() + "/jcr:content", "jcr:primaryType", "nt:resource");
- int n;
+ output.setProperty("zip:content/" + entry.getName(), "jcr:primaryType", "nt:file");
+ output.setProperty("zip:content/" + entry.getName() + "/jcr:content", "jcr:primaryType", "dna:resource");
+ int n;
ByteArrayOutputStream baout = new ByteArrayOutputStream();
while ((n = in.read(buf, 0, 1024)) > -1) {
baout.write(buf, 0, n);
}
- output.setProperty("zip:content/" + entry.getName() + "/jcr:content", "jcr:data", baout.toByteArray());
- // all other nt:file properties should be generated by other sequencers (mimetype, encoding,...)
+ byte[] bytes = baout.toByteArray();
+ output.setProperty("zip:content/" + entry.getName() + "/jcr:content",
+ "jcr:data",
+ binaryFactory.create(bytes));
+ // all other nt:file properties should be generated by other sequencers (mimetype, encoding,...) but we'll
+ // default them here
+ output.setProperty("zip:content/" + entry.getName() + "/jcr:content", "jcr:encoding", "binary");
+ output.setProperty("zip:content/" + entry.getName() + "/jcr:content",
+ "jcr:lastModified",
+ dateFactory.create(entry.getTime()).toString());
+ output.setProperty("zip:content/" + entry.getName() + "/jcr:content",
+ "jcr:mimeType",
+ "application/octet-stream");
+
}
in.closeEntry();
entry = in.getNextEntry();
Modified: trunk/extensions/dna-sequencer-zip/src/test/java/org/jboss/dna/sequencer/zip/ZipSequencerTest.java
===================================================================
--- trunk/extensions/dna-sequencer-zip/src/test/java/org/jboss/dna/sequencer/zip/ZipSequencerTest.java 2009-07-24 20:22:31 UTC (rev 1132)
+++ trunk/extensions/dna-sequencer-zip/src/test/java/org/jboss/dna/sequencer/zip/ZipSequencerTest.java 2009-07-26 00:43:59 UTC (rev 1133)
@@ -27,7 +27,9 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.stub;
import java.io.InputStream;
+import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.After;
import org.junit.Test;
@@ -59,9 +61,11 @@
ZipSequencer zs = new ZipSequencer();
SequencingOutputTestClass seqtest = new SequencingOutputTestClass();
StreamSequencerContext context = mock(StreamSequencerContext.class);
+ stub(context.getValueFactories()).toReturn(new ExecutionContext().getValueFactories());
+
zs.sequence(is, seqtest, context);
- assertThat(seqtest.properties.get(2).getPath(), is("zip:content/test subfolder/test2.txt/jcr:content"));
+ assertThat(seqtest.properties.get(3).getPath(), is("zip:content/test subfolder/test2.txt/jcr:content"));
}
}
16 years, 5 months
DNA SVN: r1132 - branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-07-24 16:22:31 -0400 (Fri, 24 Jul 2009)
New Revision: 1132
Modified:
branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
Log:
Made ServerManager implement IRestClient and delegate to the actual IRestClient.
Modified: branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java
===================================================================
--- branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java 2009-07-24 20:08:32 UTC (rev 1131)
+++ branches/eclipse/dna-web-jcr-rest-client/src/main/java/org/jboss/dna/web/jcr/rest/client/ServerManager.java 2009-07-24 20:22:31 UTC (rev 1132)
@@ -61,7 +61,7 @@
* @since 0.6
*/
@ThreadSafe
-public final class ServerManager {
+public final class ServerManager implements IRestClient {
// ===========================================================================================================================
// Constants
@@ -125,7 +125,7 @@
*
* @since 0.6
*/
- private final IRestClient restExecutor;
+ private final IRestClient delegate;
/**
* The path where the server registry is persisted or <code>null</code> if not persisted.
@@ -165,7 +165,7 @@
this.servers = new ArrayList<Server>();
this.stateLocationPath = stateLocationPath;
- this.restExecutor = restExecutor;
+ this.delegate = restExecutor;
this.listeners = new CopyOnWriteArrayList<IServerRegistryListener>();
}
@@ -236,11 +236,9 @@
}
/**
- * @param server the server whose repositories are being requested (never <code>null</code>)
- * @return the server repositories (never <code>null</code>)
- * @throws Exception if there is a problem obtaining the repositories or if the server is not registered
- * @throws RuntimeException if the server is not registered
- * @see #isRegistered(Server)
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getRepositories(org.jboss.dna.web.jcr.rest.client.domain.Server)
* @since 0.6
*/
public Collection<Repository> getRepositories( Server server ) throws Exception {
@@ -250,7 +248,7 @@
this.serverLock.readLock().lock();
if (isRegistered(server)) {
- Collection<Repository> repositories = this.restExecutor.getRepositories(server);
+ Collection<Repository> repositories = this.delegate.getRepositories(server);
return Collections.unmodifiableCollection(new ArrayList<Repository>(repositories));
}
@@ -262,11 +260,9 @@
}
/**
- * @param repository the repository whose workspaces are being requested (never <code>null</code>)
- * @return the DNA repository workspaces (never <code>null</code>)
- * @throws Exception if there is a problem obtaining the workspaces
- * @throws RuntimeException if the repository's server is not registered
- * @see #isRegistered(Server)
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.IRestClient#getWorkspaces(org.jboss.dna.web.jcr.rest.client.domain.Repository)
* @since 0.6
*/
public Collection<Workspace> getWorkspaces( Repository repository ) throws Exception {
@@ -276,7 +272,7 @@
this.serverLock.readLock().lock();
if (isRegistered(repository.getServer())) {
- Collection<Workspace> workspaces = this.restExecutor.getWorkspaces(repository);
+ Collection<Workspace> workspaces = this.delegate.getWorkspaces(repository);
return Collections.unmodifiableCollection(new ArrayList<Workspace>(workspaces));
}
@@ -440,6 +436,19 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.IRestClient#publish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
+ * java.lang.String, java.io.File)
+ * @since 0.6
+ */
+ public Status publish( Workspace workspace,
+ String path,
+ File file ) {
+ return this.delegate.publish(workspace, path, file);
+ }
+
+ /**
* @param listener the listener being unregistered and will no longer receive events (never <code>null</code>)
* @return <code>true</code> if listener was removed
* @since 0.6
@@ -562,6 +571,19 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.web.jcr.rest.client.IRestClient#unpublish(org.jboss.dna.web.jcr.rest.client.domain.Workspace,
+ * java.lang.String, java.io.File)
+ * @since 0.6
+ */
+ public Status unpublish( Workspace workspace,
+ String path,
+ File file ) {
+ return this.delegate.unpublish(workspace, path, file);
+ }
+
+ /**
* Updates the server registry with a new version of a server.
*
* @param previousServerVersion the version of the server being replaced (never <code>null</code>)
16 years, 5 months