001 /*
002 * JBoss DNA (http://www.jboss.org/dna)
003 * See the COPYRIGHT.txt file distributed with this work for information
004 * regarding copyright ownership. Some portions may be licensed
005 * to Red Hat, Inc. under one or more contributor license agreements.
006 * See the AUTHORS.txt file in the distribution for a full listing of
007 * individual contributors.
008 *
009 * Unless otherwise indicated, all code in JBoss DNA is licensed
010 * to you under the terms of the GNU Lesser General Public License as
011 * published by the Free Software Foundation; either version 2.1 of
012 * the License, or (at your option) any later version.
013 *
014 * JBoss DNA is distributed in the hope that it will be useful,
015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017 * Lesser General Public License for more details.
018 *
019 * You should have received a copy of the GNU Lesser General Public
020 * License along with this software; if not, write to the Free
021 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
022 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
023 */
024 package org.jboss.dna.graph.request;
025
026 import org.jboss.dna.common.util.CheckArg;
027 import org.jboss.dna.graph.Location;
028
029 /**
030 * Verify that a workspace exists with the supplied name. This is useful to determine the name of the "default" workspace for a
031 * source.
032 */
033 public final class VerifyWorkspaceRequest extends Request {
034
035 private static final long serialVersionUID = 1L;
036
037 private final String workspaceName;
038 private Location actualLocationOfRoot;
039 private String actualWorkspaceName;
040
041 /**
042 * Create a request to verify the existance of the named workspace.
043 *
044 * @param workspaceName the desired name of the workspace, or null if the source's default workspace should be used
045 */
046 public VerifyWorkspaceRequest( String workspaceName ) {
047 this.workspaceName = workspaceName;
048 }
049
050 /**
051 * Get the desired name for the workspace.
052 *
053 * @return the desired name for the workspace, or null if the source's default workspace is to be verified
054 */
055 public String workspaceName() {
056 return workspaceName;
057 }
058
059 /**
060 * Get the actual name of the workspace.
061 *
062 * @return the actual name of the workspace, or null if a workspace was not verified (yet)
063 */
064 public String getActualWorkspaceName() {
065 return actualWorkspaceName;
066 }
067
068 /**
069 * Set the actual name of the workspace.
070 *
071 * @param actualWorkspaceName the actual name of the workspace; never null
072 */
073 public void setActualWorkspaceName( String actualWorkspaceName ) {
074 CheckArg.isNotNull(actualWorkspaceName, "actualWorkspaceName");
075 this.actualWorkspaceName = actualWorkspaceName;
076 }
077
078 /**
079 * Get the actual location of the root node in the new workspace, or null if the workspace was not (yet) created.
080 *
081 * @return the actual location of the root node in the new workspace, or null if the workspace was not (yet) created
082 */
083 public Location getActualLocationOfRoot() {
084 return actualLocationOfRoot;
085 }
086
087 /**
088 * Set the actual location of the root node in the new workspace.
089 *
090 * @param actualLocationOfRoot the actual location of the workspace's root node.
091 */
092 public void setActualRootLocation( Location actualLocationOfRoot ) {
093 this.actualLocationOfRoot = actualLocationOfRoot;
094 }
095
096 /**
097 * {@inheritDoc}
098 *
099 * @see org.jboss.dna.graph.request.Request#isReadOnly()
100 */
101 @Override
102 public boolean isReadOnly() {
103 return false;
104 }
105
106 /**
107 * {@inheritDoc}
108 *
109 * @see java.lang.Object#hashCode()
110 */
111 @Override
112 public int hashCode() {
113 return workspaceName.hashCode();
114 }
115
116 /**
117 * {@inheritDoc}
118 *
119 * @see java.lang.Object#equals(java.lang.Object)
120 */
121 @Override
122 public boolean equals( Object obj ) {
123 if (obj == this) return true;
124 if (this.getClass().isInstance(obj)) {
125 VerifyWorkspaceRequest that = (VerifyWorkspaceRequest)obj;
126 if (!this.workspaceName.equals(that.workspaceName())) return false;
127 return true;
128 }
129 return false;
130 }
131
132 /**
133 * {@inheritDoc}
134 *
135 * @see java.lang.Object#toString()
136 */
137 @Override
138 public String toString() {
139 return "verify workspace \"" + workspaceName() + "\"";
140 }
141 }