Skip to content
This repository was archived by the owner on Apr 22, 2022. It is now read-only.

Commit 0239c48

Browse files
author
jj
committed
Merge branch 'master' of [email protected]:ontos-lds.git
Conflicts: src/main/webapp/css/app.css src/main/webapp/js/workbench/extraction-and-loading/d2rq-mapping-controller.js src/main/webapp/js/workbench/extraction-and-loading/d2rq-task-controller.js src/main/webapp/js/workbench/manual-revision-and-authoring/ontology-controller.js
2 parents 3985bb3 + 490a6b4 commit 0239c48

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2316
-486
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#Framework configuration files
22
/src/main/webapp/WEB-INF/web.xml
33
/src/main/resources/framework-configuration.ttl
4+
/src/main/resources/framework-components-local.ttl
45

56
#Mac
67
.DS_Store
@@ -18,3 +19,4 @@
1819
/src/main/webapp/VAADIN/gwt-unitCache
1920
/src/main/webapp/VAADIN/widgetsets
2021
/target
22+
/bin

src/main/java/ExecuteD2RQTaskServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class ExecuteD2RQTaskServlet extends HttpServlet {
2424
public void init(ServletConfig config) throws ServletException {
2525
super.init(config);
2626
try {
27-
frameworkUserManager = FrameworkConfiguration.getInstance(getServletContext(), false).getFrameworkUserManager();
27+
frameworkUserManager = FrameworkConfiguration.getInstance(getServletContext()).getFrameworkUserManager();
2828
} catch (Exception e) {
2929
throw new ServletException(e);
3030
}

src/main/java/ImportRDF.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private int httpUpdate(String endpoint, String graph, Model model) throws Except
146146
RdfStoreManager rdfStoreManager = null;
147147
if (username != null && !username.isEmpty() && token != null && !token.isEmpty()) {
148148
FrameworkUserManager frameworkUserManager = FrameworkConfiguration.getInstance(
149-
getServletContext(), false).getFrameworkUserManager();
149+
getServletContext()).getFrameworkUserManager();
150150
if (frameworkUserManager.checkToken(username, token))
151151
rdfStoreManager = frameworkUserManager.getRdfStoreManager(username);
152152
}

src/main/java/accounts/FrameworkUserManager.java

Lines changed: 131 additions & 71 deletions
Large diffs are not rendered by default.

src/main/java/accounts/UserManager.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ public interface UserManager {
88
public void setRdfGraphPermissions(String user, String graph, int permissions) throws Exception;
99
public void deleteRdfGraphPermissions(String user, String graph) throws Exception;
1010
public void setDefaultGraphPermissions(String graph, int permissions) throws Exception;
11+
public boolean checkUserExists(String username, String email) throws Exception;
1112
}

src/main/java/accounts/UserProfile.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public class UserProfile {
55
private String settingsGraph;
66
private String accountURI;
77
private String email;
8-
private boolean admin;
8+
private UserRole role;
99

1010
public String getUsername() {
1111
return username;
@@ -39,12 +39,12 @@ public void setEmail(String email) {
3939
this.email = email;
4040
}
4141

42-
public boolean isAdmin() {
43-
return admin;
42+
public UserRole getRole() {
43+
return role;
4444
}
4545

46-
public void setAdmin(boolean admin) {
47-
this.admin = admin;
46+
public void setRole(UserRole role) {
47+
this.role = role;
4848
}
4949

5050
@Override
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package accounts;
2+
3+
import java.util.Collection;
4+
5+
/**
6+
* Created by taleksaschina on 24.06.2014.
7+
*/
8+
public class UserRole {
9+
private String uri;
10+
private String name;
11+
private Collection<String> services;
12+
13+
public String getUri() {
14+
return uri;
15+
}
16+
17+
public void setUri(String uri) {
18+
this.uri = uri;
19+
}
20+
21+
public String getName() {
22+
return name;
23+
}
24+
25+
public void setName(String name) {
26+
this.name = name;
27+
}
28+
29+
public Collection<String> getServices() {
30+
return services;
31+
}
32+
33+
public void setServices(Collection<String> services) {
34+
this.services = services;
35+
}
36+
}

src/main/java/accounts/VirtuosoUserManager.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package accounts;
22

3-
import java.sql.Connection;
4-
import java.sql.DriverManager;
5-
import java.sql.SQLException;
6-
import java.sql.Statement;
3+
import java.sql.*;
74

85
public class VirtuosoUserManager implements UserManager {
96
private static final String jdbcDriver = "virtuoso.jdbc4.Driver";
@@ -29,8 +26,10 @@ public VirtuosoUserManager(String connectionString, String user, String password
2926
}
3027

3128
@Override
32-
public void createUser(String name, String password) throws ClassNotFoundException, SQLException {
33-
executeUpdate(getConnection(), "DB.DBA.USER_CREATE('" + name + "', '" + password + "')");
29+
public void createUser(String name, String password) throws Exception {
30+
if (checkUserExists(name, null))
31+
throw new Exception("User " + name + " already exists");
32+
executeUpdate(getConnection(), "DB.DBA.USER_CREATE('" + name + "', '" + password + "')"); //NB! this function doesn't throw exception if user already exists
3433
// executeUpdate(getConnection(), "USER_SET_OPTION('" + name +
3534
// "', 'DAV_ENABLE', 1)");
3635
}
@@ -42,7 +41,7 @@ public void dropUser(String name) throws ClassNotFoundException, SQLException {
4241

4342
@Override
4443
public void grantRole(String user, String role) throws ClassNotFoundException, SQLException {
45-
executeUpdate(getConnection(), "GRANT " + role + " TO \"" + user + "\"");
44+
executeUpdate(getConnection(), "GRANT " + role + " TO \"" + user + "\""); //NB! this function throws exception if the role is already granted
4645
}
4746

4847
@Override
@@ -82,9 +81,23 @@ public void setDefaultGraphPermissions(String graph, int permissions)
8281
* @throws SQLException
8382
*/
8483
public void grantLOLook(String user) throws ClassNotFoundException, SQLException {
85-
executeUpdate(getConnection(), "GRANT EXECUTE ON DB.DBA.L_O_LOOK TO '" + user + "'");
84+
executeUpdate(getConnection(), "GRANT EXECUTE ON DB.DBA.L_O_LOOK TO \"" + user + "\"");
8685
}
8786

87+
@Override
88+
public boolean checkUserExists(String username, String email) throws Exception {
89+
//todo is there any simpler way to check if the user exists? some function?
90+
String query = "select * from DB.DBA.SYS_USERS where U_NAME='" + username + "'";
91+
Connection conn = getConnection();
92+
Statement stmt = conn.createStatement();
93+
try {
94+
ResultSet resultSet = stmt.executeQuery(query);
95+
return resultSet.next();
96+
} finally {
97+
stmt.close();
98+
}
99+
}
100+
88101
private Connection getConnection() throws ClassNotFoundException, SQLException {
89102
if (connection == null || connection.isClosed()) {
90103
Class.forName(jdbcDriver);

0 commit comments

Comments
 (0)