Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java @ 157:6e6965873a48
Simplified creation of users.
artifacts/trunk@1382 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 03 Mar 2011 10:33:49 +0000 |
parents | a76de72ad6d1 |
children | d718a4d55662 |
rev | line source |
---|---|
100
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
1 /* |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
2 * Copyright (c) 2010 by Intevation GmbH |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
3 * |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
7 */ |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
8 |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 package de.intevation.artifactdatabase; |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
157
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
11 import de.intevation.artifacts.ArtifactCollection; |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.Artifact; |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
13 import de.intevation.artifacts.ArtifactFactory; |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
14 import de.intevation.artifacts.ArtifactSerializer; |
133
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
15 import de.intevation.artifacts.User; |
157
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
16 import de.intevation.artifacts.UserFactory; |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 |
138
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
18 import de.intevation.artifacts.common.utils.XMLUtils; |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
19 |
93
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
90
diff
changeset
|
20 import java.sql.Connection; |
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
90
diff
changeset
|
21 import java.sql.PreparedStatement; |
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
90
diff
changeset
|
22 import java.sql.ResultSet; |
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
90
diff
changeset
|
23 import java.sql.SQLException; |
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
90
diff
changeset
|
24 import java.sql.Types; |
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
90
diff
changeset
|
25 |
148
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
26 import java.util.ArrayList; |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
27 |
93
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
90
diff
changeset
|
28 import javax.sql.DataSource; |
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
90
diff
changeset
|
29 |
17
5a6b6a3debc7
Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
15
diff
changeset
|
30 import org.apache.log4j.Logger; |
5a6b6a3debc7
Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
15
diff
changeset
|
31 |
133
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
32 import org.w3c.dom.Document; |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
33 |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
34 |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 /** |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
36 * The backend implements the low level layer used to store artifacts |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
37 * in a SQL database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
38 * |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
39 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 */ |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 public class Backend |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
42 implements DatabaseCleaner.ArtifactReviver |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 { |
17
5a6b6a3debc7
Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
15
diff
changeset
|
44 private static Logger logger = Logger.getLogger(Backend.class); |
5a6b6a3debc7
Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
15
diff
changeset
|
45 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
46 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
47 * The SQL statement to create new artifact id inside the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
48 */ |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
49 public static final String SQL_NEXT_ID = |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
50 SQL.get("artifacts.id.nextval"); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
51 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
52 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
53 * The SQL statement to insert an artifact into the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
54 */ |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
55 public static final String SQL_INSERT = |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
56 SQL.get("artifacts.insert"); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
57 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
58 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
59 * The SQL statement to update some columns of an existing |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
60 * artifact in the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
61 */ |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
62 public static final String SQL_UPDATE = |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
63 SQL.get("artifacts.update"); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
64 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
65 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
66 * The SQL statement to touch the access time of an |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
67 * artifact inside the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
68 */ |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
69 public static final String SQL_TOUCH = |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
70 SQL.get("artifacts.touch"); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
71 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
72 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
73 * The SQL statement to load an artifact by a given |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
74 * identifier from the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
75 */ |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
76 public static final String SQL_LOAD_BY_GID = |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
77 SQL.get("artifacts.select.gid"); |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
78 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
79 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
80 * The SQL statement to get the database id of an artifact |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
81 * identified by the identifier. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
82 */ |
80
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
83 public static final String SQL_GET_ID = |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
84 SQL.get("artifacts.get.id"); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
85 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
86 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
87 * The SQL statement to replace the content of an |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
88 * existing artifact inside the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
89 */ |
80
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
90 public static final String SQL_REPLACE = |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
91 SQL.get("artifacts.replace"); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
92 |
133
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
93 // USER SQL |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
94 |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
95 public static final String SQL_USERS_NEXT_ID = |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
96 SQL.get("users.id.nextval"); |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
97 |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
98 public static final String SQL_USERS_INSERT = |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
99 SQL.get("users.insert"); |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
100 |
144
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
101 public static final String SQL_USERS_SELECT_ID_BY_GID = |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
102 SQL.get("users.select.id.by.gid"); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
103 |
133
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
104 public static final String SQL_USERS_SELECT_GID = |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
105 SQL.get("users.select.gid"); |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
106 |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
107 public static final String SQL_USERS_DELETE_ID = |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
108 SQL.get("users.delete.id"); |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
109 |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
110 public static final String SQL_USERS_DELETE_COLLECTIONS = |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
111 SQL.get("users.delete.collections"); |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
112 |
148
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
113 public static final String SQL_USERS_SELECT_ALL = |
133
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
114 SQL.get("users.select.all"); |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
115 |
144
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
116 public static final String SQL_USERS_COLLECTIONS = |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
117 SQL.get("users.collections"); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
118 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
119 public static final String SQL_USERS_COLLECTION_IDS = |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
120 SQL.get("users.collection.ids"); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
121 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
122 public static final String SQL_USERS_DELETE_ALL_COLLECTIONS = |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
123 SQL.get("users.delete.all.collections"); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
124 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
125 public static final String SQL_ARTIFACTS_IN_ONLY_COLLECTION_ONLY = |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
126 SQL.get("artifacts.in.one.collection.only"); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
127 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
128 public static final String SQL_OUTDATE_ARTIFACTS_COLLECTION = |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
129 SQL.get("outdate.artifacts.collection"); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
130 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
131 public static final String SQL_OUTDATE_ARTIFACTS_USER = |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
132 SQL.get("outdate.artifacts.user"); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
133 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
134 public static final String SQL_DELETE_USER_COLLECTION_ITEMS = |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
135 SQL.get("delete.user.collection.items"); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
136 |
128
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
137 /** The singleton.*/ |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
138 protected static Backend instance; |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
139 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
140 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
141 * The database cleaner. Reference is stored here because |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
142 * the cleaner is woken up if the backend finds an outdated |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
143 * artifact. This artifact should be removed as soon as |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
144 * possible. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
145 */ |
30
88972c6daa4f
Added a cleanup thread which periodically removes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
146 protected DatabaseCleaner cleaner; |
88972c6daa4f
Added a cleanup thread which periodically removes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
147 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
148 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
149 * To revive an artifact from the bytes coming from the database |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
150 * we need the artifact factory which references the artifact |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
151 * serializer which is able to do the reviving job. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
152 */ |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
153 protected FactoryLookup factoryLookup; |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
154 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
155 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
156 * Little helper interface to decouple the ArtifactDatabase |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
157 * from the Backend. A ArtifactDatabase should depend on a |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
158 * Backend but a Backend not from an ArtifactDatabase. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
159 */ |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
160 public interface FactoryLookup { |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
161 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
162 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
163 * Returns an ArtifactFactory which is bound to a given name. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
164 * @param factoryName The name of the artifact factory. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
165 * @return The ArtifactFactory bound to the factory name or |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
166 * null if not matching factory is found. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
167 */ |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
168 ArtifactFactory getArtifactFactory(String factoryName); |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
169 |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
170 } // interface FactoryLookup |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
171 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
172 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
173 * Inner class that brigdes between the persisten form of the |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
174 * artifact and the living one inside the artifact database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
175 * After the describe(), feed(), advance() and out() operations |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
176 * of the artifact it must be possible to write to modified artifact |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
177 * back into the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
178 */ |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
179 public final class PersistentArtifact |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
180 extends Id |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
181 { |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
182 private Artifact artifact; |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
183 private ArtifactSerializer serializer; |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
184 private Long ttl; |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
185 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
186 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
187 * Cronstructor to create a persistent artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
188 * @param artifact The living artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
189 * @param serializer The serializer to store the artifact |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
190 * after the operations. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
191 * @param ttl The time to life of the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
192 * @param id The database id of the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
193 */ |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
194 public PersistentArtifact( |
47
4ae4dc99127d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
46
diff
changeset
|
195 Artifact artifact, |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
196 ArtifactSerializer serializer, |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
197 Long ttl, |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
198 int id |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
199 ) { |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
200 super(id); |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
201 this.artifact = artifact; |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
202 this.serializer = serializer; |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
203 this.ttl = ttl; |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
204 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
205 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
206 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
207 * Returns the wrapped living artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
208 * @return the living artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
209 */ |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
210 public Artifact getArtifact() { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
211 return artifact; |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
212 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
213 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
214 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
215 * Returns the serialized which is able to write a |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
216 * modified artifact back into the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
217 * @return The serializer. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
218 */ |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
219 public ArtifactSerializer getSerializer() { |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
220 return serializer; |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
221 } |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
222 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
223 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
224 * The time to life of the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
225 * @return The time to live. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
226 */ |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
227 public Long getTTL() { |
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
228 return ttl; |
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
229 } |
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
230 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
231 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
232 * Stores the living artifact back into the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
233 */ |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
234 public void store() { |
38
93edc04f3a10
Added postgresql support.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
34
diff
changeset
|
235 if (logger.isDebugEnabled()) { |
93edc04f3a10
Added postgresql support.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
34
diff
changeset
|
236 logger.debug("storing artifact id = " + getId()); |
93edc04f3a10
Added postgresql support.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
34
diff
changeset
|
237 } |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
238 Backend.this.store(this); |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
239 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
240 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
241 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
242 * Only touches the access time of the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
243 */ |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
244 public void touch() { |
38
93edc04f3a10
Added postgresql support.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
34
diff
changeset
|
245 if (logger.isDebugEnabled()) { |
93edc04f3a10
Added postgresql support.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
34
diff
changeset
|
246 logger.debug("touching artifact id = " + getId()); |
93edc04f3a10
Added postgresql support.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
34
diff
changeset
|
247 } |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
248 Backend.this.touch(this); |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
249 } |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
250 } // class ArtifactWithId |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
251 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
252 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
253 * Default constructor |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
254 */ |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
255 public Backend() { |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
256 } |
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
257 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
258 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
259 * Constructor to create a backend with a link to the database cleaner. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
260 * @param cleaner The clean which periodically removes outdated |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
261 * artifacts from the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
262 */ |
30
88972c6daa4f
Added a cleanup thread which periodically removes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
263 public Backend(DatabaseCleaner cleaner) { |
88972c6daa4f
Added a cleanup thread which periodically removes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
264 this.cleaner = cleaner; |
88972c6daa4f
Added a cleanup thread which periodically removes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
265 } |
88972c6daa4f
Added a cleanup thread which periodically removes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
266 |
128
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
267 |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
268 /** |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
269 * Returns the singleton of this Backend. |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
270 * |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
271 * @return the backend. |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
272 */ |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
273 public static synchronized Backend getInstance() { |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
274 if (instance == null) { |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
275 instance = new Backend(); |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
276 } |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
277 |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
278 return instance; |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
279 } |
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
280 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
281 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
282 * Sets the factory lookup mechanism to decouple ArtifactDatabase |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
283 * and Backend. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
284 * @param factoryLookup |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
285 */ |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
286 public void setFactoryLookup(FactoryLookup factoryLookup) { |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
287 this.factoryLookup = factoryLookup; |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
288 } |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
289 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
290 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
291 * Sets the database cleaner explicitly. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
292 * @param cleaner The database cleaner |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
293 */ |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
294 public void setCleaner(DatabaseCleaner cleaner) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
295 this.cleaner = cleaner; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
296 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
297 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
298 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
299 * Returns a new unique identifier to external identify |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
300 * the artifact across the system. This implementation |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
301 * uses random UUIDs v4 to achieve this target. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
302 * @return the new identifier |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
303 */ |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
304 public String newIdentifier() { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
305 // TODO: check database for collisions. |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
306 return StringUtils.newUUID(); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
307 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
308 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
309 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
310 * Stores a new artifact into the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
311 * @param artifact The artifact to be stored |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
312 * @param factory The factory which build the artifact |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
313 * @param ttl The initial time to life of the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
314 * @return A persistent wrapper around the living |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
315 * artifact to be able to write modification later. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
316 * @throws Exception Thrown if something went wrong with the |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
317 * storage process. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
318 */ |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
319 public PersistentArtifact storeInitially( |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
320 Artifact artifact, |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
321 ArtifactFactory factory, |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
322 Long ttl |
47
4ae4dc99127d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
46
diff
changeset
|
323 ) |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
324 throws Exception |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
325 { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
326 return new PersistentArtifact( |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
327 artifact, |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
328 factory.getSerializer(), |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
329 ttl, |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
330 insertDatabase(artifact, factory, ttl)); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
331 } |
47
4ae4dc99127d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
46
diff
changeset
|
332 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
333 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
334 * Stores an artifact into database if it does not exist there. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
335 * If it exists there it is only updated. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
336 * @param artifact The artifact to store/update. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
337 * @param factory The factory which created the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
338 * @param ttl The initial time to live of the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
339 * @return A persistent version of the artifact to be able |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
340 * to store a modification later. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
341 * @throws Exception Thrown if something went wrong during |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
342 * storing/updating. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
343 */ |
80
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
344 public PersistentArtifact storeOrReplace( |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
345 Artifact artifact, |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
346 ArtifactFactory factory, |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
347 Long ttl |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
348 ) |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
349 throws Exception |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
350 { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
351 return new PersistentArtifact( |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
352 artifact, |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
353 factory.getSerializer(), |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
354 ttl, |
80
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
355 storeOrReplaceDatabase(artifact, factory, ttl)); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
356 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
357 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
358 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
359 * Implementors of this interface are able to process the raw |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
360 * artifact data from the database for loading. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
361 */ |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
362 public interface ArtifactLoader { |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
363 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
364 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
365 * Creates a custom object from the raw artifact database data. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
366 * @param factory The factory that created this artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
367 * @param ttl The current time to life of the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
368 * @param bytes The raw artifact bytes from the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
369 * @param id The database id of the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
370 * @return The custom object created by the implementation. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
371 */ |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
372 Object load(ArtifactFactory factory, Long ttl, byte [] bytes, int id); |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
373 |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
374 } // interface ArtifactLoader |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
375 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
376 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
377 * Fetches an artifact from the database identified by the |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
378 * given identifier. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
379 * @param identifer The identifier of the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
380 * @return A persistent wrapper around the found artifact |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
381 * to be able to write back a modifaction later or null |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
382 * if no artifact is found for this identifier. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
383 */ |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
384 public PersistentArtifact getArtifact(String identifer) { |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
385 |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
386 return (PersistentArtifact)loadArtifact( |
86
b2e0cb83631c
Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
84
diff
changeset
|
387 identifer, |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
388 new ArtifactLoader() { |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
389 |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
390 public Object load( |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
391 ArtifactFactory factory, |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
392 Long ttl, |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
393 byte [] bytes, |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
394 int id |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
395 ) { |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
396 ArtifactSerializer serializer = factory.getSerializer(); |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
397 |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
398 Artifact artifact = serializer.fromBytes(bytes); |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
399 |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
400 return artifact == null |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
401 ? null |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
402 : new PersistentArtifact(artifact, serializer, ttl, id); |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
403 } |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
404 }); |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
405 } |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
406 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
407 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
408 * More general loading mechanism for artifacts. The concrete |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
409 * load processing is delegated to the given loader. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
410 * @param identifer The identifier of the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
411 * @param loader The loader which processes the raw database data. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
412 * @return The object created by the loader. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
413 */ |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
414 public Object loadArtifact(String identifer, ArtifactLoader loader) { |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
415 |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
416 if (!StringUtils.checkUUID(identifer)) { |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
417 return null; |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
418 } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
419 |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
420 Connection connection = null; |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
421 PreparedStatement stmnt_load = null; |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
422 ResultSet load_result = null; |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
423 |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
424 DataSource dataSource = DBConnection.getDataSource(); |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
425 try { |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
426 connection = dataSource.getConnection(); |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
427 stmnt_load = connection.prepareStatement(SQL_LOAD_BY_GID); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
428 stmnt_load.setString(1, identifer); |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
429 |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
430 load_result = stmnt_load.executeQuery(); |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
431 |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
432 if (!load_result.next()) { |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
433 return null; |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
434 } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
435 |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
436 int id = load_result.getInt(1); |
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
437 long ttlX = load_result.getLong(3); |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
438 |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
439 Long ttl = load_result.wasNull() ? null : Long.valueOf(ttlX); |
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
440 |
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
441 if (ttl != null) { // real time to life |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
442 long last_access = load_result.getTimestamp(2).getTime(); |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
443 if (last_access + ttlX < System.currentTimeMillis()) { |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
444 artifactOutdated(id); |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
445 return null; |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
446 } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
447 } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
448 |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
449 String factoryName = load_result.getString(4); |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
450 |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
451 if (factoryLookup == null) { |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
452 logger.error("factory lookup == null"); |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
453 return null; |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
454 } |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
455 |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
456 ArtifactFactory factory = factoryLookup |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
457 .getArtifactFactory(factoryName); |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
458 |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
459 if (factory == null) { |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
460 logger.error("factory '" + factoryName + "' not found"); |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
461 return null; |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
462 } |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
463 |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
464 byte [] bytes = load_result.getBytes(5); |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
465 |
84
72e2dd4feb31
Added the time to live of an artifact to the CallContext.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
80
diff
changeset
|
466 return loader.load(factory, ttl, bytes, id); |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
467 } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
468 catch (SQLException sqle) { |
17
5a6b6a3debc7
Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
15
diff
changeset
|
469 logger.error(sqle.getLocalizedMessage(), sqle); |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
470 } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
471 finally { |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
472 if (load_result != null) { |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
473 try { load_result.close(); } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
474 catch (SQLException sqle) {} |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
475 } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
476 if (stmnt_load != null) { |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
477 try { load_result.close(); } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
478 catch (SQLException sqle) {} |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
479 } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
480 if (connection != null) { |
47
4ae4dc99127d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
46
diff
changeset
|
481 try { connection.close(); } |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
482 catch (SQLException sqle) {} |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
483 } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
484 } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
485 return null; |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
486 } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
487 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
488 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
489 * Called if the load mechanism found an outdated artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
490 * It wakes up the database cleaner. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
491 * @param id The id of the outdated artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
492 */ |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
493 protected void artifactOutdated(int id) { |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
494 if (logger.isDebugEnabled()) { |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
495 logger.info("artifactOutdated: id = " + id); |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
496 } |
30
88972c6daa4f
Added a cleanup thread which periodically removes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
497 if (cleaner != null) { |
88972c6daa4f
Added a cleanup thread which periodically removes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
498 cleaner.wakeup(); |
88972c6daa4f
Added a cleanup thread which periodically removes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
499 } |
15
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
500 } |
9ad6ec2d09c3
Implemented restoring artifacts from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
14
diff
changeset
|
501 |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
502 public Artifact reviveArtifact(String factoryName, byte [] bytes) { |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
503 if (factoryLookup == null) { |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
504 logger.error("reviveArtifact: factory lookup == null"); |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
505 return null; |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
506 } |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
507 ArtifactFactory factory = factoryLookup |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
508 .getArtifactFactory(factoryName); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
509 |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
510 if (factory == null) { |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
511 logger.error( |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
512 "reviveArtifact: no factory '" + factoryName + "' found"); |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
513 return null; |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
514 } |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
515 |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
516 ArtifactSerializer serializer = factory.getSerializer(); |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
517 |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
518 return serializer.fromBytes(bytes); |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
519 } |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
520 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
521 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
522 * Internal method to store/replace an artifact inside the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
523 * If an artifact with the given identifier does not exists it is |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
524 * created else only the content data is updated. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
525 * @param artifact The artifact to be store/update inside the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
526 * @param factory The factory that created the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
527 * @param ttl The initial time to life of the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
528 * @return The database id of the stored/updated artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
529 */ |
80
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
530 protected int storeOrReplaceDatabase( |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
531 Artifact artifact, |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
532 ArtifactFactory factory, |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
533 Long ttl |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
534 ) { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
535 String uuid = artifact.identifier(); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
536 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
537 if (!StringUtils.checkUUID(uuid)) { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
538 throw new RuntimeException("No valid UUID"); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
539 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
540 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
541 Connection connection = null; |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
542 PreparedStatement stmnt = null; |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
543 ResultSet result = null; |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
544 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
545 DataSource dataSource = DBConnection.getDataSource(); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
546 try { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
547 connection = dataSource.getConnection(); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
548 try { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
549 connection.setAutoCommit(false); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
550 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
551 stmnt = connection.prepareStatement(SQL_GET_ID); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
552 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
553 stmnt.setString(1, uuid); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
554 result = stmnt.executeQuery(); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
555 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
556 Integer ID = result.next() |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
557 ? Integer.valueOf(result.getInt(1)) |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
558 : null; |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
559 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
560 result.close(); result = null; |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
561 stmnt.close(); stmnt = null; |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
562 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
563 if (ID != null) { // already in database |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
564 int id = ID.intValue(); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
565 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
566 stmnt = connection.prepareStatement(SQL_REPLACE); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
567 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
568 if (ttl == null) { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
569 stmnt.setNull(1, Types.BIGINT); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
570 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
571 else { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
572 stmnt.setLong(1, ttl.longValue()); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
573 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
574 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
575 stmnt.setString(2, factory.getName()); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
576 stmnt.setBytes( |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
577 3, |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
578 factory.getSerializer().toBytes(artifact)); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
579 stmnt.setInt(4, id); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
580 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
581 stmnt.execute(); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
582 connection.commit(); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
583 return id; |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
584 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
585 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
586 stmnt = connection.prepareStatement(SQL_NEXT_ID); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
587 result = stmnt.executeQuery(); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
588 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
589 if (!result.next()) { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
590 throw new RuntimeException("No id generated"); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
591 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
592 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
593 int id = result.getInt(1); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
594 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
595 result.close(); result = null; |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
596 stmnt.close(); stmnt = null; |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
597 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
598 stmnt = connection.prepareStatement(SQL_INSERT); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
599 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
600 stmnt.setInt(1, id); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
601 stmnt.setString(2, uuid); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
602 if (ttl == null) { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
603 stmnt.setNull(3, Types.BIGINT); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
604 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
605 else { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
606 stmnt.setLong(3, ttl.longValue()); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
607 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
608 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
609 stmnt.setString(4, factory.getName()); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
610 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
611 stmnt.setBytes( |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
612 5, |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
613 factory.getSerializer().toBytes(artifact)); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
614 |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
615 stmnt.execute(); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
616 connection.commit(); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
617 return id; |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
618 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
619 catch (SQLException sqle) { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
620 connection.rollback(); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
621 throw sqle; |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
622 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
623 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
624 catch (SQLException sqle) { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
625 logger.error(sqle.getLocalizedMessage(), sqle); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
626 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
627 finally { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
628 if (result != null) { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
629 try { result.close(); } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
630 catch (SQLException sqle) {} |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
631 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
632 if (stmnt != null) { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
633 try { stmnt.close(); } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
634 catch (SQLException sqle) {} |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
635 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
636 if (connection != null) { |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
637 try { connection.close(); } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
638 catch (SQLException sqle) {} |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
639 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
640 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
641 throw new RuntimeException("failed insert artifact into database"); |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
642 } |
8447467cef86
Implementation to import artifacts from incoming xml documents (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
643 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
644 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
645 * Internal method to store an artifact inside the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
646 * @param artifact The artifact to be stored. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
647 * @param factory The factory which created the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
648 * @param ttl The initial time to live of the artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
649 * @return The database id of the stored artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
650 */ |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
651 protected int insertDatabase( |
47
4ae4dc99127d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
46
diff
changeset
|
652 Artifact artifact, |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
653 ArtifactFactory factory, |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
654 Long ttl |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
655 ) { |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
656 String uuid = artifact.identifier(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
657 |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
658 Connection connection = null; |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
659 PreparedStatement stmnt_next_id = null; |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
660 PreparedStatement stmnt_insert = null; |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
661 ResultSet res_id = null; |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
662 |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
663 DataSource dataSource = DBConnection.getDataSource(); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
664 try { |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
665 connection = dataSource.getConnection(); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
666 try { |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
667 connection.setAutoCommit(false); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
668 |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
669 stmnt_next_id = connection.prepareStatement(SQL_NEXT_ID); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
670 stmnt_insert = connection.prepareStatement(SQL_INSERT); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
671 |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
672 res_id = stmnt_next_id.executeQuery(); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
673 |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
674 if (!res_id.next()) { |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
675 throw new RuntimeException("No id generated"); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
676 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
677 |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
678 int id = res_id.getInt(1); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
679 |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
680 stmnt_insert.setInt(1, id); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
681 stmnt_insert.setString(2, uuid); |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
682 if (ttl == null) { |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
683 stmnt_insert.setNull(3, Types.BIGINT); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
684 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
685 else { |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
686 stmnt_insert.setLong(3, ttl.longValue()); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
687 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
688 |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
689 stmnt_insert.setString(4, factory.getName()); |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
690 |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
691 stmnt_insert.setBytes( |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
692 5, |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
693 factory.getSerializer().toBytes(artifact)); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
694 |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
695 stmnt_insert.execute(); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
696 |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
697 connection.commit(); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
698 |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
699 return id; |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
700 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
701 catch (SQLException sqle) { |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
702 connection.rollback(); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
703 throw sqle; |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
704 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
705 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
706 catch (SQLException sqle) { |
17
5a6b6a3debc7
Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
15
diff
changeset
|
707 logger.error(sqle.getLocalizedMessage(), sqle); |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
708 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
709 finally { |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
710 if (res_id != null) { |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
711 try { res_id.close(); } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
712 catch (SQLException sqle) {} |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
713 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
714 if (stmnt_insert != null) { |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
715 try { stmnt_insert.close(); } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
716 catch (SQLException sqle) {} |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
717 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
718 if (stmnt_next_id != null) { |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
719 try { stmnt_next_id.close(); } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
720 catch (SQLException sqle) {} |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
721 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
722 if (connection != null) { |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
723 try { connection.close(); } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
724 catch (SQLException sqle) {} |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
725 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
726 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
727 throw new RuntimeException("failed insert artifact into database"); |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
728 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
729 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
730 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
731 * Touches the access timestamp of a given artifact to prevent |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
732 * that it will be removed from the database by the database cleaner. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
733 * @param artifact The persistent wrapper around the living artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
734 */ |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
735 public void touch(PersistentArtifact artifact) { |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
736 |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
737 try { |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
738 Connection connection = null; |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
739 PreparedStatement stmnt_touch = null; |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
740 DataSource dataSource = DBConnection.getDataSource(); |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
741 try { |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
742 connection = dataSource.getConnection(); |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
743 try { |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
744 connection.setAutoCommit(false); |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
745 stmnt_touch = connection.prepareStatement(SQL_TOUCH); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
746 stmnt_touch.setInt(1, artifact.getId()); |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
747 stmnt_touch.execute(); |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
748 connection.commit(); |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
749 } |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
750 catch (SQLException sqle) { |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
751 connection.rollback(); |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
752 } |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
753 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
754 catch (SQLException sqle) { |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
755 logger.error(sqle.getLocalizedMessage(), sqle); |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
756 } |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
757 finally { |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
758 if (stmnt_touch != null) { |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
759 try { stmnt_touch.close(); } |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
760 catch (SQLException sqle) {} |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
761 } |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
762 if (connection != null) { |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
763 try { connection.close(); } |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
764 catch (SQLException sqle) {} |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
765 } |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
766 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
767 } |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
768 catch (Exception e) { |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
769 logger.error(e.getLocalizedMessage(), e); |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
770 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
771 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
772 |
90
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
773 /** |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
774 * Writes modification of an artifact back to the database. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
775 * @param artifact The persistent wrapper around a living |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
776 * artifact. |
68285f7bc476
More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
86
diff
changeset
|
777 */ |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
778 public void store(PersistentArtifact artifact) { |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
779 |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
780 try { |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
781 Connection connection = null; |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
782 PreparedStatement stmnt_update = null; |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
783 DataSource dataSource = DBConnection.getDataSource(); |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
784 try { |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
785 connection = dataSource.getConnection(); |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
786 try { |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
787 connection.setAutoCommit(false); |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
788 stmnt_update = connection.prepareStatement(SQL_UPDATE); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
31
diff
changeset
|
789 stmnt_update.setInt(2, artifact.getId()); |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
790 |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
791 byte [] bytes = artifact |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
792 .getSerializer() |
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
38
diff
changeset
|
793 .toBytes(artifact.getArtifact()); |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
794 |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
795 stmnt_update.setBytes(1, bytes); |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
796 stmnt_update.execute(); |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
797 connection.commit(); |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
798 } |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
799 catch (SQLException sqle) { |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
800 connection.rollback(); |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
801 } |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
802 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
803 catch (SQLException sqle) { |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
804 logger.error(sqle.getLocalizedMessage(), sqle); |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
805 } |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
806 finally { |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
807 if (stmnt_update != null) { |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
808 try { stmnt_update.close(); } |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
809 catch (SQLException sqle) {} |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
810 } |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
811 if (connection != null) { |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
812 try { connection.close(); } |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
813 catch (SQLException sqle) {} |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
814 } |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
815 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
816 } |
26
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
817 catch (Exception e) { |
83a059c204f8
Connected /create with artifact db.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
818 logger.error(e.getLocalizedMessage(), e); |
14
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
819 } |
0d16d1bb2df0
Initial checkin of artigact persistents back by database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
820 } |
133
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
821 |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
822 public User createUser( |
157
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
823 String name, |
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
824 Document role, |
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
825 UserFactory factory, |
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
826 Object context |
133
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
827 ) { |
138
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
828 Connection connection = null; |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
829 PreparedStatement stmnt_next_id = null; |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
830 PreparedStatement stmnt_insert = null; |
145
c0d025df722d
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
144
diff
changeset
|
831 ResultSet result = null; |
138
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
832 |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
833 String identifier = newIdentifier(); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
834 |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
835 DataSource dataSource = DBConnection.getDataSource(); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
836 try { |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
837 connection = dataSource.getConnection(); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
838 try { |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
839 connection.setAutoCommit(false); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
840 |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
841 stmnt_next_id = connection.prepareStatement(SQL_USERS_NEXT_ID); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
842 stmnt_insert = connection.prepareStatement(SQL_USERS_INSERT); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
843 |
145
c0d025df722d
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
144
diff
changeset
|
844 result = stmnt_next_id.executeQuery(); |
138
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
845 |
146
967dc552455d
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
145
diff
changeset
|
846 if (!result.next()) { |
138
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
847 throw new RuntimeException("No id generated"); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
848 } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
849 |
145
c0d025df722d
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
144
diff
changeset
|
850 int id = result.getInt(1); |
138
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
851 |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
852 stmnt_insert.setInt(1, id); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
853 stmnt_insert.setString(2, identifier); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
854 stmnt_insert.setString(3, name); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
855 |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
856 byte [] roleData = role == null |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
857 ? null |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
858 : XMLUtils.toByteArray(role); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
859 |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
860 if (roleData == null) { |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
861 stmnt_insert.setNull(4, Types.BIGINT); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
862 } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
863 else { |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
864 stmnt_insert.setBytes(4, roleData); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
865 } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
866 |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
867 stmnt_insert.execute(); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
868 |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
869 connection.commit(); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
870 |
157
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
871 return factory.createUser(identifier, name, role, context); |
138
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
872 } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
873 catch (SQLException sqle) { |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
874 connection.rollback(); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
875 throw sqle; |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
876 } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
877 } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
878 catch (SQLException sqle) { |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
879 logger.error(sqle.getLocalizedMessage(), sqle); |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
880 } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
881 finally { |
145
c0d025df722d
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
144
diff
changeset
|
882 if (result != null) { |
c0d025df722d
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
144
diff
changeset
|
883 try { result.close(); } |
138
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
884 catch (SQLException sqle) {} |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
885 } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
886 if (stmnt_insert != null) { |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
887 try { stmnt_insert.close(); } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
888 catch (SQLException sqle) {} |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
889 } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
890 if (stmnt_next_id != null) { |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
891 try { stmnt_next_id.close(); } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
892 catch (SQLException sqle) {} |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
893 } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
894 if (connection != null) { |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
895 try { connection.close(); } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
896 catch (SQLException sqle) {} |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
897 } |
b90e831d3dfe
Call database to create a new user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
133
diff
changeset
|
898 } |
133
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
899 return null; |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
900 } |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
901 |
154
1a72f08ce8d7
Propagate delete user errors correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
153
diff
changeset
|
902 public boolean deleteUser(String identifier) { |
144
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
903 |
147
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
904 Connection conn = null; |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
905 ResultSet result = null; |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
906 PreparedStatement stmnt = null; |
144
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
907 |
147
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
908 if (!StringUtils.checkUUID(identifier)) { |
154
1a72f08ce8d7
Propagate delete user errors correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
153
diff
changeset
|
909 return false; |
147
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
910 } |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
911 |
144
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
912 DataSource dataSource = DBConnection.getDataSource(); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
913 try { |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
914 conn = dataSource.getConnection(); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
915 try { |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
916 conn.setAutoCommit(false); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
917 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
918 // fetch user id |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
919 stmnt = conn.prepareStatement(SQL_USERS_SELECT_ID_BY_GID); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
920 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
921 stmnt.setString(1, identifier); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
922 result = stmnt.executeQuery(); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
923 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
924 if (!result.next()) { // No such user |
154
1a72f08ce8d7
Propagate delete user errors correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
153
diff
changeset
|
925 return false; |
144
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
926 } |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
927 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
928 int id = result.getInt(1); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
929 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
930 result.close(); result = null; |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
931 stmnt.close(); stmnt = null; |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
932 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
933 // outdate the artifacts exclusively used by the user |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
934 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
935 stmnt = conn.prepareStatement(SQL_OUTDATE_ARTIFACTS_USER); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
936 stmnt.setInt(1, id); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
937 stmnt.setInt(2, id); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
938 stmnt.execute(); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
939 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
940 stmnt.close(); stmnt = null; |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
941 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
942 // delete the collection items of the user |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
943 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
944 stmnt = conn.prepareStatement(SQL_DELETE_USER_COLLECTION_ITEMS); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
945 stmnt.setInt(1, id); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
946 stmnt.execute(); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
947 stmnt.close(); stmnt = null; |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
948 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
949 // delete the collections of the user |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
950 |
151
3d70de111af1
Bugfix: Replaced wrong SQL statements with the correct ones.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
148
diff
changeset
|
951 stmnt = conn.prepareStatement(SQL_USERS_DELETE_COLLECTIONS); |
144
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
952 stmnt.setInt(1, id); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
953 stmnt.execute(); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
954 stmnt.close(); stmnt = null; |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
955 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
956 // delete the user |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
957 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
958 stmnt = conn.prepareStatement(SQL_USERS_DELETE_ID); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
959 stmnt.setInt(1, id); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
960 stmnt.execute(); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
961 |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
962 conn.commit(); |
154
1a72f08ce8d7
Propagate delete user errors correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
153
diff
changeset
|
963 |
1a72f08ce8d7
Propagate delete user errors correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
153
diff
changeset
|
964 return true; |
144
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
965 } |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
966 catch (SQLException sqle) { |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
967 conn.rollback(); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
968 throw sqle; |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
969 } |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
970 } |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
971 catch (SQLException sqle) { |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
972 logger.error(sqle.getLocalizedMessage(), sqle); |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
973 } |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
974 finally { |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
975 if (result != null) { |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
976 try { result.close(); } |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
977 catch (SQLException sqle) {} |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
978 } |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
979 if (stmnt != null) { |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
980 try { stmnt.close(); } |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
981 catch (SQLException sqle) {} |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
982 } |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
983 if (conn != null) { |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
984 try { conn.close(); } |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
985 catch (SQLException sqle) {} |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
986 } |
5369582d4fbf
Enable backend to delete users
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
138
diff
changeset
|
987 } |
154
1a72f08ce8d7
Propagate delete user errors correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
153
diff
changeset
|
988 |
1a72f08ce8d7
Propagate delete user errors correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
153
diff
changeset
|
989 return false; |
133
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
990 } |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
991 |
157
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
992 public User getUser( |
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
993 String identifier, |
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
994 UserFactory factory, |
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
995 Object context |
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
996 ) { |
147
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
997 Connection conn = null; |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
998 ResultSet result = null; |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
999 PreparedStatement stmnt = null; |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1000 |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1001 if (!StringUtils.checkUUID(identifier)) { |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1002 logger.debug("Invalid UUID: '" + identifier + "'"); |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1003 return null; |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1004 } |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1005 |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1006 DataSource dataSource = DBConnection.getDataSource(); |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1007 try { |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1008 conn = dataSource.getConnection(); |
151
3d70de111af1
Bugfix: Replaced wrong SQL statements with the correct ones.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
148
diff
changeset
|
1009 stmnt = conn.prepareStatement(SQL_USERS_SELECT_GID); |
147
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1010 stmnt.setString(1, identifier); |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1011 result = stmnt.executeQuery(); |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1012 if (!result.next()) { // no such user |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1013 return null; |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1014 } |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1015 // omit id |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1016 String name = result.getString(2); |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1017 byte [] roleData = result.getBytes(3); |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1018 |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1019 Document role = XMLUtils.fromByteArray(roleData); |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1020 |
157
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
1021 return factory.createUser(identifier, name, role, context); |
147
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1022 } |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1023 catch (SQLException sqle) { |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1024 logger.error(sqle.getLocalizedMessage(), sqle); |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1025 } |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1026 finally { |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1027 if (result != null) { |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1028 try { result.close(); } |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1029 catch (SQLException sqle) {} |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1030 } |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1031 if (stmnt != null) { |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1032 try { stmnt.close(); } |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1033 catch (SQLException sqle) {} |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1034 } |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1035 if (conn != null) { |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1036 try { conn.close(); } |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1037 catch (SQLException sqle) {} |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1038 } |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1039 } |
9a64e0c1c737
Added code to load user from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
146
diff
changeset
|
1040 |
133
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
1041 return null; |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
1042 } |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
1043 |
157
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
1044 public User [] getUsers(UserFactory factory, Object context) { |
148
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1045 Connection conn = null; |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1046 ResultSet result = null; |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1047 PreparedStatement stmnt = null; |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1048 |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1049 DataSource dataSource = DBConnection.getDataSource(); |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1050 try { |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1051 conn = dataSource.getConnection(); |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1052 stmnt = conn.prepareStatement(SQL_USERS_SELECT_ALL); |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1053 result = stmnt.executeQuery(); |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1054 |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1055 ArrayList<User> users = new ArrayList<User>(); |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1056 |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1057 while (result.next()) { |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1058 // omit id |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1059 String identifier = result.getString(2); |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1060 String name = result.getString(3); |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1061 byte [] roleData = result.getBytes(4); |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1062 |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1063 Document role = XMLUtils.fromByteArray(roleData); |
157
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
1064 User user = |
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
1065 factory.createUser(identifier, name, role, context); |
148
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1066 users.add(user); |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1067 } |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1068 |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1069 return users.toArray(new User[users.size()]); |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1070 } |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1071 catch (SQLException sqle) { |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1072 logger.error(sqle.getLocalizedMessage(), sqle); |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1073 } |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1074 finally { |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1075 if (result != null) { |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1076 try { result.close(); } |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1077 catch (SQLException sqle) {} |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1078 } |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1079 if (stmnt != null) { |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1080 try { stmnt.close(); } |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1081 catch (SQLException sqle) {} |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1082 } |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1083 if (conn != null) { |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1084 try { conn.close(); } |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1085 catch (SQLException sqle) {} |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1086 } |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1087 } |
101a52d3ad08
Added code to load all users from database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
147
diff
changeset
|
1088 |
133
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
1089 return null; |
2950c6011afa
Fixed typo in keys.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
128
diff
changeset
|
1090 } |
156
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1091 |
157
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
1092 public ArtifactCollection [] listCollections(String userId) { |
156
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1093 // TODO: Implement me! |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1094 return null; |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1095 } |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1096 |
157
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
1097 public ArtifactCollection createCollection(String ownerId, Document data) { |
156
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1098 // TODO: Implement me! |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1099 return null; |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1100 } |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1101 |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1102 public boolean deleteCollection(String collectionId) { |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1103 // TODO: Implement me! |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1104 return false; |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1105 } |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1106 |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1107 public Document getCollectionAttribute( |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1108 String collectionId, |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1109 String artifactId |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1110 ) { |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1111 // TODO: Implement me! |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1112 return null; |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1113 } |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1114 |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1115 public boolean setCollectionAttribute( |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1116 String collectionId, |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1117 String artifactId, |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1118 Document attribute |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1119 ) { |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1120 // TODO: Implement me! |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1121 return false; |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1122 } |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1123 |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1124 public boolean addCollectionArtifact( |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1125 String collectionId, |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1126 String artifactId |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1127 ) { |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1128 // TODO: Implement me! |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1129 return false; |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1130 } |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1131 |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1132 public boolean removeCollectionArtifact( |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1133 String collectionId, |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1134 String artifactId |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1135 ) { |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1136 // TODO: Implement me! |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1137 return false; |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1138 } |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1139 |
157
6e6965873a48
Simplified creation of users.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
156
diff
changeset
|
1140 public ArtifactCollection [] listCollectionArtifacts(String collectionId) { |
156
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1141 // TODO: Implement me! |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1142 return null; |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1143 } |
a76de72ad6d1
Added stubs for the collection handling in db backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
154
diff
changeset
|
1144 |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1145 } |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
47
diff
changeset
|
1146 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |