Statistics
| Revision:

gvsig-projects-pool / org.gvsig.vcsgis / trunk / org.gvsig.vcsgis / org.gvsig.vcsgis.lib / org.gvsig.vcsgis.lib.api / src / main / java / org / gvsig / vcsgis / lib / VCSGisManager.java @ 8612

History | View | Annotate | Download (15.1 KB)

1
package org.gvsig.vcsgis.lib;
2

    
3
/* gvSIG. Desktop Geographic Information System.
4
 *
5
 * Copyright (c) 2007-2020 gvSIG Association
6
 *
7
 * This program is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License
9
 * as published by the Free Software Foundation; either version 2
10
 * of the License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
 * MA  02110-1301, USA.
21
 *
22
 * For any additional information, do not hesitate to contact us
23
 * at info AT gvsig.com, or visit our website www.gvsig.com.
24
 */
25

    
26
import java.io.File;
27
import java.io.Writer;
28
import java.lang.ref.WeakReference;
29
import java.net.URL;
30
import java.util.List;
31
import java.util.Map;
32
import javax.json.JsonObject;
33
import javax.servlet.http.HttpServlet;
34
import org.apache.commons.lang3.tuple.Pair;
35
import org.cresques.cts.IProjection;
36
import org.gvsig.fmap.dal.feature.FeatureStore;
37
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
38
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer;
39
import org.gvsig.fmap.geom.primitive.Envelope;
40
import org.gvsig.tools.dynobject.DynObjectValueItem;
41
import org.gvsig.tools.task.SimpleTaskStatus;
42
import org.gvsig.tools.util.Factory;
43
import org.gvsig.vcsgis.lib.repository.VCSGisIdentityController;
44
import org.gvsig.vcsgis.lib.repository.VCSGisRepository;
45
import org.gvsig.vcsgis.lib.repository.VCSGisRepositoryLocaldb;
46
import org.gvsig.vcsgis.lib.repository.requests.VCSGisAuthenticateRequest;
47
import org.gvsig.vcsgis.lib.server.VCSGisServerController;
48
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace;
49
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceDescriptor;
50

    
51

    
52
/**
53
 * @author gvSIG Teamn
54
 *
55
 */
