Loading TapSchemaManager/pom.xml +5 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,11 @@ <type>jar</type> <scope>runtime</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.21</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> Loading TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/businesslayer/TapSchema.java +2 −2 Original line number Diff line number Diff line Loading @@ -26,11 +26,11 @@ public class TapSchema implements EntityWrapperContainer<Schema>, Serializable { private String selectedSchema; private final Map<String, Schema> schemas; public TapSchema(Credentials credentials, String tapSchemaName, boolean exists) throws SQLException { public TapSchema(Credentials sourceCredentials, Credentials tapSchemaCredentials, String tapSchemaName, boolean exists) throws SQLException { this.name = tapSchemaName; schemas = new TreeMap<String, Schema>(String.CASE_INSENSITIVE_ORDER); this.tapSchemaHandler = new TapSchemaHandler(credentials, tapSchemaName, exists); this.tapSchemaHandler = new TapSchemaHandler(sourceCredentials, tapSchemaCredentials, tapSchemaName, exists); if (exists) { for (SchemaEntity schemaEntity : tapSchemaHandler.getSchemas()) { Loading TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/CredentialsBean.java +51 −37 Original line number Diff line number Diff line Loading @@ -6,19 +6,21 @@ import java.sql.Connection; import java.sql.SQLException; import javax.annotation.PostConstruct; import javax.enterprise.context.Conversation; import javax.enterprise.context.RequestScoped; import javax.faces.view.ViewScoped; import javax.inject.Inject; import javax.inject.Named; import org.apache.log4j.Logger; /** * * @author Sonia Zorba <zorba at oats.inaf.it> */ @Named("credentialsInsertion") @RequestScoped @ViewScoped public class CredentialsBean implements Serializable { private static final long serialVersionUID = -2688980249773483198L; private static final Logger log = Logger.getLogger(CredentialsBean.class); @Inject Conversation conversation; Loading @@ -28,65 +30,77 @@ public class CredentialsBean implements Serializable { private String loginError; private Credentials credentials; private Credentials sourceCredentials; private Credentials tapSchemaCredentials; private boolean separateCredentials; @PostConstruct public void init() { log.debug("CredentialsBean created"); if (!conversation.isTransient()) { conversation.end(); } credentials = new Credentials(); sourceCredentials = new Credentials(); tapSchemaCredentials = new Credentials(); } public String getHostname() { return credentials.getHostname(); public String getLoginError() { return loginError; } public void setHostname(String hostname) { credentials.setHostname(hostname); } public String login() { System.out.println("login called"); log.info("login called"); public int getPort() { return credentials.getPort(); } loginError = null; public void setPort(int port) { credentials.setPort(port); if (!separateCredentials) { tapSchemaCredentials.setHostname(sourceCredentials.getHostname()); tapSchemaCredentials.setPort(sourceCredentials.getPort()); tapSchemaCredentials.setUsername(sourceCredentials.getUsername()); tapSchemaCredentials.setPassword(sourceCredentials.getPassword()); } public String getUsername() { return credentials.getUsername(); try { Connection connection = sourceCredentials.getConnection(); connection.close(); connection = tapSchemaCredentials.getConnection(); connection.close(); conversation.setTimeout(30 * 60000L); // 30 minutes conversation.begin(); schemaSelectionBean.setSourceCredentials(sourceCredentials); schemaSelectionBean.setTapSchemaCredentials(tapSchemaCredentials); return "schemaSelection.xhtml?faces-redirect=true"; } catch (SQLException e) { log.error("Exception caught", e); loginError = "Connection error: " + e.getMessage(); return null; } } public void setUsername(String username) { credentials.setUsername(username); public boolean isSeparateCredentials() { return separateCredentials; } public String getPassword() { return credentials.getPassword(); public void setSeparateCredentials(boolean separateCredentials) { this.separateCredentials = separateCredentials; } public void setPassword(String password) { credentials.setPassword(password); public Credentials getSourceCredentials() { return sourceCredentials; } public String getLoginError() { return loginError; public void setSourceCredentials(Credentials sourceCredentials) { this.sourceCredentials = sourceCredentials; } public String login() { loginError = null; try { Connection connection = credentials.getConnection(); connection.close(); conversation.setTimeout(30 * 60000L); // 30 minutes conversation.begin(); schemaSelectionBean.setCredentials(credentials); return "schemaSelection.xhtml?faces-redirect=true"; } catch (SQLException e) { loginError = "Connection error: " + e.getMessage(); return "index.xhtml?faces-redirect=true"; public Credentials getTapSchemaCredentials() { return tapSchemaCredentials; } public void setTapSchemaCredentials(Credentials tapSchemaCredentials) { this.tapSchemaCredentials = tapSchemaCredentials; } } TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/SchemaSelectionBean.java +49 −19 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ import javax.faces.context.FacesContext; import javax.faces.validator.ValidatorException; import javax.inject.Inject; import javax.inject.Named; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Loading @@ -27,6 +29,7 @@ import javax.inject.Named; public class SchemaSelectionBean implements Serializable { private static final long serialVersionUID = -5745720427701334323L; private static final Logger log = LoggerFactory.getLogger(SchemaSelectionBean.class); @Inject private Conversation conversation; Loading @@ -34,7 +37,8 @@ public class SchemaSelectionBean implements Serializable { @Inject TapSchemaEditingBean tapSchemaEditingBean; private Credentials credentials; private Credentials sourceCredentials; private Credentials tapSchemaCredentials; private String selectedRadioOption; Loading @@ -60,35 +64,53 @@ public class SchemaSelectionBean implements Serializable { final boolean validationFailed = fc.isValidationFailed(); if (!ajaxRequest && !validationFailed) { Connection connection = null; try { connection = credentials.getConnection(); allSchemas = DataProvider.getAllSchemasNames(connection); // Loading all schemas of the source database Connection sourceConnection = null; try { sourceConnection = sourceCredentials.getConnection(); allSchemas = DataProvider.getAllSchemasNames(sourceConnection); setSelectedSchemas(new ArrayList<String>()); } catch (SQLException e) { throw new RuntimeException(e); } finally { try { if (sourceConnection != null) { sourceConnection.close(); } } catch (SQLException e) { log.error("Exception caught", e); } } allTAPSchemas = DataProvider.getAllTAPSchemasNames(connection, allSchemas); // Loading all schemas of the TAP_SCHEMA database Connection tapSchemaConnection = null; try { tapSchemaConnection = tapSchemaCredentials.getConnection(); allTAPSchemas = DataProvider.getAllTAPSchemasNames( tapSchemaConnection, DataProvider.getAllSchemasNames(tapSchemaConnection)); if (!allTAPSchemas.isEmpty()) { this.selectedTAPSchema = allTAPSchemas.get(0); loadExposedSchemas(connection); loadExposedSchemas(tapSchemaConnection); } } catch (SQLException e) { throw new RuntimeException(e); } finally { try { if (connection != null) { connection.close(); if (tapSchemaConnection != null) { tapSchemaConnection.close(); } } catch (SQLException e) { throw new RuntimeException(e); log.error("Exception caught", e); } } } } public void loadExposedSchemas(Connection connection) throws SQLException { List<String> schemas = DataProvider.getExposedSchemas(connection, selectedTAPSchema); private void loadExposedSchemas(Connection tapSchemaConnection) throws SQLException { List<String> schemas = DataProvider.getExposedSchemas(tapSchemaConnection, selectedTAPSchema); exposedSchemas = ""; for (int i = 0; i < schemas.size(); i++) { exposedSchemas += schemas.get(i); Loading Loading @@ -127,7 +149,7 @@ public class SchemaSelectionBean implements Serializable { Connection connection = null; try { connection = credentials.getConnection(); connection = tapSchemaCredentials.getConnection(); loadExposedSchemas(connection); } catch (SQLException e) { throw new RuntimeException(e); Loading Loading @@ -157,7 +179,7 @@ public class SchemaSelectionBean implements Serializable { public String edit() { try { return loadTapSchema(new TapSchema(credentials, selectedTAPSchema, true)); return loadTapSchema(new TapSchema(sourceCredentials, tapSchemaCredentials, selectedTAPSchema, true)); } catch (SQLException e) { throw new RuntimeException(e); } Loading @@ -165,7 +187,7 @@ public class SchemaSelectionBean implements Serializable { public String create() { try { TapSchema tapSchema = new TapSchema(credentials, tapSchemaName, false); TapSchema tapSchema = new TapSchema(sourceCredentials, tapSchemaCredentials, tapSchemaName, false); for (String selectedSchema : selectedSchemas) { tapSchema.addEntityWrapper(selectedSchema); } Loading @@ -183,12 +205,20 @@ public class SchemaSelectionBean implements Serializable { this.tapSchemaName = tapSchemaName; } public Credentials getCredentials() { return credentials; public Credentials getSourceCredentials() { return sourceCredentials; } public void setSourceCredentials(Credentials sourceCredentials) { this.sourceCredentials = sourceCredentials; } public Credentials getTapSchemaCredentials() { return tapSchemaCredentials; } public void setCredentials(Credentials credentials) { this.credentials = credentials; public void setTapSchemaCredentials(Credentials tapSchemaCredentials) { this.tapSchemaCredentials = tapSchemaCredentials; } public String logout() { Loading TapSchemaManager/src/main/resources/log4j.properties 0 → 100644 +16 −0 Original line number Diff line number Diff line # Default Appender log4j.appender.AD=org.apache.log4j.ConsoleAppender log4j.appender.AD.layout=org.apache.log4j.PatternLayout log4j.appender.AD.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n # IA2 Appender log4j.appender.IA2=org.apache.log4j.ConsoleAppender log4j.appender.IA2.layout=org.apache.log4j.PatternLayout log4j.appender.IA2.layout.ConversionPattern=[%c{1}]: %m%n # Root Logger log4j.rootLogger=WARN,AD # IA2 Logger log4j.logger.it.inaf.oats.ia2=TRACE,IA2 log4j.additivity.it.inaf.oats.ia2=false Loading
TapSchemaManager/pom.xml +5 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,11 @@ <type>jar</type> <scope>runtime</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.21</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> Loading
TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/businesslayer/TapSchema.java +2 −2 Original line number Diff line number Diff line Loading @@ -26,11 +26,11 @@ public class TapSchema implements EntityWrapperContainer<Schema>, Serializable { private String selectedSchema; private final Map<String, Schema> schemas; public TapSchema(Credentials credentials, String tapSchemaName, boolean exists) throws SQLException { public TapSchema(Credentials sourceCredentials, Credentials tapSchemaCredentials, String tapSchemaName, boolean exists) throws SQLException { this.name = tapSchemaName; schemas = new TreeMap<String, Schema>(String.CASE_INSENSITIVE_ORDER); this.tapSchemaHandler = new TapSchemaHandler(credentials, tapSchemaName, exists); this.tapSchemaHandler = new TapSchemaHandler(sourceCredentials, tapSchemaCredentials, tapSchemaName, exists); if (exists) { for (SchemaEntity schemaEntity : tapSchemaHandler.getSchemas()) { Loading
TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/CredentialsBean.java +51 −37 Original line number Diff line number Diff line Loading @@ -6,19 +6,21 @@ import java.sql.Connection; import java.sql.SQLException; import javax.annotation.PostConstruct; import javax.enterprise.context.Conversation; import javax.enterprise.context.RequestScoped; import javax.faces.view.ViewScoped; import javax.inject.Inject; import javax.inject.Named; import org.apache.log4j.Logger; /** * * @author Sonia Zorba <zorba at oats.inaf.it> */ @Named("credentialsInsertion") @RequestScoped @ViewScoped public class CredentialsBean implements Serializable { private static final long serialVersionUID = -2688980249773483198L; private static final Logger log = Logger.getLogger(CredentialsBean.class); @Inject Conversation conversation; Loading @@ -28,65 +30,77 @@ public class CredentialsBean implements Serializable { private String loginError; private Credentials credentials; private Credentials sourceCredentials; private Credentials tapSchemaCredentials; private boolean separateCredentials; @PostConstruct public void init() { log.debug("CredentialsBean created"); if (!conversation.isTransient()) { conversation.end(); } credentials = new Credentials(); sourceCredentials = new Credentials(); tapSchemaCredentials = new Credentials(); } public String getHostname() { return credentials.getHostname(); public String getLoginError() { return loginError; } public void setHostname(String hostname) { credentials.setHostname(hostname); } public String login() { System.out.println("login called"); log.info("login called"); public int getPort() { return credentials.getPort(); } loginError = null; public void setPort(int port) { credentials.setPort(port); if (!separateCredentials) { tapSchemaCredentials.setHostname(sourceCredentials.getHostname()); tapSchemaCredentials.setPort(sourceCredentials.getPort()); tapSchemaCredentials.setUsername(sourceCredentials.getUsername()); tapSchemaCredentials.setPassword(sourceCredentials.getPassword()); } public String getUsername() { return credentials.getUsername(); try { Connection connection = sourceCredentials.getConnection(); connection.close(); connection = tapSchemaCredentials.getConnection(); connection.close(); conversation.setTimeout(30 * 60000L); // 30 minutes conversation.begin(); schemaSelectionBean.setSourceCredentials(sourceCredentials); schemaSelectionBean.setTapSchemaCredentials(tapSchemaCredentials); return "schemaSelection.xhtml?faces-redirect=true"; } catch (SQLException e) { log.error("Exception caught", e); loginError = "Connection error: " + e.getMessage(); return null; } } public void setUsername(String username) { credentials.setUsername(username); public boolean isSeparateCredentials() { return separateCredentials; } public String getPassword() { return credentials.getPassword(); public void setSeparateCredentials(boolean separateCredentials) { this.separateCredentials = separateCredentials; } public void setPassword(String password) { credentials.setPassword(password); public Credentials getSourceCredentials() { return sourceCredentials; } public String getLoginError() { return loginError; public void setSourceCredentials(Credentials sourceCredentials) { this.sourceCredentials = sourceCredentials; } public String login() { loginError = null; try { Connection connection = credentials.getConnection(); connection.close(); conversation.setTimeout(30 * 60000L); // 30 minutes conversation.begin(); schemaSelectionBean.setCredentials(credentials); return "schemaSelection.xhtml?faces-redirect=true"; } catch (SQLException e) { loginError = "Connection error: " + e.getMessage(); return "index.xhtml?faces-redirect=true"; public Credentials getTapSchemaCredentials() { return tapSchemaCredentials; } public void setTapSchemaCredentials(Credentials tapSchemaCredentials) { this.tapSchemaCredentials = tapSchemaCredentials; } }
TapSchemaManager/src/main/java/it/inaf/oats/ia2/tapschemamanager/webapp/SchemaSelectionBean.java +49 −19 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ import javax.faces.context.FacesContext; import javax.faces.validator.ValidatorException; import javax.inject.Inject; import javax.inject.Named; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Loading @@ -27,6 +29,7 @@ import javax.inject.Named; public class SchemaSelectionBean implements Serializable { private static final long serialVersionUID = -5745720427701334323L; private static final Logger log = LoggerFactory.getLogger(SchemaSelectionBean.class); @Inject private Conversation conversation; Loading @@ -34,7 +37,8 @@ public class SchemaSelectionBean implements Serializable { @Inject TapSchemaEditingBean tapSchemaEditingBean; private Credentials credentials; private Credentials sourceCredentials; private Credentials tapSchemaCredentials; private String selectedRadioOption; Loading @@ -60,35 +64,53 @@ public class SchemaSelectionBean implements Serializable { final boolean validationFailed = fc.isValidationFailed(); if (!ajaxRequest && !validationFailed) { Connection connection = null; try { connection = credentials.getConnection(); allSchemas = DataProvider.getAllSchemasNames(connection); // Loading all schemas of the source database Connection sourceConnection = null; try { sourceConnection = sourceCredentials.getConnection(); allSchemas = DataProvider.getAllSchemasNames(sourceConnection); setSelectedSchemas(new ArrayList<String>()); } catch (SQLException e) { throw new RuntimeException(e); } finally { try { if (sourceConnection != null) { sourceConnection.close(); } } catch (SQLException e) { log.error("Exception caught", e); } } allTAPSchemas = DataProvider.getAllTAPSchemasNames(connection, allSchemas); // Loading all schemas of the TAP_SCHEMA database Connection tapSchemaConnection = null; try { tapSchemaConnection = tapSchemaCredentials.getConnection(); allTAPSchemas = DataProvider.getAllTAPSchemasNames( tapSchemaConnection, DataProvider.getAllSchemasNames(tapSchemaConnection)); if (!allTAPSchemas.isEmpty()) { this.selectedTAPSchema = allTAPSchemas.get(0); loadExposedSchemas(connection); loadExposedSchemas(tapSchemaConnection); } } catch (SQLException e) { throw new RuntimeException(e); } finally { try { if (connection != null) { connection.close(); if (tapSchemaConnection != null) { tapSchemaConnection.close(); } } catch (SQLException e) { throw new RuntimeException(e); log.error("Exception caught", e); } } } } public void loadExposedSchemas(Connection connection) throws SQLException { List<String> schemas = DataProvider.getExposedSchemas(connection, selectedTAPSchema); private void loadExposedSchemas(Connection tapSchemaConnection) throws SQLException { List<String> schemas = DataProvider.getExposedSchemas(tapSchemaConnection, selectedTAPSchema); exposedSchemas = ""; for (int i = 0; i < schemas.size(); i++) { exposedSchemas += schemas.get(i); Loading Loading @@ -127,7 +149,7 @@ public class SchemaSelectionBean implements Serializable { Connection connection = null; try { connection = credentials.getConnection(); connection = tapSchemaCredentials.getConnection(); loadExposedSchemas(connection); } catch (SQLException e) { throw new RuntimeException(e); Loading Loading @@ -157,7 +179,7 @@ public class SchemaSelectionBean implements Serializable { public String edit() { try { return loadTapSchema(new TapSchema(credentials, selectedTAPSchema, true)); return loadTapSchema(new TapSchema(sourceCredentials, tapSchemaCredentials, selectedTAPSchema, true)); } catch (SQLException e) { throw new RuntimeException(e); } Loading @@ -165,7 +187,7 @@ public class SchemaSelectionBean implements Serializable { public String create() { try { TapSchema tapSchema = new TapSchema(credentials, tapSchemaName, false); TapSchema tapSchema = new TapSchema(sourceCredentials, tapSchemaCredentials, tapSchemaName, false); for (String selectedSchema : selectedSchemas) { tapSchema.addEntityWrapper(selectedSchema); } Loading @@ -183,12 +205,20 @@ public class SchemaSelectionBean implements Serializable { this.tapSchemaName = tapSchemaName; } public Credentials getCredentials() { return credentials; public Credentials getSourceCredentials() { return sourceCredentials; } public void setSourceCredentials(Credentials sourceCredentials) { this.sourceCredentials = sourceCredentials; } public Credentials getTapSchemaCredentials() { return tapSchemaCredentials; } public void setCredentials(Credentials credentials) { this.credentials = credentials; public void setTapSchemaCredentials(Credentials tapSchemaCredentials) { this.tapSchemaCredentials = tapSchemaCredentials; } public String logout() { Loading
TapSchemaManager/src/main/resources/log4j.properties 0 → 100644 +16 −0 Original line number Diff line number Diff line # Default Appender log4j.appender.AD=org.apache.log4j.ConsoleAppender log4j.appender.AD.layout=org.apache.log4j.PatternLayout log4j.appender.AD.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n # IA2 Appender log4j.appender.IA2=org.apache.log4j.ConsoleAppender log4j.appender.IA2.layout=org.apache.log4j.PatternLayout log4j.appender.IA2.layout.ConversionPattern=[%c{1}]: %m%n # Root Logger log4j.rootLogger=WARN,AD # IA2 Logger log4j.logger.it.inaf.oats.ia2=TRACE,IA2 log4j.additivity.it.inaf.oats.ia2=false