From 563cf1c5e16f148709700dd2c59e6fd07731e468 Mon Sep 17 00:00:00 2001 From: Sonia Zorba Date: Fri, 17 Mar 2017 16:35:44 +0100 Subject: [PATCH] Started changes for multi-user setup and custom UCD insertion. Refactoring (in progress) --- .../it/inaf/ia2/tsm/webapp/Configuration.java | 55 ---- ...rationBean.java => ConfigurationData.java} | 62 ++-- .../tsm/webapp/CredentialsDialogResource.java | 48 ++++ ...tialsBean.java => CredentialsEditing.java} | 86 ++---- .../it/inaf/ia2/tsm/webapp/FirstSetup.java | 65 +++++ .../java/it/inaf/ia2/tsm/webapp/Login.java | 74 +++++ .../it/inaf/ia2/tsm/webapp/ParsedUCD.java | 1 - .../inaf/ia2/tsm/webapp/SearchUCDDialog.java | 18 +- .../ia2/tsm/webapp/SeparateCredentials.java | 5 +- .../ia2/tsm/webapp/TapSchemaEditingBean.java | 2 + .../it/inaf/ia2/tsm/webapp/UCDEditor.java | 99 +++++++ .../java/it/inaf/ia2/tsm/webapp/User.java | 75 +++++ .../java/it/inaf/ia2/tsm/webapp/Version.java | 2 +- .../tsm/webapp/checker/FirstSetupChecker.java | 67 +++++ .../tsm/webapp/checker/LoggedInChecker.java | 33 +++ .../webapp/{ => env}/ApplicationConfig.java | 5 +- .../CustomPartialResponseWriter.java | 2 +- .../CustomPartialViewContextFactory.java | 2 +- .../CustomPartialViewContextWrapper.java | 2 +- .../tsm/webapp/{ => env}/JSUpdateHandler.java | 2 +- .../tsm/webapp/{ => env}/KeepAliveBean.java | 7 +- .../webapp/{ => env}/KeepAliveResource.java | 2 +- .../{ => env}/NullOrEmptyConverter.java | 6 +- .../{ => env}/TSMResourceHandlerWrapper.java | 6 +- .../Configuration.java} | 39 ++- .../webapp/xmlconfig/UCDConfiguration.java | 94 ++++++ .../webapp/xmlconfig/UserConfiguration.java | 104 +++++++ .../src/main/resources/webapp.properties | 3 +- .../src/main/webapp/WEB-INF/faces-config.xml | 4 +- .../webapp/WEB-INF/templates/master.xhtml | 5 + .../src/main/webapp/consistencyChecks.xhtml | 1 + .../src/main/webapp/credentialsEditing.xhtml | 227 +++++++++++++++ .../src/main/webapp/expired.xhtml | 2 +- .../src/main/webapp/index.xhtml | 272 ++---------------- .../src/main/webapp/resources/css/style.css | 15 + .../main/webapp/resources/js/credentials.js | 17 +- .../src/main/webapp/resources/js/keepalive.js | 23 -- .../src/main/webapp/resources/js/login.js | 13 + .../main/webapp/resources/js/ucd-editor.js | 13 + .../resources/tsm_components/ucd_editor.xhtml | 88 ++++++ .../tsm_components/user_navbar.xhtml | 47 +++ .../src/main/webapp/schemaSelection.xhtml | 1 + .../src/main/webapp/setup.xhtml | 51 ++++ .../src/main/webapp/tapSchemaEditing.xhtml | 2 + .../src/test/java/TapSchemaMangerTest.java | 47 +-- 45 files changed, 1287 insertions(+), 507 deletions(-) delete mode 100644 TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/Configuration.java rename TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/{WebAppConfigurationBean.java => ConfigurationData.java} (53%) create mode 100644 TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsDialogResource.java rename TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/{CredentialsBean.java => CredentialsEditing.java} (65%) create mode 100644 TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/FirstSetup.java create mode 100644 TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/Login.java create mode 100644 TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/UCDEditor.java create mode 100644 TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/User.java create mode 100644 TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/checker/FirstSetupChecker.java create mode 100644 TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/checker/LoggedInChecker.java rename TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/{ => env}/ApplicationConfig.java (90%) rename TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/{ => env}/CustomPartialResponseWriter.java (99%) rename TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/{ => env}/CustomPartialViewContextFactory.java (97%) rename TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/{ => env}/CustomPartialViewContextWrapper.java (98%) rename TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/{ => env}/JSUpdateHandler.java (97%) rename TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/{ => env}/KeepAliveBean.java (87%) rename TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/{ => env}/KeepAliveResource.java (98%) rename TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/{ => env}/NullOrEmptyConverter.java (93%) rename TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/{ => env}/TSMResourceHandlerWrapper.java (95%) rename TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/{CredentialsConfiguration.java => xmlconfig/Configuration.java} (60%) create mode 100644 TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/UCDConfiguration.java create mode 100644 TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/UserConfiguration.java create mode 100644 TapSchemaManagerWebApp/src/main/webapp/credentialsEditing.xhtml create mode 100644 TapSchemaManagerWebApp/src/main/webapp/resources/js/login.js create mode 100644 TapSchemaManagerWebApp/src/main/webapp/resources/js/ucd-editor.js create mode 100644 TapSchemaManagerWebApp/src/main/webapp/resources/tsm_components/ucd_editor.xhtml create mode 100644 TapSchemaManagerWebApp/src/main/webapp/resources/tsm_components/user_navbar.xhtml create mode 100644 TapSchemaManagerWebApp/src/main/webapp/setup.xhtml diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/Configuration.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/Configuration.java deleted file mode 100644 index 1af54e9..0000000 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/Configuration.java +++ /dev/null @@ -1,55 +0,0 @@ -package it.inaf.ia2.tsm.webapp; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * JAXB model for TSM web application configuration. - * - * @author Sonia Zorba {@literal } - */ -@XmlRootElement(name = "configuration") -public class Configuration { - - private CredentialsConfiguration credentialsConfiguration; - private List customUCDs; - private String version; - - public Configuration() { - version = Version.NUMBER; - credentialsConfiguration = new CredentialsConfiguration(); - customUCDs = new ArrayList<>(); - } - - @XmlElement(name = "credentials-config") - public CredentialsConfiguration getCredentialsConfiguration() { - return credentialsConfiguration; - } - - public void setCredentialsConfiguration(CredentialsConfiguration credentialsConfiguration) { - this.credentialsConfiguration = credentialsConfiguration; - } - - @XmlElementWrapper(name = "custom-ucds") - @XmlElement(name = "ucd") - public List getCustomUCDs() { - return customUCDs; - } - - public void setCustomUCDs(List customUCDs) { - this.customUCDs = customUCDs; - } - - @XmlAttribute(name = "version") - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } -} diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/WebAppConfigurationBean.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/ConfigurationData.java similarity index 53% rename from TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/WebAppConfigurationBean.java rename to TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/ConfigurationData.java index 40afa31..b270a3b 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/WebAppConfigurationBean.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/ConfigurationData.java @@ -22,33 +22,31 @@ */ package it.inaf.ia2.tsm.webapp; -import ari.ucidy.UCDSyntax; -import ari.ucidy.UCDWord; -import ari.ucidy.UCDWordList; +import it.inaf.ia2.tsm.webapp.xmlconfig.Configuration; +import it.inaf.ia2.tsm.webapp.xmlconfig.UserConfiguration; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import javax.annotation.PostConstruct; import javax.enterprise.context.ApplicationScoped; +import javax.faces.context.FacesContext; +import javax.inject.Named; import javax.xml.bind.JAXB; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; /** * * @author Sonia Zorba {@literal } */ +@Named("config") @ApplicationScoped -public class WebAppConfigurationBean { +public class ConfigurationData { - private static final Logger LOG = LoggerFactory.getLogger(WebAppConfigurationBean.class); + private static final Logger LOG = LoggerFactory.getLogger(ConfigurationData.class); private File configFile; - private String password; private Configuration configuration; @PostConstruct @@ -59,7 +57,6 @@ public class WebAppConfigurationBean { prop.load(in); } configFile = new File(prop.getProperty("config_file_path")); - password = prop.getProperty("password"); if (!configFile.exists()) { @@ -72,21 +69,15 @@ public class WebAppConfigurationBean { } else { - configuration = getOldConfigurationUpdated(configFile); - - if (configuration != null) { - updateConfigurationFile(); - } else { - // Configuration file was ok, simply unmarshal it - configuration = JAXB.unmarshal(configFile, Configuration.class); - } + // Configuration file exists, simply unmarshal it + configuration = JAXB.unmarshal(configFile, Configuration.class); } } catch (IOException e) { throw new ExceptionInInitializerError(e); } } - public Configuration getConfig() { + public Configuration getData() { return configuration; } @@ -94,33 +85,16 @@ public class WebAppConfigurationBean { JAXB.marshal(configuration, configFile); } - public String getPassword() { - return password; + public synchronized void addUser(UserConfiguration user) throws IOException { + configuration.getUsers().add(user); + updateConfigurationFile(); } - /** - * Checking for old configuration and updating configuration model, if - * necessary. This method returns null if no update is necessary. - */ - private Configuration getOldConfigurationUpdated(File file) throws IOException { - try { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document doc = db.parse(file); - String nodeName = doc.getDocumentElement().getNodeName(); - if (nodeName.equals("credentials-config")) { - LOG.debug("Detected version 1.0.3 or lower. Extracting CredentialsConfiguration and updating the XML model."); - CredentialsConfiguration cc = JAXB.unmarshal(file, CredentialsConfiguration.class); - Configuration updatedConfiguration = new Configuration(); - updatedConfiguration.setCredentialsConfiguration(cc); - return updatedConfiguration; - } + public String getRestPath() { + return FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath() + "/rest"; + } - // Currently for version 1.0.4+ no updated are necessary. - return null; - } catch (Throwable t) { - LOG.warn("Unable to parse XML configuration. Deleting it and creating a new empy one."); - return new Configuration(); - } + public String getVersion() { + return Version.NUMBER; } } diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsDialogResource.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsDialogResource.java new file mode 100644 index 0000000..f45a0c4 --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsDialogResource.java @@ -0,0 +1,48 @@ +/* + * _____________________________________________________________________________ + * + * INAF - OATS National Institute for Astrophysics - Astronomical Observatory of + * Trieste INAF - IA2 Italian Center for Astronomical Archives + * _____________________________________________________________________________ + * + * Copyright (C) 2017 Istituto Nazionale di Astrofisica + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License Version 3 as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package it.inaf.ia2.tsm.webapp; + +import javax.ws.rs.Path; +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.ws.rs.POST; +import javax.ws.rs.QueryParam; + +/** + * REST Web Service for setting opening dialog status using JavaScript. This is + * necessary to conditionally disable JSF validation when dialog is closed. + * + * @author Sonia Zorba + */ +@Path("credentialsDialog") +@RequestScoped +public class CredentialsDialogResource { + + @Inject + CredentialsEditing credentialsEditing; + + @POST + public void setOpened(@QueryParam("opened") boolean opened) { + credentialsEditing.setCredentialsDialogOpened(opened); + } +} diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsBean.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsEditing.java similarity index 65% rename from TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsBean.java rename to TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsEditing.java index 8a58a98..b7d74c8 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsBean.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsEditing.java @@ -24,6 +24,7 @@ package it.inaf.ia2.tsm.webapp; import it.inaf.ia2.tsm.api.Credentials; import it.inaf.ia2.tsm.api.DBWrapper; +import it.inaf.ia2.tsm.webapp.xmlconfig.UserConfiguration; import java.io.IOException; import java.io.Serializable; import java.sql.SQLException; @@ -31,11 +32,8 @@ import java.util.List; import javax.annotation.PostConstruct; import javax.enterprise.context.Conversation; import javax.enterprise.context.SessionScoped; -import javax.faces.application.FacesMessage; -import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; -import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,23 +43,24 @@ import org.slf4j.LoggerFactory; */ @Named("credentialsInsertion") @SessionScoped -public class CredentialsBean implements Serializable { +public class CredentialsEditing implements Serializable { private static final long serialVersionUID = -2688980249773483198L; - private static final Logger log = LoggerFactory.getLogger(CredentialsBean.class); + private static final Logger LOG = LoggerFactory.getLogger(CredentialsEditing.class); @Inject - WebAppConfigurationBean ccBean; + private User user; + + @Inject + private ConfigurationData config; @Inject Conversation conversation; @Inject - SchemaSelectionBean schemaSelectionBean; + private SchemaSelectionBean schemaSelectionBean; - private boolean loggedIn; - private String adminPassword; - private String loginError; + private boolean credentialsDialogOpened; private Credentials sourceCredentials; private Credentials tapSchemaCredentials; @@ -70,30 +69,20 @@ public class CredentialsBean implements Serializable { @PostConstruct public void init() { - log.debug("CredentialsBean created"); - if (!conversation.isTransient()) { conversation.end(); } sourceCredentials = new Credentials(); tapSchemaCredentials = new Credentials(); - } - public void login() { - if (adminPassword != null && adminPassword.equals(ccBean.getPassword())) { - loggedIn = true; - } else { - FacesContext.getCurrentInstance().addMessage("main:password", new FacesMessage("Invalid credentials")); - } - } + for (UserConfiguration u : config.getData().getUsers()) { - public String getLoginError() { - return loginError; + } } public List getSavedCredentials() { - return ccBean.getConfig().getCredentialsConfiguration().getCredentialsInfo(); + return user.getUserConfiguration().getCredentialsInfo(); } public void editCredentials(Credentials credentials, int index) { @@ -113,21 +102,20 @@ public class CredentialsBean implements Serializable { separateCredentials = false; this.sourceCredentials = new Credentials(); this.tapSchemaCredentials = new Credentials(); - currentEditingRow = ccBean.getConfig().getCredentialsConfiguration().getCredentialsInfo().size(); + currentEditingRow = getSavedCredentials().size(); } public String loginWithSingleCredentials(Credentials credentials) { - log.debug("Login with single credentials"); + LOG.debug("Login with single credentials"); return loginWithDBWrapper(new DBWrapper(credentials)); } public String loginWithSeparatedCredentials(Credentials sourceCredentials, Credentials tapSchemaCredentials) { - log.debug("Login with separated credentials"); + LOG.debug("Login with separated credentials"); return loginWithDBWrapper(new DBWrapper(sourceCredentials, tapSchemaCredentials)); } private String loginWithDBWrapper(DBWrapper dbWrapper) { - loginError = null; try { dbWrapper.testConnections(); @@ -136,33 +124,31 @@ public class CredentialsBean implements Serializable { schemaSelectionBean.setDbWrapper(dbWrapper); return "schemaSelection.xhtml?faces-redirect=true"; } catch (SQLException e) { - log.error("Exception caught", e); - loginError = "Connection error: " + e.getMessage(); + LOG.error("Exception caught", e); + //loginError = "Connection error: " + e.getMessage(); return null; } } public void removeCredentials(int index) throws IOException { - ccBean.getConfig().getCredentialsConfiguration().getCredentialsInfo().remove(index); - ccBean.updateConfigurationFile(); + getSavedCredentials().remove(index); + config.updateConfigurationFile(); } public void saveCredentialsEdited() throws IOException { - List credentialsList = ccBean.getConfig().getCredentialsConfiguration().getCredentialsInfo(); - - if (currentEditingRow < credentialsList.size()) { - credentialsList.remove(currentEditingRow); + if (currentEditingRow < getSavedCredentials().size()) { + getSavedCredentials().remove(currentEditingRow); } if (separateCredentials) { SeparateCredentials sc = new SeparateCredentials(sourceCredentials, tapSchemaCredentials); - credentialsList.add(currentEditingRow, sc); + getSavedCredentials().add(currentEditingRow, sc); } else { - credentialsList.add(currentEditingRow, sourceCredentials); + getSavedCredentials().add(currentEditingRow, sourceCredentials); } - ccBean.updateConfigurationFile(); + config.updateConfigurationFile(); } public boolean isSeparateCredentials() { @@ -189,27 +175,11 @@ public class CredentialsBean implements Serializable { this.tapSchemaCredentials = tapSchemaCredentials; } - public String getAdminPassword() { - return adminPassword; - } - - public void setAdminPassword(String adminPassword) { - this.adminPassword = adminPassword; - } - - public boolean isLoggedIn() { - return loggedIn; - } - - public void setLoggedIn(boolean loggedIn) { - this.loggedIn = loggedIn; + public boolean isCredentialsDialogOpened() { + return credentialsDialogOpened; } - public String logout() { - HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); - if (request.isRequestedSessionIdValid()) { - request.getSession().invalidate(); - } - return "index.xhtml?faces-redirect=true"; + public void setCredentialsDialogOpened(boolean credentialsDialogOpened) { + this.credentialsDialogOpened = credentialsDialogOpened; } } diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/FirstSetup.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/FirstSetup.java new file mode 100644 index 0000000..57bb1da --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/FirstSetup.java @@ -0,0 +1,65 @@ +package it.inaf.ia2.tsm.webapp; + +import it.inaf.ia2.tsm.webapp.xmlconfig.UserConfiguration; +import java.io.IOException; +import javax.enterprise.context.RequestScoped; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * + * @author Sonia Zorba + */ +@Named +@RequestScoped +public class FirstSetup { + + @Inject + ConfigurationData config; + + private String adminUsername; + private String adminPassword; + private String adminPasswordConfirm; + + public String createAdmin() throws IOException { + if (adminPassword.equals(adminPasswordConfirm)) { + UserConfiguration userConfig = new UserConfiguration(); + userConfig.setUsername(adminUsername); + userConfig.setPassword(adminPassword); + userConfig.setRole("admin"); + + config.addUser(userConfig); + + return "index.xhtml?faces-redirect=true"; + } else { + FacesContext.getCurrentInstance().addMessage("admin-password-confirm", new FacesMessage("Passwords don't match")); + } + return null; + } + + public String getAdminUsername() { + return adminUsername; + } + + public void setAdminUsername(String adminUsername) { + this.adminUsername = adminUsername; + } + + public String getAdminPassword() { + return adminPassword; + } + + public void setAdminPassword(String adminPassword) { + this.adminPassword = adminPassword; + } + + public String getAdminPasswordConfirm() { + return adminPasswordConfirm; + } + + public void setAdminPasswordConfirm(String adminPasswordConfirm) { + this.adminPasswordConfirm = adminPasswordConfirm; + } +} diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/Login.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/Login.java new file mode 100644 index 0000000..33baa26 --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/Login.java @@ -0,0 +1,74 @@ +/* + * _____________________________________________________________________________ + * + * INAF - OATS National Institute for Astrophysics - Astronomical Observatory of + * Trieste INAF - IA2 Italian Center for Astronomical Archives + * _____________________________________________________________________________ + * + * Copyright (C) 2016 Istituto Nazionale di Astrofisica + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License Version 3 as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package it.inaf.ia2.tsm.webapp; + +import it.inaf.ia2.tsm.webapp.xmlconfig.UserConfiguration; +import javax.enterprise.context.RequestScoped; +import javax.faces.application.FacesMessage; +import javax.faces.context.FacesContext; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * + * @author Sonia Zorba + */ +@Named +@RequestScoped +public class Login { + + @Inject + private ConfigurationData config; + @Inject + private User user; + + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String login() { + for (UserConfiguration u : config.getData().getUsers()) { + if (u.getUsername().equals(username) && u.getPassword().equals(password)) { + user.login(u); + return "credentialsEditing.xhtml?faces-redirect=true"; + } + } + FacesContext.getCurrentInstance().addMessage("main", new FacesMessage("Invalid credentials")); + return null; + } +} diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/ParsedUCD.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/ParsedUCD.java index 5a63b58..4586a32 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/ParsedUCD.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/ParsedUCD.java @@ -24,7 +24,6 @@ package it.inaf.ia2.tsm.webapp; import ari.ucidy.UCD; import ari.ucidy.UCDParser; -import ari.ucidy.UCDWordList; import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/SearchUCDDialog.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/SearchUCDDialog.java index 063d799..6e2ad78 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/SearchUCDDialog.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/SearchUCDDialog.java @@ -38,7 +38,7 @@ public class SearchUCDDialog implements Serializable { private static final long serialVersionUID = -3503024742241865133L; @Inject - WebAppConfigurationBean config; + ConfigurationData config; private boolean manualInsertion; @@ -151,14 +151,14 @@ public class SearchUCDDialog implements Serializable { public void setUCDManualText(String UCDManualText) { this.UCDManualText = UCDManualText; } - - public void validateManualUCD() { - if (UCDManualText == null || UCDManualText.isEmpty() || UCDManualText.trim().isEmpty()) { - parsedUCD = null; - } else { - parsedUCD = new ParsedUCD(UCDManualText, config.getConfig().getCustomUCDs()); - } - } +// +// public void validateManualUCD() { +// if (UCDManualText == null || UCDManualText.isEmpty() || UCDManualText.trim().isEmpty()) { +// parsedUCD = null; +// } else { +// parsedUCD = new ParsedUCD(UCDManualText, config.getConfig().getCustomUCDs()); +// } +// } public String getUCDRegExp() { return SearchUCD.REG_EXP_UCD; diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/SeparateCredentials.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/SeparateCredentials.java index b3113c9..16675f4 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/SeparateCredentials.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/SeparateCredentials.java @@ -23,13 +23,16 @@ package it.inaf.ia2.tsm.webapp; import it.inaf.ia2.tsm.api.Credentials; +import java.io.Serializable; import javax.xml.bind.annotation.XmlElement; /** * * @author Sonia Zorba {@literal } */ -public class SeparateCredentials { +public class SeparateCredentials implements Serializable { + + private static final long serialVersionUID = 2108950341601128938L; private Credentials sourceCredentials; private Credentials tapSchemaCredentials; diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/TapSchemaEditingBean.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/TapSchemaEditingBean.java index 9f59b79..9cd6e3f 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/TapSchemaEditingBean.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/TapSchemaEditingBean.java @@ -22,6 +22,8 @@ */ package it.inaf.ia2.tsm.webapp; +import it.inaf.ia2.tsm.webapp.env.CustomPartialResponseWriter; +import it.inaf.ia2.tsm.webapp.env.JSUpdateHandler; import it.inaf.ia2.tsm.api.contract.ChildEntity; import it.inaf.ia2.tsm.api.contract.Column; import it.inaf.ia2.tsm.api.contract.EntitiesContainer; diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/UCDEditor.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/UCDEditor.java new file mode 100644 index 0000000..2171c58 --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/UCDEditor.java @@ -0,0 +1,99 @@ +package it.inaf.ia2.tsm.webapp; + +import ari.ucidy.UCD; +import ari.ucidy.UCDParser; +import it.inaf.ia2.tsm.webapp.xmlconfig.UCDConfiguration; +import it.inaf.ia2.tsm.webapp.xmlconfig.UserConfiguration; +import java.io.IOException; +import java.io.Serializable; +import java.util.List; +import javax.enterprise.context.SessionScoped; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * + * @author Sonia Zorba + */ +@Named("ucdEditor") +@SessionScoped +public class UCDEditor implements Serializable { + + private static final long serialVersionUID = -9117203239681234534L; + + @Inject + private ConfigurationData config; + + @Inject + private User user; + + private boolean viewExisting; + private UCDConfiguration newUCDConfiguration; + private String invalidUCDMessage; + private List customUCDs; + + public void openDialog() { + viewExisting = true; + newUCDConfiguration = new UCDConfiguration(); + invalidUCDMessage = null; + + // Retriving UCD list of current user + for (UserConfiguration u : config.getData().getUsers()) { + if (u.getUsername().equals(user.getUsername())) { + customUCDs = u.getCustomUCDs(); + break; + } + } + } + + public boolean isViewExisting() { + return viewExisting; + } + + public void setViewExisting(boolean viewExisting) { + this.viewExisting = viewExisting; + invalidUCDMessage = null; + } + + public UCDConfiguration getNewUCDConfiguration() { + return newUCDConfiguration; + } + + public List getCustomUCDs() { + return customUCDs; + } + + public void addUCD() throws IOException { + invalidUCDMessage = null; + + if (newUCDConfiguration.getWord() == null || newUCDConfiguration.getWord().isEmpty()) { + invalidUCDMessage = "Insert the UCD word"; + return; + } + + // Check if word syntax is valid + UCD ucd = UCDParser.parseUCD(newUCDConfiguration.getWord()); + + if (ucd.size() != 1 || !ucd.getWord(0).valid) { + invalidUCDMessage = "Invalid UCD word syntax"; + return; + } + + customUCDs.add(newUCDConfiguration); + newUCDConfiguration = new UCDConfiguration(); + config.updateConfigurationFile(); + } + + public void removeUCD(int index) throws IOException { + customUCDs.remove(index); + config.updateConfigurationFile(); + } + + /** + * For some reason getCurrentInstance().addMessage doesn't work inside the + * dialog, so this field has been added for setting error message manually. + */ + public String getInvalidUCDMessage() { + return invalidUCDMessage; + } +} diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/User.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/User.java new file mode 100644 index 0000000..7b253de --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/User.java @@ -0,0 +1,75 @@ +/* + * _____________________________________________________________________________ + * + * INAF - OATS National Institute for Astrophysics - Astronomical Observatory of + * Trieste INAF - IA2 Italian Center for Astronomical Archives + * _____________________________________________________________________________ + * + * Copyright (C) 2016 Istituto Nazionale di Astrofisica + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License Version 3 as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package it.inaf.ia2.tsm.webapp; + +import it.inaf.ia2.tsm.webapp.xmlconfig.UserConfiguration; +import java.io.Serializable; +import javax.enterprise.context.SessionScoped; +import javax.faces.context.FacesContext; +import javax.inject.Inject; +import javax.inject.Named; +import javax.servlet.http.HttpServletRequest; + +/** + * + * @author Sonia Zorba + */ +@Named +@SessionScoped +public class User implements Serializable { + + private static final long serialVersionUID = 1L; + + @Inject + ConfigurationData config; + + private UserConfiguration userConfiguration; + + public String getUsername() { + return userConfiguration == null ? null : userConfiguration.getUsername(); + } + + public boolean isAdmin() { + return userConfiguration != null && "admin".equals(userConfiguration.getRole()); + } + + public boolean isLoggedIn() { + return userConfiguration != null; + } + + public void login(UserConfiguration userConfiguration) { + this.userConfiguration = userConfiguration; + } + + public String logout() { + HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); + if (request.isRequestedSessionIdValid()) { + request.getSession().invalidate(); + } + return "index.xhtml?faces-redirect=true"; + } + + public UserConfiguration getUserConfiguration() { + return userConfiguration; + } +} diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/Version.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/Version.java index de5cd97..eeaa900 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/Version.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/Version.java @@ -14,7 +14,7 @@ public class Version { public final static String NUMBER; static { - try (InputStream is = TSMResourceHandlerWrapper.class.getClassLoader().getResourceAsStream("version.txt")) { + try (InputStream is = Version.class.getClassLoader().getResourceAsStream("version.txt")) { Scanner s = new Scanner(is).useDelimiter("\\A"); NUMBER = s.next().trim(); } catch (IOException e) { diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/checker/FirstSetupChecker.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/checker/FirstSetupChecker.java new file mode 100644 index 0000000..cf6aee2 --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/checker/FirstSetupChecker.java @@ -0,0 +1,67 @@ +/* + * _____________________________________________________________________________ + * + * INAF - OATS National Institute for Astrophysics - Astronomical Observatory of + * Trieste INAF - IA2 Italian Center for Astronomical Archives + * _____________________________________________________________________________ + * + * Copyright (C) 2016 Istituto Nazionale di Astrofisica + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License Version 3 as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package it.inaf.ia2.tsm.webapp.checker; + +import it.inaf.ia2.tsm.webapp.ConfigurationData; +import it.inaf.ia2.tsm.webapp.xmlconfig.Configuration; +import it.inaf.ia2.tsm.webapp.xmlconfig.UserConfiguration; +import javax.enterprise.context.RequestScoped; +import javax.faces.context.FacesContext; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * + * @author Sonia Zorba + */ +@Named +@RequestScoped +public class FirstSetupChecker { + + @Inject + private ConfigurationData config; + + public boolean isFirstSetupCompleted() { + Configuration c = config.getData(); + for (UserConfiguration user : c.getUsers()) { + if ("admin".equals(user.getRole())) { + return true; + } + } + return false; + } + + public void checkFromIndex() { + if (!isFirstSetupCompleted()) { + FacesContext fc = FacesContext.getCurrentInstance(); + fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "/setup.xhtml?faces-redirect=true"); + } + } + + public void checkFromFirstSetup() { + if (isFirstSetupCompleted()) { + FacesContext fc = FacesContext.getCurrentInstance(); + fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "/index.xhtml?faces-redirect=true"); + } + } +} diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/checker/LoggedInChecker.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/checker/LoggedInChecker.java new file mode 100644 index 0000000..605d49b --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/checker/LoggedInChecker.java @@ -0,0 +1,33 @@ +package it.inaf.ia2.tsm.webapp.checker; + +import it.inaf.ia2.tsm.webapp.User; +import javax.enterprise.context.RequestScoped; +import javax.faces.context.FacesContext; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * + * @author Sonia Zorba + */ +@Named +@RequestScoped +public class LoggedInChecker { + + @Inject + private User user; + + public void checkFromIndex() { + if (user.isLoggedIn()) { + FacesContext fc = FacesContext.getCurrentInstance(); + fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "/credentialsEditing.xhtml?faces-redirect=true"); + } + } + + public void checkFromNonIndex() { + if (!user.isLoggedIn()) { + FacesContext fc = FacesContext.getCurrentInstance(); + fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "/index.xhtml?faces-redirect=true"); + } + } +} diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/ApplicationConfig.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/ApplicationConfig.java similarity index 90% rename from TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/ApplicationConfig.java rename to TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/ApplicationConfig.java index 3138609..771603b 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/ApplicationConfig.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/ApplicationConfig.java @@ -20,7 +20,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package it.inaf.ia2.tsm.webapp; +package it.inaf.ia2.tsm.webapp.env; import java.util.Set; import javax.ws.rs.core.Application; @@ -45,6 +45,7 @@ public class ApplicationConfig extends Application { * out calling this method in getClasses(). */ private void addRestResourceClasses(Set> resources) { - resources.add(it.inaf.ia2.tsm.webapp.KeepAliveResource.class); + resources.add(it.inaf.ia2.tsm.webapp.CredentialsDialogResource.class); + resources.add(it.inaf.ia2.tsm.webapp.env.KeepAliveResource.class); } } diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CustomPartialResponseWriter.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/CustomPartialResponseWriter.java similarity index 99% rename from TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CustomPartialResponseWriter.java rename to TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/CustomPartialResponseWriter.java index 70d67d7..a5fe0cd 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CustomPartialResponseWriter.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/CustomPartialResponseWriter.java @@ -20,7 +20,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package it.inaf.ia2.tsm.webapp; +package it.inaf.ia2.tsm.webapp.env; import java.io.IOException; import java.util.Collections; diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CustomPartialViewContextFactory.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/CustomPartialViewContextFactory.java similarity index 97% rename from TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CustomPartialViewContextFactory.java rename to TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/CustomPartialViewContextFactory.java index b381ae1..40e5374 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CustomPartialViewContextFactory.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/CustomPartialViewContextFactory.java @@ -20,7 +20,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package it.inaf.ia2.tsm.webapp; +package it.inaf.ia2.tsm.webapp.env; import javax.faces.context.FacesContext; import javax.faces.context.PartialViewContext; diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CustomPartialViewContextWrapper.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/CustomPartialViewContextWrapper.java similarity index 98% rename from TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CustomPartialViewContextWrapper.java rename to TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/CustomPartialViewContextWrapper.java index a58f3b3..1b6c3bd 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CustomPartialViewContextWrapper.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/CustomPartialViewContextWrapper.java @@ -20,7 +20,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package it.inaf.ia2.tsm.webapp; +package it.inaf.ia2.tsm.webapp.env; import javax.faces.context.PartialResponseWriter; import javax.faces.context.PartialViewContext; diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/JSUpdateHandler.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/JSUpdateHandler.java similarity index 97% rename from TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/JSUpdateHandler.java rename to TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/JSUpdateHandler.java index 9ae5bd0..dc63045 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/JSUpdateHandler.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/JSUpdateHandler.java @@ -20,7 +20,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package it.inaf.ia2.tsm.webapp; +package it.inaf.ia2.tsm.webapp.env; /** * diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/KeepAliveBean.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/KeepAliveBean.java similarity index 87% rename from TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/KeepAliveBean.java rename to TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/KeepAliveBean.java index 34b82a7..256b2bb 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/KeepAliveBean.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/KeepAliveBean.java @@ -20,12 +20,11 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package it.inaf.ia2.tsm.webapp; +package it.inaf.ia2.tsm.webapp.env; import java.io.Serializable; import javax.enterprise.context.Conversation; import javax.enterprise.context.ConversationScoped; -import javax.faces.context.FacesContext; import javax.inject.Inject; import javax.inject.Named; @@ -42,10 +41,6 @@ public class KeepAliveBean implements Serializable { @Inject private Conversation conversation; - public String getRestPath() { - return FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath() + "/rest"; - } - public String getConversationId() { return conversation.getId(); } diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/KeepAliveResource.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/KeepAliveResource.java similarity index 98% rename from TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/KeepAliveResource.java rename to TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/KeepAliveResource.java index 4805b20..f6f89da 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/KeepAliveResource.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/KeepAliveResource.java @@ -20,7 +20,7 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package it.inaf.ia2.tsm.webapp; +package it.inaf.ia2.tsm.webapp.env; import java.io.Serializable; import javax.enterprise.context.Conversation; diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/NullOrEmptyConverter.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/NullOrEmptyConverter.java similarity index 93% rename from TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/NullOrEmptyConverter.java rename to TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/NullOrEmptyConverter.java index 471ac63..9626762 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/NullOrEmptyConverter.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/NullOrEmptyConverter.java @@ -20,15 +20,13 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package it.inaf.ia2.tsm.webapp; +package it.inaf.ia2.tsm.webapp.env; import javax.faces.component.UIComponent; import javax.faces.component.ValueHolder; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.convert.FacesConverter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * TAP_SCHEMA Manager inputText elements convert an empty input to null values. @@ -46,8 +44,6 @@ import org.slf4j.LoggerFactory; @FacesConverter("it.inaf.ia2.NullOrEmptyConverter") public class NullOrEmptyConverter implements Converter { - private final static Logger log = LoggerFactory.getLogger(NullOrEmptyConverter.class); - @Override public Object getAsObject(FacesContext context, UIComponent component, String value) { String previousValue = (String) ((ValueHolder) component).getValue(); diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/TSMResourceHandlerWrapper.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/TSMResourceHandlerWrapper.java similarity index 95% rename from TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/TSMResourceHandlerWrapper.java rename to TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/TSMResourceHandlerWrapper.java index 8891d79..69efda0 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/TSMResourceHandlerWrapper.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/env/TSMResourceHandlerWrapper.java @@ -20,11 +20,9 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package it.inaf.ia2.tsm.webapp; +package it.inaf.ia2.tsm.webapp.env; -import java.io.IOException; -import java.io.InputStream; -import java.util.Scanner; +import it.inaf.ia2.tsm.webapp.Version; import javax.faces.application.Resource; import javax.faces.application.ResourceHandler; import javax.faces.application.ResourceHandlerWrapper; diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsConfiguration.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/Configuration.java similarity index 60% rename from TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsConfiguration.java rename to TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/Configuration.java index af55592..ca6386a 100644 --- a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsConfiguration.java +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/Configuration.java @@ -20,45 +20,44 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package it.inaf.ia2.tsm.webapp; +package it.inaf.ia2.tsm.webapp.xmlconfig; -import it.inaf.ia2.tsm.api.Credentials; +import it.inaf.ia2.tsm.webapp.Version; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlRootElement; /** + * JAXB model for TASMAN web application configuration. * * @author Sonia Zorba {@literal } */ -@XmlRootElement(name = "credentials-config") -public class CredentialsConfiguration { +@XmlRootElement(name = "configuration") +public class Configuration implements Serializable { - private List credentialsInfo; + private static final long serialVersionUID = 5424034991075602177L; - public CredentialsConfiguration() { - credentialsInfo = new ArrayList<>(); - } - - public void addCredentials(Credentials credentials) { - credentialsInfo.add(credentials); - } + private final String version; + private final List users; - public void addSeparateCredentials(SeparateCredentials separateCredentials) { - credentialsInfo.add(separateCredentials); + public Configuration() { + version = Version.NUMBER; + users = new ArrayList<>(); } @XmlElements({ - @XmlElement(name = "credentials", type = Credentials.class), - @XmlElement(name = "separate-credentials", type = SeparateCredentials.class) + @XmlElement(name = "user") }) - public List getCredentialsInfo() { - return credentialsInfo; + public List getUsers() { + return users; } - private void setCredentialsInfo(List credentialsInfo) { - this.credentialsInfo = credentialsInfo; + @XmlAttribute(name = "version") + public String getVersion() { + return version; } } diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/UCDConfiguration.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/UCDConfiguration.java new file mode 100644 index 0000000..d6d8c7c --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/UCDConfiguration.java @@ -0,0 +1,94 @@ +/* + * _____________________________________________________________________________ + * + * INAF - OATS National Institute for Astrophysics - Astronomical Observatory of + * Trieste INAF - IA2 Italian Center for Astronomical Archives + * _____________________________________________________________________________ + * + * Copyright (C) 2016 Istituto Nazionale di Astrofisica + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License Version 3 as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package it.inaf.ia2.tsm.webapp.xmlconfig; + +import ari.ucidy.UCDSyntax; +import java.io.Serializable; +import javax.xml.bind.annotation.XmlElement; + +/** + * JAXB class for defining custom UCDs. + * + * @author Sonia Zorba + */ +public class UCDConfiguration implements Serializable { + + private static final long serialVersionUID = 2741074893406134667L; + + private UCDSyntax syntax; + private String word; + private String description; + + public UCDConfiguration() { + syntax = UCDSyntax.BOTH; + } + + @XmlElement(name = "code") + public UCDSyntax getSyntax() { + return syntax; + } + + public void setSyntax(UCDSyntax syntax) { + this.syntax = syntax; + } + + /** + * UCD word, including also custom namespace. + */ + @XmlElement(name = "word") + public String getWord() { + return word; + } + + public void setWord(String word) { + this.word = word; + } + + @XmlElement(name = "description") + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getCode() { + switch (syntax) { + case PRIMARY: + return "P"; + case SECONDARY: + return "S"; + case BOTH: + return "Q"; + case PHOT_QUANTITY: + return "E"; + case COLOUR: + return "C"; + case VECTOR: + return "V"; + default: + throw new RuntimeException("No code defined for syntax " + syntax); + } + } +} diff --git a/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/UserConfiguration.java b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/UserConfiguration.java new file mode 100644 index 0000000..41009c3 --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/UserConfiguration.java @@ -0,0 +1,104 @@ +/* + * _____________________________________________________________________________ + * + * INAF - OATS National Institute for Astrophysics - Astronomical Observatory of + * Trieste INAF - IA2 Italian Center for Astronomical Archives + * _____________________________________________________________________________ + * + * Copyright (C) 2016 Istituto Nazionale di Astrofisica + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License Version 3 as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package it.inaf.ia2.tsm.webapp.xmlconfig; + +import it.inaf.ia2.tsm.api.Credentials; +import it.inaf.ia2.tsm.webapp.SeparateCredentials; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlElements; + +/** + * + * @author Sonia Zorba + */ +public class UserConfiguration implements Serializable { + + private static final long serialVersionUID = 8512896146526279206L; + + private String role; + private String username; + private String password; + private final List customUCDs; + private final List credentialsInfo; + + public UserConfiguration() { + credentialsInfo = new ArrayList<>(); + customUCDs = new ArrayList<>(); + } + + @XmlAttribute(name = "username") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + @XmlAttribute(name = "password") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public void addCredentials(Credentials credentials) { + credentialsInfo.add(credentials); + } + + public void addSeparateCredentials(SeparateCredentials separateCredentials) { + credentialsInfo.add(separateCredentials); + } + + @XmlAttribute(name = "role") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @XmlElementWrapper(name = "credentials-configuration") + @XmlElements({ + @XmlElement(name = "credentials", type = Credentials.class) + , + @XmlElement(name = "separate-credentials", type = SeparateCredentials.class) + }) + public List getCredentialsInfo() { + return credentialsInfo; + } + + @XmlElementWrapper(name = "ucd-list") + @XmlElement(name = "ucd") + public List getCustomUCDs() { + return customUCDs; + } +} diff --git a/TapSchemaManagerWebApp/src/main/resources/webapp.properties b/TapSchemaManagerWebApp/src/main/resources/webapp.properties index fde5ec7..8a2b506 100644 --- a/TapSchemaManagerWebApp/src/main/resources/webapp.properties +++ b/TapSchemaManagerWebApp/src/main/resources/webapp.properties @@ -1,3 +1,2 @@ ucd_service_url=http://ia2-vo.oats.inaf.it/ucd/ -config_file_path=/home/sonia/.tsm/config.xml -password=pippo \ No newline at end of file +config_file_path=/home/sonia/.tsm/config.xml \ No newline at end of file diff --git a/TapSchemaManagerWebApp/src/main/webapp/WEB-INF/faces-config.xml b/TapSchemaManagerWebApp/src/main/webapp/WEB-INF/faces-config.xml index 4e7d8c9..f0bc77b 100644 --- a/TapSchemaManagerWebApp/src/main/webapp/WEB-INF/faces-config.xml +++ b/TapSchemaManagerWebApp/src/main/webapp/WEB-INF/faces-config.xml @@ -4,9 +4,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"> - it.inaf.ia2.tsm.webapp.CustomPartialViewContextFactory + it.inaf.ia2.tsm.webapp.env.CustomPartialViewContextFactory - it.inaf.ia2.tsm.webapp.TSMResourceHandlerWrapper + it.inaf.ia2.tsm.webapp.env.TSMResourceHandlerWrapper diff --git a/TapSchemaManagerWebApp/src/main/webapp/WEB-INF/templates/master.xhtml b/TapSchemaManagerWebApp/src/main/webapp/WEB-INF/templates/master.xhtml index 21b0916..09acb15 100644 --- a/TapSchemaManagerWebApp/src/main/webapp/WEB-INF/templates/master.xhtml +++ b/TapSchemaManagerWebApp/src/main/webapp/WEB-INF/templates/master.xhtml @@ -25,6 +25,11 @@ +

+
+ TASMAN ${config.version} – Powered by IA2 +
+
diff --git a/TapSchemaManagerWebApp/src/main/webapp/consistencyChecks.xhtml b/TapSchemaManagerWebApp/src/main/webapp/consistencyChecks.xhtml index 5fa2503..f34f093 100644 --- a/TapSchemaManagerWebApp/src/main/webapp/consistencyChecks.xhtml +++ b/TapSchemaManagerWebApp/src/main/webapp/consistencyChecks.xhtml @@ -11,6 +11,7 @@ +
diff --git a/TapSchemaManagerWebApp/src/main/webapp/credentialsEditing.xhtml b/TapSchemaManagerWebApp/src/main/webapp/credentialsEditing.xhtml new file mode 100644 index 0000000..2ef7e50 --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/webapp/credentialsEditing.xhtml @@ -0,0 +1,227 @@ + + + TASMAN - Credentials insertion page + + + + + + + + + + + +
+
+

TASMAN - Credentials insertion page

+
+ + + +
+
+ +
+ + + + + + + + + (${c.databaseType eq 'MYSQL' ? 'MySQL' : 'Postgres'}) ${c.hostname}:${c.port} ${c.username} +
+
+ + + +
+
+ +
+ + + + + + + + + Source + (${c.sourceCredentials.databaseType eq 'MYSQL' ? 'MySQL' : 'Postgres'}) ${c.sourceCredentials.hostname}:${c.sourceCredentials.port} ${c.sourceCredentials.username} + TAP_SCHEMA + (${c.tapSchemaCredentials.databaseType eq 'MYSQL' ? 'MySQL' : 'Postgres'}) ${c.tapSchemaCredentials.hostname}:${c.tapSchemaCredentials.port} ${c.tapSchemaCredentials.username} +
+
+ + + +
+
+
+
+
+
+



+ + + Add new database credentials + + +
+
+ + + + +
+
+
+
diff --git a/TapSchemaManagerWebApp/src/main/webapp/expired.xhtml b/TapSchemaManagerWebApp/src/main/webapp/expired.xhtml index 141f91e..fd4d57e 100644 --- a/TapSchemaManagerWebApp/src/main/webapp/expired.xhtml +++ b/TapSchemaManagerWebApp/src/main/webapp/expired.xhtml @@ -4,7 +4,7 @@ xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" > - TapSchema Manager - Session Expired + TASMAN - Session Expired
diff --git a/TapSchemaManagerWebApp/src/main/webapp/index.xhtml b/TapSchemaManagerWebApp/src/main/webapp/index.xhtml index 293702c..baefb22 100644 --- a/TapSchemaManagerWebApp/src/main/webapp/index.xhtml +++ b/TapSchemaManagerWebApp/src/main/webapp/index.xhtml @@ -4,266 +4,50 @@ xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" > - TAP_SCHEMA Manager - Credentials insertion page + TASMAN - Login - + + +
-

TAP_SCHEMA Manager - Credentials insertion page

+

TASMAN - Login


- - -
-
-
-
Login
-
-
-
- Password -
- -

-
-
-
- - Login - - +
+
+
+
Login
+
+
+
+ Username +
+ +

-
-
-
-
- - - - - -
-
- -
- - - - - - - - - (${c.databaseType eq 'MYSQL' ? 'MySQL' : 'Postgres'}) ${c.hostname}:${c.port} ${c.username} -
-
- - - -
-
- -
- - - - - - - - - Source - (${c.sourceCredentials.databaseType eq 'MYSQL' ? 'MySQL' : 'Postgres'}) ${c.sourceCredentials.hostname}:${c.sourceCredentials.port} ${c.sourceCredentials.username} - TAP_SCHEMA - (${c.tapSchemaCredentials.databaseType eq 'MYSQL' ? 'MySQL' : 'Postgres'}) ${c.tapSchemaCredentials.hostname}:${c.tapSchemaCredentials.port} ${c.tapSchemaCredentials.username} -
-
- - - -
-
-
-
-
-
- - - Add new - - -
-
- -
- -
- #{credentialsInsertion.loginError} -
-
- - diff --git a/TapSchemaManagerWebApp/src/main/webapp/resources/css/style.css b/TapSchemaManagerWebApp/src/main/webapp/resources/css/style.css index 0e000b9..04bfc26 100644 --- a/TapSchemaManagerWebApp/src/main/webapp/resources/css/style.css +++ b/TapSchemaManagerWebApp/src/main/webapp/resources/css/style.css @@ -189,3 +189,18 @@ input[type="checkbox"].changed { vertical-align: middle; font-size: 45px; } + +footer { + border-top: 1px #eee solid; + margin-top: 20px; + color: #777; + font-size: 85%; + padding-top: 10px; + margin-bottom: 10px; +} + +/* Trick to avoid horrible displaying of h:selectOneRadio */ +table input+label { + margin-right: 10px; + margin-left: 3px; +} \ No newline at end of file diff --git a/TapSchemaManagerWebApp/src/main/webapp/resources/js/credentials.js b/TapSchemaManagerWebApp/src/main/webapp/resources/js/credentials.js index 7c07ddc..18b9911 100644 --- a/TapSchemaManagerWebApp/src/main/webapp/resources/js/credentials.js +++ b/TapSchemaManagerWebApp/src/main/webapp/resources/js/credentials.js @@ -1,9 +1,14 @@ (function () { + var restPath; + window.credentials = { - adminLoginClicked: function (event) { + init: function (path) { + restPath = path; + }, + saveClicked: function (event) { if (event.keyCode === 13) { - $('#main\\:admin-login-btn').click(); + $('#main\\:save-credentials').click(); event.preventDefault(); return false; } @@ -22,4 +27,12 @@ } }; + $(document).ready(function () { + $('body').on('shown.bs.modal', '#credentials-modal', function ( ) { + $.post(restPath + "/credentialsDialog?opened=true"); + }); + $('body').on('hidden.bs.modal', '#credentials-modal', function ( ) { + $.post(restPath + "/credentialsDialog?opened=false"); + }); + }); })(); diff --git a/TapSchemaManagerWebApp/src/main/webapp/resources/js/keepalive.js b/TapSchemaManagerWebApp/src/main/webapp/resources/js/keepalive.js index 2f68ea7..9c0ed39 100644 --- a/TapSchemaManagerWebApp/src/main/webapp/resources/js/keepalive.js +++ b/TapSchemaManagerWebApp/src/main/webapp/resources/js/keepalive.js @@ -1,26 +1,3 @@ -/* - * _____________________________________________________________________________ - * - * INAF - OATS National Institute for Astrophysics - Astronomical Observatory of - * Trieste INAF - IA2 Italian Center for Astronomical Archives - * _____________________________________________________________________________ - * - * Copyright (C) 2016 Istituto Nazionale di Astrofisica - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License Version 3 as published by the - * Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 51 - * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - window.startKeepAlive = function (restPath, conversationId) { setInterval(function () { $.get(restPath + '/keepalive?cid=' + conversationId); diff --git a/TapSchemaManagerWebApp/src/main/webapp/resources/js/login.js b/TapSchemaManagerWebApp/src/main/webapp/resources/js/login.js new file mode 100644 index 0000000..dc123e3 --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/webapp/resources/js/login.js @@ -0,0 +1,13 @@ +(function () { + + window.credentials = { + loginClicked: function (event) { + if (event.keyCode === 13) { + $('#main\\:admin-login-btn').click(); + event.preventDefault(); + return false; + } + } + }; + +})(); diff --git a/TapSchemaManagerWebApp/src/main/webapp/resources/js/ucd-editor.js b/TapSchemaManagerWebApp/src/main/webapp/resources/js/ucd-editor.js new file mode 100644 index 0000000..3ae2c38 --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/webapp/resources/js/ucd-editor.js @@ -0,0 +1,13 @@ +(function ($) { + + window.UCDEditor = { + + open: function (event) { + if (event.status === 'success') { + $('#ucd-editor').modal('show'); + } + } + + }; + +})(jQuery); \ No newline at end of file diff --git a/TapSchemaManagerWebApp/src/main/webapp/resources/tsm_components/ucd_editor.xhtml b/TapSchemaManagerWebApp/src/main/webapp/resources/tsm_components/ucd_editor.xhtml new file mode 100644 index 0000000..39acc18 --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/webapp/resources/tsm_components/ucd_editor.xhtml @@ -0,0 +1,88 @@ + + + + + + + + + + diff --git a/TapSchemaManagerWebApp/src/main/webapp/resources/tsm_components/user_navbar.xhtml b/TapSchemaManagerWebApp/src/main/webapp/resources/tsm_components/user_navbar.xhtml new file mode 100644 index 0000000..6a2b907 --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/webapp/resources/tsm_components/user_navbar.xhtml @@ -0,0 +1,47 @@ + + + + + + + + + + diff --git a/TapSchemaManagerWebApp/src/main/webapp/schemaSelection.xhtml b/TapSchemaManagerWebApp/src/main/webapp/schemaSelection.xhtml index 01bd503..c176f65 100644 --- a/TapSchemaManagerWebApp/src/main/webapp/schemaSelection.xhtml +++ b/TapSchemaManagerWebApp/src/main/webapp/schemaSelection.xhtml @@ -11,6 +11,7 @@ +
diff --git a/TapSchemaManagerWebApp/src/main/webapp/setup.xhtml b/TapSchemaManagerWebApp/src/main/webapp/setup.xhtml new file mode 100644 index 0000000..777fa5f --- /dev/null +++ b/TapSchemaManagerWebApp/src/main/webapp/setup.xhtml @@ -0,0 +1,51 @@ + + + TASMAN - First setup + + +
+
+
+

TASMAN - First setup

+ +

It appears that you don't have defined an admin user yet.

+

Create it now:

+ +
+
+ Admin username +
+ +
+
+
+ Admin password +
+ +
+
+
+ Re-enter password +
+ +
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/TapSchemaManagerWebApp/src/main/webapp/tapSchemaEditing.xhtml b/TapSchemaManagerWebApp/src/main/webapp/tapSchemaEditing.xhtml index 0eaaae3..0071f43 100644 --- a/TapSchemaManagerWebApp/src/main/webapp/tapSchemaEditing.xhtml +++ b/TapSchemaManagerWebApp/src/main/webapp/tapSchemaEditing.xhtml @@ -15,6 +15,8 @@ + + diff --git a/TapSchemaManagerWebApp/src/test/java/TapSchemaMangerTest.java b/TapSchemaManagerWebApp/src/test/java/TapSchemaMangerTest.java index bd0c546..3b754d7 100644 --- a/TapSchemaManagerWebApp/src/test/java/TapSchemaMangerTest.java +++ b/TapSchemaManagerWebApp/src/test/java/TapSchemaMangerTest.java @@ -20,9 +20,9 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import it.inaf.ia2.tsm.webapp.CredentialsConfiguration; import it.inaf.ia2.tsm.webapp.SeparateCredentials; import it.inaf.ia2.tsm.api.Credentials; +import it.inaf.ia2.tsm.webapp.xmlconfig.UserConfiguration; import java.io.StringReader; import java.io.StringWriter; import javax.xml.bind.JAXB; @@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory; */ public class TapSchemaMangerTest { - private static final Logger log = LoggerFactory.getLogger(TapSchemaMangerTest.class); + private static final Logger LOG = LoggerFactory.getLogger(TapSchemaMangerTest.class); public TapSchemaMangerTest() { } @@ -65,25 +65,28 @@ public class TapSchemaMangerTest { @Test public void testCredentialsConfigSerialization() throws Exception { - CredentialsConfiguration cc = new CredentialsConfiguration(); - - cc.addCredentials(new Credentials()); - - SeparateCredentials sc = new SeparateCredentials(); - sc.setSourceCredentials(new Credentials()); - sc.setTapSchemaCredentials(new Credentials()); - cc.addSeparateCredentials(sc); - - StringWriter sw = new StringWriter(); - JAXB.marshal(cc, sw); - - StringReader sr = new StringReader(sw.toString()); - - cc = JAXB.unmarshal(sr, CredentialsConfiguration.class); - sw = new StringWriter(); - JAXB.marshal(cc, sw); - - log.debug(sw.toString()); - sw.close(); +// CredentialsConfiguration cc = new CredentialsConfiguration(); +// +// UserConfiguration uc = new UserConfiguration(); +// cc.getUsers().add(uc); +// +// uc.addCredentials(new Credentials()); +// +// SeparateCredentials sc = new SeparateCredentials(); +// sc.setSourceCredentials(new Credentials()); +// sc.setTapSchemaCredentials(new Credentials()); +// uc.addSeparateCredentials(sc); +// +// StringWriter sw = new StringWriter(); +// JAXB.marshal(cc, sw); +// +// StringReader sr = new StringReader(sw.toString()); +// +// cc = JAXB.unmarshal(sr, CredentialsConfiguration.class); +// sw = new StringWriter(); +// JAXB.marshal(cc, sw); +// +// LOG.debug(sw.toString()); +// sw.close(); } } -- GitLab