56
public interface VCSGisManager {
57

    
58
    public static final String STORESREPOSITORY_VCSGIS_MODEL = "VCSGISModel";
59
    public static final String STORESREPOSITORY_VCSGIS_LOCALURL = "VCSGISLocalUrl";
60

    
61
    public static final int ERR_OK = 0;
62
    public static final int ERR_NO_ERROR = ERR_OK;
63
    public static final int ERR_DBFILE_IS_NULL = 1;
64
    public static final int ERR_WSEXPLORER_IS_NULL = 2;
65
    public static final int ERR_CANT_OPEN_WORKSPACE = 3;
66
    public static final int ERR_CANT_OPEN_WORKSPACE_SERVEREXPLORER = 4;
67
    public static final int ERR_STORE_NOT_IN_VERSION_CONTROL = 5;
68
    public static final int ERR_LABEL_IS_NULL = 6;
69
    public static final int ERR_CANT_EXECUTE_REQUEST = 7;
70
    public static final int ERR_CANT_BUILD_REQUEST_RESPONSE = 8;
71
    public static final int ERR_CANT_BUILD_REQUEST = 9;
72
    public static final int ERR_CANT_HANDLE_REQUEST = 10;
73
    public static final int ERR_CANT_INITIALIZE_REPOSITORY = 11;
74
    public static final int ERR_CANT_CONSUME_RESPONSE = 12;
75
    public static final int ERR_INVALID_DATA = 13;
76
    public static final int ERR_INVALID_REPOSITORY = 14;
77
    public static final int ERR_INVALID_REVISION = 15;
78
    public static final int ERR_INVALID_REVISION_FOR_ENTITY = 16;
79
    public static final int ERR_CANCELLED_BY_USER = 17;
80
    public static final int ERR_CANT_ADD_LAYER = 18;
81
    public static final int ERR_CANT_AUTHENTICATE_USER = 19;
82
    public static final int ERR_INVALID_AUTHENTICATION_TOKEN = 20;
83
    public static final int ERR_USER_NOT_AUTHORIZED = 21;
84
    public static final int ERR_AUTHENTICATION_EXPIRED = 22;
85
    public static final int ERR_INVALID_USERCODE = 23;
86
    public static final int ERR_INVALID_PARAMETERS = 24;
87
    public static final int ERR_EXCEPTION = 25;
88
    public static final int ERR_TABLE_IS_EDITING = 26;
89

    
90
    public static final int ERR_CANT_RETRIEVE_USERS = 30;
91
    public static final int ERR_CANT_RETRIEVE_TOPOLOGYPLANS = 31;
92
    public static final int ERR_TOPOLOGYPLAN_REQUIRED = 32;
93
    public static final int ERR_TOPOLOGYPLAN_OUTDATED = 33;
94
    
95
    public static final int ERR_INVALID_RECORDCODE = 34;
96
    public static final int ERR_DATA_RECORD_NOT_FOUND = 35;
97
    
98
    public static final int ERR_INVALID_ENTITY = 36;
99
    public static final int ERR_OPERATION_NOT_ALLOWED_WITH_LINKEDTABLE = 37;
100
    public static final int ERR_TOO_MANY_REPOSITORIES = 39;
101
    
102
    public static final int ERR_CANT_CREATE_TABLE = 100;
103
    public static final int ERR_CANT_CREATE_TABLE_CONFIG = 110;
104
    public static final int ERR_CANT_CREATE_TABLE_ENTITIES = 120;
105
    public static final int ERR_CANT_CREATE_TABLE_CHANGES = 130;
106
    
107
    public static final int ERR_ENTITY_ALREADY_EXISTS = 200;
108
    public static final int ERR_ENTITY_NOT_HAS_VCSGISCODE = 210;
109
    public static final int ERR_CANT_OPEN_ENTITIES = 220;
110
    public static final int ERR_CANT_INSERT_ENTITIES = 230;
111
    public static final int ERR_ENTITY_NOT_EXISTS = 240;
112
    public static final int ERR_CANT_RETRIEVE_ENTITIES = 250;
113
    public static final int ERR_CANT_ADD_ENTITY_WITHOUT_PRIMARY_KEY = 260;
114
    public static final int ERR_CANT_ADD_TABLE = 270;
115
    public static final int ERR_CANT_REMOVE_ENTITY = 280;
116
    
117
    public static final int ERR_CANT_OPEN_CHANGES = 300;
118
    public static final int ERR_CANT_INSERT_CHANGE = 310;
119
    public static final int ERR_CANT_ADD_CHANGE = 320;
120
    public static final int ERR_CANT_REMOVE_CHANGES = 330;
121

    
122
    public static final int ERR_CANT_OPEN_STORE = 400;
123
    public static final int ERR_CANT_RETRIEVE_SOURCE_FEATURES = 410;
124
    public static final int ERR_CANT_INSERT_FEATURES = 420;
125

    
126
    public static final int ERR_CANT_COMMIT = 500;
127
    public static final int ERR_CANT_COMMIT_WORKSPACE_OUTDATED = 510;
128
    public static final int ERR_CANT_COMMIT_WITH_FEATURE_CODE_BLANK = 520;
129
    public static final int ERR_CANT_COMMIT_WITH_FEATURE_DATA_BLANK = 530;
130

    
131
    public static final int ERR_CANT_CHECKOUT = 600;
132
    
133
    public static final int ERR_CANT_REVERT = 700;
134
    
135
    public static final int ERR_CANT_UPDATE_ENTITIES = 70;
136

    
137
    public static final int ERR_CANT_UPDATE = 80;
138
    public static final int ERR_CANT_PREPARE_UPDATE = 81;
139
    public static final int ERR_UPDATE_NEED_MERGE = 82;
140
    public static final int ERR_CANT_UPDATE_CLEAN = 83;
141
    public static final int ERR_CANT_MERGE = 84;
142
    public static final int ERR_CANNOT_UPDATE_TABLE_THAT_NOT_EXIST = 85;
143
    
144
    public static final int ERR_CANT_PREPARE_WORKSPACE = 800;
145
    public static final int ERR_REPOSITORY_URL_NOT_DEFINED = 801;
146
    public static final int ERR_WORKING_COPIES_FOLDER_NOT_DEFINED = 802;
147
    
148
    public static final int ERR_CANT_EXPORT = 900;
149
    
150
    public static final int ERR_USER_CANCELLED = 10000;
151
    public static final int ERR_OFFLINE = 10001;
152
    
153
    public static final int STATE_UNKNOWN = 0; 
154
    public static final int STATE_LOCAL_UNMODIFIED = 1;
155
    public static final int STATE_LOCAL_NEW = 2;
156
    public static final int STATE_LOCAL_MODIFIED = 4;
157
    public static final int STATE_LOCAL_OUTDATED = 6;
158
    public static final int STATE_LOCAL_OUTDATED_AND_MODIFIED = 8;
159
    public static final int STATE_CONFLICT = 16;
160
    public static final int STATE_REPOSITORY_NEW = 32;
161
    public static final int STATE_NOT_IN_LOCAL_OR_REPOSITORY = 64;
162
    public static final int STATE_DISCONNECTED = 128;
163
    public static final int STATE_CORRUPT = 256;
164
    public static final int STATE_REPOSITORY_MODIFIED = STATE_LOCAL_OUTDATED;
165
    
166
    // Repository and workspace operations
167
    public static final int OP_UNKNOWN = -1;
168
    public static final int OP_DELETE = 0;
169
    public static final int OP_UPDATE = 1;
170
    public static final int OP_INSERT = 2;
171

    
172
    //Only workspace operations
173
    public static final int OP_ADD_ENTITY = 3;
174
    public static final int OP_IGNORE = 4;
175

    
176
    public static final int TOPOLOGYPLAN_UNKNOWN = 0;
177
    public static final int TOPOLOGYPLAN_PASSED = 1;
178
    public static final int TOPOLOGYPLAN_NOTPASSED = 2;
179
    
180
    public static final int TOPOLOGYPLAN_MODE_RECOMMENDED = 0;
181
    public static final int TOPOLOGYPLAN_MODE_MANDATORY = 1;
182
    
183
    public static final String DEFAULT_DATA_TABLE = "VCSGISREPO_DATA";
184
    public static final String FEATURECODE_FIELD_NAME = "VCSGISCODE";
185
    
186
    public static final int VCSGISCODELEN = 60;
187

    
188
    
189
    public static final String TAG_VCSGIS_LABEL = "vcsgis.label";
190
    public static final String TAG_VCSGIS_DATAMODEL = "vcsgis.datamodel";
191
    public static final String TAG_VCSGIS_CATEGORY = "vcsgis.category";
192
    public static final String TAG_VCSGIS_FIELDFORLABEL = "vcsgis.fieldforlabel";
193
    public static final String TAG_VCSGIS_RESOURCES = "vcsgis.resources";
194
    public static final String TAG_VCSGIS_TABLENAME = "vcsgis.storename";
195
    
196
    
197
    public static final String GUEST_USER_CODE = "00000000000000000000000000000000000000";
198
    public static final String GUEST_USER_ID = "guest";
199
    
200
    public static final String DEFAULT_REPOSITORY_CRS = "EPSG:25830";
201
    
202
    public void clean();
203
    
204
    /**
205
     * Initializes a workspace in the indicated database with the indicated 
206
     * label and associates it with the indicated repository.
207
     * 
208
     * It fails if a workspace is already created in that database.
209
     * 
210
     * A code will be assigned to the workspace automatically.
211
     * 
212
     * @param database in which to initialize the workspace.
213
     * @param repository to associate the workspace with.
214
     * @param label repository to associate the workspace with.
215
     * @param status
216
     * @return a error code.
217
     */
218
    public int initWorkspace(JDBCServerExplorer database, VCSGisRepository repository, String label, SimpleTaskStatus status);
219

    
220
    /**
221
     * Initializes a workspace in the H2 database associated with the 
222
     * indicated file with the indicated label and associating it with 
223
     * the indicated repository.
224
     * 
225
     * It fails if a workspace is already created in that database.
226
     * 
227
     * A code will be assigned to the workspace automatically.
228
     * 
229
     * @param dbfile file associated with database H2 in which to initialize the workspace.
230
     * @param repository to associate the workspace with.
231
     * @param label repository to associate the workspace with.
232
     * @param status
233
     * @return a error code.
234
     */
235
    public int initWorkspace(File dbfile, VCSGisRepository repository, String label, SimpleTaskStatus status);
236

    
237
    public VCSGisWorkspace openWorkspace(JDBCServerExplorer workspace);
238
    
239
    public VCSGisWorkspace openWorkspace(File wsfile);
240
    
241
    public VCSGisWorkspace openWorkspace(File wsfile, String label);
242
    
243
    public VCSGisWorkspace openWorkspace(JDBCServerExplorer wsexplorer, String label);
244
    
245
    /**
246
     * Return a Map with the workspace descriptors registered in this manager.
247
     * 
248
     * The Map is indexed by the code of the workspace.
249
     * 
250
     * If the manager has not any workspace registered, return a empty Map.
251
     * 
252
     * @return the Map with the registered workspace descriptors.
253
     */
254
    public Map<String, VCSGisWorkspaceDescriptor> getWorkspaces();
255
    
256
    /**
257
     * Register a VCSGis-workspace in this manager.
258
     * 
259
     * @param workspace to register
260
     */
261
    public void registerWorkspace(VCSGisWorkspace workspace);
262

    
263
    public void deregisterWorkspace(File dbfile);
264
    
265
    /**
266
     * Deregister the VCSGis-workspace of this manager.
267
     * 
268
     * @param workspace to deregister
269
     */
270
    public void deregisterWorkspace(VCSGisWorkspace workspace);
271
    public void deregisterWorkspace(String workspaceCode);
272

    
273
    /**
274
     * Replace the current registered workspaces by the indicaded as the Map
275
     * of parameters in this manager.
276
     * 
277
     * If descriptors is null, remove al registered workspaces in this manager.
278
     * 
279
     * This method is designed to support the persistence of this manager's workspaces.
280
     * 
281
     * @param descriptors 
282
     */
283
    public void restoreWorkspaces(Map<String, VCSGisWorkspaceDescriptor> descriptors);
284
    
285
    /**
286
     * Returns the workspace associated with the store.
287
     * 
288
     * If the store is not associated with any registered workspace, it returns null.
289
     * 
290
     * The method can add properties to the store to optimize future invocations.
291
     * 
292
     * @param store
293
     * 
294
     * @return the workspace of the store or null.
295
     */
296
    public VCSGisWorkspace getWorkspace(FeatureStore store);
297
    
298
    /**
299
     * Return true if the file is a database of H2 that contains a VCSGis-workspace,
300
     * otherwise return false.
301
     * 
302
     * @param dbfile
303
     * @return 
304
     */
305
    public boolean isWorkspace(File dbfile);
306
    
307
    /**
308
     * Return true if the explorer parameters reference a database that contains a VCSGis-workspace,
309
     * otherwise return false.
310
     * 
311
     * @param params
312
     * @return 
313
     */
314
    public boolean isWorkspace(JDBCServerExplorerParameters params);
315

    
316
    public boolean isRepository(JDBCServerExplorerParameters params);
317

    
318
    public VCSGisWorkspaceDescriptor getWorkspaceDescriptor(String code);
319

    
320
    public int initRepository(JDBCServerExplorerParameters repositoryParameters, IProjection crs, Envelope tablebbox, boolean indexGeometries, SimpleTaskStatus status);
321
    
322
    public int initRepository(JDBCServerExplorerParameters repositoryParameters, SimpleTaskStatus status);
323
    
324
    public VCSGisRepository openRepository(JDBCServerExplorerParameters repositoryParameters);
325
    
326
    public VCSGisRepository openRepository(URL repository);
327

    
328
    public VCSGisRepository openRepository(JsonObject jsonrepo);
329
    
330
    public VCSGisServerController createServerController(VCSGisRepository repository);
331

    
332
    public void setCodeGenerator(VCSGisCodeGenerator generator);
333
    
334
    public VCSGisCodeGenerator getCodeGenerator();
335
    
336
    public String getErrorMessage(int errcode);
337
    
338
    public void setUserIdentificationRequester(VCSGisUserIdentificationRequester userIdentificationRequester);
339
    
340
    public VCSGisUserIdentificationRequester getUserIdentificationRequester();
341

    
342
    public void setAuthenticateRequestFactory(Factory<VCSGisAuthenticateRequest> authenticateRequest);
343

    
344
    public Factory<VCSGisAuthenticateRequest> getAuthenticateRequestFactory();
345

    
346
    public void setIdentityControllertFactory(Factory<VCSGisIdentityController> IdentityControllerFactory);
347
    
348
    public Factory<VCSGisIdentityController> getIdentityControllerFactory();    
349
    
350
    public VCSGisTopologyPlanStatus createTopologyPlanStatus(String topologyPlanCode, String hashCode, boolean passed);
351
    
352
    public Class<? extends HttpServlet>  getServletClass(String name);
353

    
354
    public List<VCSGisPreparedWorkingCopyInformation> getPreparedWorkingCopyInformation(URL server);
355

    
356
    public List<VCSGisPreparedWorkingCopyInformation> getPreparedWorkingCopyInformation(JDBCServerExplorerParameters repositoryParameters);
357

    
358
    public int preparedWorkingCopy(URL server, String name, String label, String categories, String username, String userpass);
359
    
360
    public List<Pair<WeakReference<FeatureStore>,Integer>> getEditingStores();
361
    
362
    public void forceRemoveFromEditingStores(FeatureStore store);
363
    
364
    public boolean isThereAnyStoreInEditing();
365
    
366
    public boolean IsThereConflictingStoresInEdition();
367
    
368
    public void setWriterForProtocolDebugging(Writer writer);
369
    
370
    public Writer getWriterForProtocolDebugging();
371
    
372
}