1 /*
2 * ModeShape (http://www.modeshape.org)
3 * See the COPYRIGHT.txt file distributed with this work for information
4 * regarding copyright ownership. Some portions may be licensed
5 * to Red Hat, Inc. under one or more contributor license agreements.
6 * See the AUTHORS.txt file in the distribution for a full listing of
7 * individual contributors.
8 *
9 * Unless otherwise indicated, all code in ModeShape is licensed
10 * to you under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
13 *
14 * ModeShape is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this software; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23 */
24 package org.modeshape.graph.request;
25
26 import java.util.Set;
27
28 /**
29 * A request to obtain the information about the workspaces that are available.
30 */
31 public class GetWorkspacesRequest extends CacheableRequest {
32
33 private static final long serialVersionUID = 1L;
34
35 private Set<String> availableWorkspaceNames;
36
37 /**
38 * Create a request to obtain the information about the available workspaces.
39 */
40 public GetWorkspacesRequest() {
41 }
42
43 /**
44 * {@inheritDoc}
45 *
46 * @see org.modeshape.graph.request.Request#isReadOnly()
47 */
48 @Override
49 public boolean isReadOnly() {
50 return true;
51 }
52
53 /**
54 * Get the names of workspaces that are available (at least to the current user)
55 *
56 * @return the set of workspace names, or null if the request has not been completed
57 */
58 public Set<String> getAvailableWorkspaceNames() {
59 return availableWorkspaceNames;
60 }
61
62 /**
63 * Set the names of the workspaces that are available (at least to the current user)
64 *
65 * @param availableWorkspaceNames Sets availableWorkspaceNames to the specified value.
66 * @throws IllegalStateException if the request is frozen
67 */
68 public void setAvailableWorkspaceNames( Set<String> availableWorkspaceNames ) {
69 checkNotFrozen();
70 this.availableWorkspaceNames = availableWorkspaceNames;
71 }
72
73 /**
74 * {@inheritDoc}
75 *
76 * @see org.modeshape.graph.request.Request#cancel()
77 */
78 @Override
79 public void cancel() {
80 super.cancel();
81 this.availableWorkspaceNames = null;
82 }
83
84 /**
85 * {@inheritDoc}
86 *
87 * @see java.lang.Object#hashCode()
88 */
89 @Override
90 public int hashCode() {
91 return getClass().hashCode();
92 }
93
94 /**
95 * {@inheritDoc}
96 *
97 * @see java.lang.Object#equals(java.lang.Object)
98 */
99 @Override
100 public boolean equals( Object obj ) {
101 if (obj == this) return true;
102 if (this.getClass().isInstance(obj)) {
103 // All workspace requests are consider equal
104 return true;
105 }
106 return false;
107 }
108
109 /**
110 * {@inheritDoc}
111 *
112 * @see java.lang.Object#toString()
113 */
114 @Override
115 public String toString() {
116 return "request workspaces";
117 }
118
119 @Override
120 public RequestType getType() {
121 return RequestType.GET_WORKSPACES;
122 }
123
124 }