Author: elvisisking
Date: 2010-11-17 13:56:32 -0500 (Wed, 17 Nov 2010)
New Revision: 26687
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/PublishDialog.html
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/ServerDialog.html
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/ServerView.html
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/Toc.html
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/images/ModeShapeMessageConsole.png
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/images/PublishDialog.png
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/images/ServerView.png
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/PublishedResourceHelper.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsHandler.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/dialogs/PublishedLocationsDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/PublishJob.java
Log:
JBDS-1402 Cannot enter the ModeShape workspace path. The ModeShape workspace area is a
path segment that is prepended to the resource project path. Mostly changes related to the
property that persists the workspace locations files are published to. Also related
documentation changes.
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/PublishDialog.html
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/PublishDialog.html 2010-11-17
18:55:33 UTC (rev 26686)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/PublishDialog.html 2010-11-17
18:56:32 UTC (rev 26687)
@@ -37,6 +37,10 @@
<td>allows selection of a workspace of the selected repository</td>
</tr>
<tr>
+ <td align="right"><strong>Workspace Area Text
Field</strong> </td>
+ <td>the root path in the workspace where files will be published</td>
+</tr>
+<tr>
<td align="right"><strong>Resources
List</strong> </td>
<td>a list of all the selected files that will be published or
unpublished</td>
</tr>
@@ -46,7 +50,12 @@
</tr>
</table>
-<p>A server must be selected before a repository can be selected. Likewise, a
repository must be selected before a workspace can be selected. The message area at the
top of the dialog will indicate the type of operation (publish or unpublish) and if there
is any missing information. Once the workspace has been selected the 'Finish'
button will be enabled and the operation can be executed. These operations can be run in
the background so that multiple operations can be run at the same time. The <a
href="ModeShapeMessageConsole.html">ModeShape Message Console</a>
displays output from the operations.</p>
+<p>A server must be selected before a repository can be selected. Likewise, a
repository must be selected before a workspace
+can be selected. The message area at the top of the dialog will indicate the type of
operation (publish or unpublish) and if
+there is any missing information. The workspace area is a path segment in the workspace
that will be used as the root path
+for the publishing operation. Once the workspace has been selected the 'Finish'
button will be enabled and the operation
+can be executed. These operations can be run in the background so that multiple
operations can be run at the same time.
+The <a href="ModeShapeMessageConsole.html">ModeShape Message
Console</a> displays output from the operations.</p>
<h3>Related Topics</h3>
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/ServerDialog.html
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/ServerDialog.html 2010-11-17
18:55:33 UTC (rev 26686)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/ServerDialog.html 2010-11-17
18:56:32 UTC (rev 26687)
@@ -42,11 +42,11 @@
</tr>
</table>
-<p>Once all server properties have been entered the 'Finish' button will be
enabled and the new server can be created or the existing server's properties can be
modified. You can display the Server Dialog from the Server View and from the
Publish/Unpublish Dialog.</p>
+<p>Once all server properties have been entered the 'Finish' button will be
enabled and the new server can be created or the existing server's properties can be
modified. You can display the Server Dialog from the ModeShape View and from the
Publish/Unpublish Dialog.</p>
<h3>Related Topics</h3>
<ul>
-<li><a href="ServerView.html">Server View</a></li>
+<li><a href="ServerView.html">ModeShape View</a></li>
<li><a href="PublishDialog.html">Publishing and Unpublishing
Dialog</a></li>
</ul>
\ No newline at end of file
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/ServerView.html
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/ServerView.html 2010-11-17
18:55:33 UTC (rev 26686)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/ServerView.html 2010-11-17
18:56:32 UTC (rev 26687)
@@ -9,15 +9,15 @@
- See the AUTHORS.txt file in the distribution for a full listing of
- individual contributors.
-->
-<h2>ModeShape Server View</h2>
+<h2>ModeShape View</h2>
-<p>The <i>Server View</i> displays the registered servers hosting
ModeShape repositories. For each server, the repositories and repository workspaces are
also displayed. There are view toolbar buttons to create a new server (<img
src="images/new_server.gif" border="0" alt="">), edit a
selected server's properties (<img src="images/edit_server.gif"
border="0" alt="">), discard one or more selected servers (<img
src="images/delete_server.gif" border="0" alt="">),
reconnect to a selected server (<img src="images/refresh.gif"
border="0" alt="">), and collapse all servers so that their
repositories and workspaces can't be seen (<img
src="images/collapse_all.gif" border="0" alt="">). If a
connection to a server cannot be established that server icon will be decorated with an
error overlay image.</p>
+<p>The <i>ModeShape View</i> displays the registered servers hosting
ModeShape repositories. For each server, the repositories and repository workspaces are
also displayed. There are view toolbar buttons to create a new server (<img
src="images/new_server.gif" border="0" alt="">), edit a
selected server's properties (<img src="images/edit_server.gif"
border="0" alt="">), discard one or more selected servers (<img
src="images/delete_server.gif" border="0" alt="">),
reconnect to a selected server (<img src="images/refresh.gif"
border="0" alt="">), and collapse all servers so that their
repositories and workspaces can't be seen (<img
src="images/collapse_all.gif" border="0" alt="">). If a
connection to a server cannot be established that server icon will be decorated with an
error overlay image.</p>
-<p>Here is what the <i>Server View</i> looks like:</p>
+<p>Here is what the <i>ModeShape View</i> looks like:</p>
<img src="images/ServerView.png" border="0" alt="">
-<p>The view's context menu includes the new server, edit server properties,
discard server, and reconnect to server actions. Here is what the Server View context menu
looks like:</p>
+<p>The view's context menu includes the new server, edit server properties,
discard server, and reconnect to server actions. Here is what the ModeShape View context
menu looks like:</p>
<img src="images/ServerViewContextMenu.png" border="0"
alt="">
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/Toc.html
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/Toc.html 2010-11-17
18:55:33 UTC (rev 26686)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/Toc.html 2010-11-17
18:56:32 UTC (rev 26687)
@@ -14,7 +14,7 @@
<ul>
<li><a href="PublishDialog.html">Publish/Unpublish
Dialog</a></li>
<li><a href="ServerDialog.html">Server Dialog</a></li>
-<li><a href="ServerView.html">Server View</a></li>
+<li><a href="ServerView.html">ModeShape View</a></li>
<li><a href="ModeShapeMessageConsole.html">ModeShape Message
Console</a></li>
<li><a href="PublishedLocationsDialog.html">Published Locations
Dialog</a></li>
<li><a href="ResourceContextMenu.html">Resource Context
Menu</a></li>
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/images/ModeShapeMessageConsole.png
===================================================================
(Binary files differ)
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/images/PublishDialog.png
===================================================================
(Binary files differ)
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/docs/images/ServerView.png
===================================================================
(Binary files differ)
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/PublishedResourceHelper.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/PublishedResourceHelper.java 2010-11-17
18:55:33 UTC (rev 26686)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/PublishedResourceHelper.java 2010-11-17
18:56:32 UTC (rev 26687)
@@ -19,6 +19,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.modeshape.common.util.CheckArg;
+import org.modeshape.common.util.HashCode;
import org.modeshape.web.jcr.rest.client.Status;
import org.modeshape.web.jcr.rest.client.Status.Severity;
import org.modeshape.web.jcr.rest.client.domain.Repository;
@@ -80,64 +81,70 @@
/**
* @param file the file that was just published (never
<code>null</code>)
* @param workspace the workspace where the file was published (never
<code>null</code>)
+ * @param url the URL where the resource was published (never
<code>null</code>)
* @throws Exception if there is a problem setting the property
*/
public void addPublishedProperty( IFile file,
- Workspace workspace ) throws Exception {
+ Workspace workspace,
+ String url ) throws Exception {
CheckArg.isNotNull(file, "file");
CheckArg.isNotNull(workspace, "workspace");
+ CheckArg.isNotNull(url, "url");
- Set<Workspace> workspaces = getPublishedOnWorkspaces(file);
- workspaces.add(workspace);
+ Set<WorkspaceLocation> workspaceLocations =
getPublishedWorkspaceLocations(file);
+ workspaceLocations.add(new WorkspaceLocation(workspace, url));
// set new value
- setPublishedOnPropertyValue(file, workspaces);
+ setPublishedOnPropertyValue(file, workspaceLocations);
}
/**
- * @param workspaces the workspaces used to create the property value
+ * @param workspaceLocations the workspace locations used to create the property
value
* @return the property value
*/
- private String createPublishedPropertyValue( Set<Workspace> workspaces ) {
+ private String createPublishedPropertyValue( Set<WorkspaceLocation>
workspaceLocations ) {
StringBuilder value = new StringBuilder();
- for (Workspace workspace : workspaces) {
- value.append(createWorkspaceId(workspace)).append(DELIM);
+ for (WorkspaceLocation workspaceLocation : workspaceLocations) {
+ value.append(createWorkspaceLocationId(workspaceLocation)).append(DELIM);
}
return value.toString();
}
/**
- * @param workspace the workspace whose identifier is being created
+ * @param workspaceLocation the workspace location whose identifier is being created
* @return the ID
*/
- private String createWorkspaceId( Workspace workspace ) {
+ private String createWorkspaceLocationId( WorkspaceLocation workspaceLocation ) {
+ Workspace workspace = workspaceLocation.getWorkspace();
+
StringBuilder result = new StringBuilder();
result.append(workspace.getServer().getUrl()).append(ID_DELIM).append(workspace.getServer().getUser()).append(ID_DELIM);
result.append(workspace.getRepository().getName()).append(ID_DELIM);
- result.append(workspace.getName());
+ result.append(workspace.getName()).append(ID_DELIM);
+ result.append(workspaceLocation.getUrl());
return result.toString();
}
/**
- * @param file the file whose <code>Workspace</code>s it has been
published on is being requested (never <code>null</code>)
- * @return the workspaces (never <code>null</code>)
+ * @param file the file whose published <code>WorkspaceLocation</code>s
is being requested (never <code>null</code>)
+ * @return the workspace locations (never <code>null</code>)
* @throws Exception if there is a problem reading one of the file's persistent
properties or a problem with the server
* manager
*/
- public Set<Workspace> getPublishedOnWorkspaces( IFile file ) throws Exception
{
+ public Set<WorkspaceLocation> getPublishedWorkspaceLocations( IFile file )
throws Exception {
CheckArg.isNotNull(file, "file");
- Set<Workspace> publishedOnWorkspaces = null;
+ Set<WorkspaceLocation> publishedWorkspaceLocations = null;
String value = file.getPersistentProperty(PUBLISHED_RESOURCE_PROPERTY);
if (value == null) {
- publishedOnWorkspaces = new HashSet<Workspace>(1);
+ publishedWorkspaceLocations = new HashSet<WorkspaceLocation>(1);
} else {
StringTokenizer wsTokenizer = new StringTokenizer(value, DELIM);
- publishedOnWorkspaces = new
HashSet<Workspace>(wsTokenizer.countTokens());
+ publishedWorkspaceLocations = new
HashSet<WorkspaceLocation>(wsTokenizer.countTokens());
while (wsTokenizer.hasMoreTokens()) {
StringTokenizer propsTokenizer = new
StringTokenizer(wsTokenizer.nextToken(), ID_DELIM);
@@ -145,11 +152,14 @@
PARSE_WORKSPACE: while (propsTokenizer.hasMoreTokens()) {
String url = propsTokenizer.nextToken();
String user = propsTokenizer.nextToken();
+
+ // find server
Server server = this.serverManager.findServer(url, user);
if ((server != null) &&
this.serverManager.ping(server).isOk()) {
Collection<Repository> repositories =
this.serverManager.getRepositories(server);
+ // find repository
if (!repositories.isEmpty()) {
String repositoryName = propsTokenizer.nextToken();
@@ -157,12 +167,15 @@
if (repository.getName().equals(repositoryName)) {
Collection<Workspace> workspaces =
this.serverManager.getWorkspaces(repository);
+ // find workspace
if (!workspaces.isEmpty()) {
String workspaceName =
propsTokenizer.nextToken();
for (Workspace workspace : workspaces) {
if
(workspace.getName().equals(workspaceName)) {
- publishedOnWorkspaces.add(workspace);
+ // get URL
+ String publishedUrl =
propsTokenizer.nextToken();
+ publishedWorkspaceLocations.add(new
WorkspaceLocation(workspace, publishedUrl));
break PARSE_WORKSPACE;
}
}
@@ -179,7 +192,7 @@
}
}
- return publishedOnWorkspaces;
+ return publishedWorkspaceLocations;
}
/**
@@ -190,7 +203,7 @@
CheckArg.isNotNull(file, "file");
try {
- return !getPublishedOnWorkspaces(file).isEmpty();
+ return !getPublishedWorkspaceLocations(file).isEmpty();
} catch (Exception e) {
Activator.getDefault().log(new Status(Severity.ERROR,
RestClientI18n.publishedResourcePropertyErrorMsg.text(file), e));
}
@@ -201,18 +214,21 @@
/**
* @param file the file that was just unpublished (never
<code>null</code>)
* @param workspace the workspace where the file was unpublished (never
<code>null</code>)
+ * @param url the URL where the resource was unpublished (never
<code>null</code>)
* @throws Exception if there is a problem changing the property value
*/
public void removePublishedProperty( IFile file,
- Workspace workspace ) throws Exception {
+ Workspace workspace,
+ String url ) throws Exception {
CheckArg.isNotNull(file, "file");
CheckArg.isNotNull(workspace, "workspace");
+ CheckArg.isNotNull(url, "url");
- Set<Workspace> workspaces = getPublishedOnWorkspaces(file);
- workspaces.remove(workspace);
+ Set<WorkspaceLocation> workspaceLocations =
getPublishedWorkspaceLocations(file);
+ workspaceLocations.remove(new WorkspaceLocation(workspace, url));
// set new value
- setPublishedOnPropertyValue(file, workspaces);
+ setPublishedOnPropertyValue(file, workspaceLocations);
}
/**
@@ -225,17 +241,96 @@
/**
* @param file the file whose property is being set
- * @param workspaces the workspaces the file has been published to or
<code>null</code> if the file has not been published
+ * @param workspaceLocations the workspace locations the file has been published to
or <code>null</code> if the file has not
+ * been published
* @throws CoreException if there was a problem changing the property value
*/
private void setPublishedOnPropertyValue( IFile file,
- Set<Workspace> workspaces ) throws
CoreException {
- if ((workspaces == null) || workspaces.isEmpty()) {
+ Set<WorkspaceLocation>
workspaceLocations ) throws CoreException {
+ if ((workspaceLocations == null) || workspaceLocations.isEmpty()) {
clear(file);
} else {
- String value = createPublishedPropertyValue(workspaces);
+ String value = createPublishedPropertyValue(workspaceLocations);
file.setPersistentProperty(PUBLISHED_RESOURCE_PROPERTY, value);
}
}
+ /**
+ * Holds the workspace and the URL where the file was published to.
+ */
+ public class WorkspaceLocation {
+
+ private final Workspace workspace;
+
+ private final String url;
+
+ public WorkspaceLocation( Workspace workspace,
+ String url ) {
+ this.workspace = workspace;
+ this.url = url;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals( Object obj ) {
+ if (obj == null) return false;
+ if (!getClass().equals(obj.getClass())) return false;
+
+ WorkspaceLocation thatLocation = (WorkspaceLocation)obj;
+
+ if (this.workspace.equals(thatLocation.workspace)) {
+ if ((this.url == null) || this.url.equals("")) {
+ return ((thatLocation.url == null) ||
thatLocation.url.equals(""));
+ }
+
+ return this.url.equals(thatLocation.url);
+ }
+
+ return false;
+ }
+
+ /**
+ * @return the repository where the workspace is located (never
<code>null</code>)
+ */
+ public Repository getRepository() {
+ return this.workspace.getRepository();
+ }
+
+ /**
+ * @return the server where the workspace is located (never
<code>null</code>)
+ */
+ public Server getServer() {
+ return this.workspace.getServer();
+ }
+
+ /**
+ * @return the workspace where published (never <code>null</code>)
+ */
+ public Workspace getWorkspace() {
+ return this.workspace;
+ }
+
+ /**
+ * @return the URL where the file is published (never
<code>null</code>)
+ */
+ public String getUrl() {
+ return this.url;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return HashCode.compute(this.workspace, this.url);
+ }
+
+ }
+
}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java 2010-11-17
18:55:33 UTC (rev 26686)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.java 2010-11-17
18:56:32 UTC (rev 26687)
@@ -54,7 +54,6 @@
public static I18n publishedLocationsDialogCopyUrlButton;
public static I18n publishedLocationsDialogCopyUrlButtonToolTip;
- public static I18n publishedLocationsDialogErrorObtainingUrlMsg;
public static I18n publishedLocationsDialogFileUrlColumnHeader;
public static I18n publishedLocationsDialogMsg;
public static I18n publishedLocationsDialogRepositoryColumnHeader;
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties 2010-11-17
18:55:33 UTC (rev 26686)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/RestClientI18n.properties 2010-11-17
18:56:32 UTC (rev 26687)
@@ -46,7 +46,6 @@
publishedLocationsDialogCopyUrlButton = Copy URL
publishedLocationsDialogCopyUrlButtonToolTip = Copy to the clipboard the selected
workspace URL where the file is published
-publishedLocationsDialogErrorObtainingUrlMsg = Error obtaining URL
publishedLocationsDialogFileUrlColumnHeader = Published URL
publishedLocationsDialogMsg = The file "{0}" has been published to the
following ModeShape workspaces:
publishedLocationsDialogRepositoryColumnHeader = Repository
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsHandler.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsHandler.java 2010-11-17
18:55:33 UTC (rev 26686)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsHandler.java 2010-11-17
18:56:32 UTC (rev 26687)
@@ -21,10 +21,10 @@
import org.jboss.tools.modeshape.rest.PublishedResourceHelper;
import org.jboss.tools.modeshape.rest.RestClientI18n;
import org.jboss.tools.modeshape.rest.ServerManager;
+import org.jboss.tools.modeshape.rest.PublishedResourceHelper.WorkspaceLocation;
import org.jboss.tools.modeshape.rest.dialogs.PublishedLocationsDialog;
import org.modeshape.web.jcr.rest.client.Status;
import org.modeshape.web.jcr.rest.client.Status.Severity;
-import org.modeshape.web.jcr.rest.client.domain.Workspace;
/**
* The <code>ShowPublishedLocationsHandler</code> displays a dialog that
shows information on which ModeShape repositories a
@@ -54,9 +54,9 @@
Shell shell = HandlerUtil.getActiveShell(event);
try {
- Set<Workspace> workspaces =
resourceHelper.getPublishedOnWorkspaces((IFile)selection.getFirstElement());
- PublishedLocationsDialog dialog = new PublishedLocationsDialog(shell,
serverManager,
-
(IFile)selection.getFirstElement(), workspaces);
+ Set<WorkspaceLocation> workspaceLocations =
resourceHelper.getPublishedWorkspaceLocations((IFile)selection.getFirstElement());
+ PublishedLocationsDialog dialog = new PublishedLocationsDialog(shell,
(IFile)selection.getFirstElement(),
+
workspaceLocations);
dialog.open();
} catch (Exception e) {
Activator.getDefault().log(new Status(Severity.ERROR,
RestClientI18n.showPublishedLocationsErrorMsg.text(), e));
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/dialogs/PublishedLocationsDialog.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/dialogs/PublishedLocationsDialog.java 2010-11-17
18:55:33 UTC (rev 26686)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/dialogs/PublishedLocationsDialog.java 2010-11-17
18:56:32 UTC (rev 26687)
@@ -16,7 +16,6 @@
import static org.jboss.tools.modeshape.rest.IUiConstants.REPOSITORY_IMAGE;
import static org.jboss.tools.modeshape.rest.IUiConstants.SERVER_IMAGE;
import static org.jboss.tools.modeshape.rest.IUiConstants.WORKSPACE_IMAGE;
-import java.io.File;
import java.util.Collection;
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -48,12 +47,9 @@
import org.eclipse.swt.widgets.TableColumn;
import org.jboss.tools.modeshape.rest.Activator;
import org.jboss.tools.modeshape.rest.RestClientI18n;
-import org.jboss.tools.modeshape.rest.ServerManager;
+import org.jboss.tools.modeshape.rest.PublishedResourceHelper.WorkspaceLocation;
import org.modeshape.common.util.CheckArg;
-import org.modeshape.web.jcr.rest.client.Status;
-import org.modeshape.web.jcr.rest.client.Status.Severity;
import org.modeshape.web.jcr.rest.client.domain.Server;
-import org.modeshape.web.jcr.rest.client.domain.Workspace;
/**
* The <code>PublishedLocationsDialog</code> class provides a UI for viewing
a list of {@link Server servers} a selected file has
@@ -114,24 +110,14 @@
private Button btnCopy;
/**
- * The file whose workspaces it was published to is being displayed by this dialog.
- */
- private final IFile file;
-
- /**
- * The server manager who can obtain the URL for the file at each of the workspaces.
- */
- private final ServerManager serverManager;
-
- /**
* The viewer of the table holding the published locations.
*/
private TableViewer viewer;
/**
- * Collection of workspaces the selected file has been published to.
+ * Collection of workspace locations the selected file has been published to.
*/
- private final Collection<Workspace> workspaces;
+ private final Collection<WorkspaceLocation> workspaceLocations;
//
===========================================================================================================================
// Constructors
@@ -139,27 +125,20 @@
/**
* @param parentShell the dialog parent
- * @param serverManager the server manager that this dialog will get URLs from (never
<code>null</code>)
* @param file the file whose workspaces it has been published on is being requested
(never <code>null</code>)
- * @param workspaces the workspaces (never <code>null</code>)
+ * @param workspaceLocations the workspace locations (never
<code>null</code>)
*/
public PublishedLocationsDialog( Shell parentShell,
- ServerManager serverManager,
IFile file,
- Collection<Workspace> workspaces ) {
+ Collection<WorkspaceLocation>
workspaceLocations ) {
super(parentShell, RestClientI18n.publishedLocationsDialogTitle.text(),
Activator.getDefault().getImage(ModeShape_IMAGE_16x),
RestClientI18n.publishedLocationsDialogMsg.text(file.getFullPath()),
MessageDialog.INFORMATION,
new String[] {IDialogConstants.OK_LABEL}, 0);
- CheckArg.isNotNull(serverManager, "serverManager");
- CheckArg.isNotNull(file, "file");
- CheckArg.isNotNull(workspaces, "workspaces");
+ CheckArg.isNotNull(workspaceLocations, "workspaceLocations");
+ this.workspaceLocations = workspaceLocations;
- this.file = file;
- this.serverManager = serverManager;
- this.workspaces = workspaces;
-
// make sure dialog is resizable
setShellStyle(getShellStyle() | SWT.RESIZE);
}
@@ -261,49 +240,26 @@
}
/**
- * @return the file system file this dialog is showing the published locations of
(never <code>null</code>)
- */
- private File getFile() {
- return this.file.getLocation().toFile();
- }
-
- /**
- * This path does not include the name of the file.
- *
- * @return the path the file was published (never <code>null</code>)
- */
- private String getPath() {
- return this.file.getParent().getFullPath().toString();
- }
-
- /**
- * @param workspace the workspace where the file was published
+ * @param workspaceLocation the workspace location where the file was published
* @return the URL where the file was published
*/
- String getPublishedAtUrl( Workspace workspace ) {
- try {
- return this.serverManager.getUrl(getFile(), getPath(),
workspace).toString();
- } catch (Exception e) {
- String message =
RestClientI18n.publishedLocationsDialogErrorObtainingUrlMsg.text();
- Activator.getDefault().log(new Status(Severity.ERROR, message, e));
- return message;
- }
-
+ String getPublishedAtUrl( WorkspaceLocation workspaceLocation ) {
+ return workspaceLocation.getUrl();
}
/**
* @return the workspaces the file has been published to (never
<code>null</code>)
*/
- Object[] getWorkspaces() {
- return this.workspaces.toArray();
+ Object[] getWorkspaceLocations() {
+ return this.workspaceLocations.toArray();
}
/**
* Handler for when the copy URL button is clicked.
*/
void handleCopyUrl() {
- Workspace workspace =
(Workspace)((IStructuredSelection)this.viewer.getSelection()).getFirstElement();
- String url = getPublishedAtUrl(workspace);
+ WorkspaceLocation workspaceLocation =
(WorkspaceLocation)((IStructuredSelection)this.viewer.getSelection()).getFirstElement();
+ String url = getPublishedAtUrl(workspaceLocation);
Clipboard clipboard = new Clipboard(Display.getCurrent());
clipboard.setContents(new Object[] {url}, new Transfer[]
{TextTransfer.getInstance()});
}
@@ -367,26 +323,26 @@
@Override
public String getColumnText( Object element,
int columnIndex ) {
- Workspace workspace = (Workspace)element;
+ WorkspaceLocation workspaceLocation = (WorkspaceLocation)element;
if (columnIndex == SERVER_URL_COL) {
- return workspace.getServer().getUrl();
+ return workspaceLocation.getServer().getUrl();
}
if (columnIndex == USER_COL) {
- return workspace.getServer().getUser();
+ return workspaceLocation.getServer().getUser();
}
if (columnIndex == REPOSITORY_COL) {
- return workspace.getRepository().getName();
+ return workspaceLocation.getRepository().getName();
}
if (columnIndex == WORKSPACE_COL) {
- return workspace.getName();
+ return workspaceLocation.getWorkspace().getName();
}
if (columnIndex == FILE_URL_COL) {
- return getPublishedAtUrl(workspace);
+ return getPublishedAtUrl(workspaceLocation);
}
// should never get here
@@ -401,7 +357,7 @@
*/
@Override
public Object[] getElements( Object inputElement ) {
- return getWorkspaces();
+ return getWorkspaceLocations();
}
/**
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/PublishJob.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/PublishJob.java 2010-11-17
18:55:33 UTC (rev 26686)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/jobs/PublishJob.java 2010-11-17
18:56:32 UTC (rev 26687)
@@ -133,7 +133,7 @@
this.files = files;
this.workspace = workspace;
this.jobId = JOB_ID.get();
-
+
// setup the workspace area and remove trailing separator if necessary
String temp = ((workspaceArea == null) ? "" : workspaceArea);
@@ -223,6 +223,7 @@
File file = eclipseFile.getLocation().toFile();
String path = this.workspaceArea +
eclipseFile.getParent().getFullPath().toString();
+ URL url = getServerManager().getUrl(file, path, this.workspace);
Status status = null;
if (isPublishing()) {
@@ -230,14 +231,14 @@
// set persistent property on resource indicating it has been
published
if (!status.isError()) {
- resourceHelper.addPublishedProperty(eclipseFile, workspace);
+ resourceHelper.addPublishedProperty(eclipseFile, this.workspace,
url.toString());
}
} else {
status = getServerManager().unpublish(this.workspace, path, file);
// clear persistent property on resource indicating it has been
unpublished
if (!status.isError()) {
- resourceHelper.removePublishedProperty(eclipseFile, workspace);
+ resourceHelper.removePublishedProperty(eclipseFile,
this.workspace, url.toString());
}
}
@@ -253,7 +254,6 @@
// write outcome message to console
if (isPublishing() && status.isOk()) {
- URL url = getServerManager().getUrl(file, path, this.workspace);
writeToConsole(eclipseFile, url, status);
} else {
writeToConsole(eclipseFile, null, status);