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 1af54e9d143599a7c8f494b24d4b4f5749583844..0000000000000000000000000000000000000000 --- 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 40afa31f15e7c58c4150bf272faa4347fe94c207..b270a3bf85103c844addc1ade3d8f28e72fc9356 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 0000000000000000000000000000000000000000..f45a0c4475bb8f34d82b041e7d570a5fa5813e56 --- /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 8a58a9823593fa70fa1b1e84e45cdcd92fb03bcf..b7d74c8561f518c21fd528a63d63309d2b1dffd0 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 0000000000000000000000000000000000000000..57bb1da816a9da0908ae7213a83d920b2085d463 --- /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 0000000000000000000000000000000000000000..33baa264c25602721b0029a38206d769a882eeb5 --- /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 5a63b58d664cb51e9a0424ff32e062b418ca4084..4586a32cd609971e930086227561be983309f629 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 063d799ee71b4efd56537b3c39aa6d0ff54a7f25..6e2ad780680ca829064eb9bf8ee2863736009908 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 b3113c9f1e7adfd80a6f7fe5d736df574898d769..16675f476af21caf89772aebb0875dd38e6b3150 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 9f59b795373924277ba035dcbe6883839e3370ab..9cd6e3fc182f7c687eab59e05982a977afdbe4c2 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 0000000000000000000000000000000000000000..2171c58ff623163a02ecd286478478b43f546275 --- /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 0000000000000000000000000000000000000000..7b253deb0e8026c3b249476ac3c855a23e8f886b --- /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 de5cd9759d4febf956762f42dd86e05e0e56d108..eeaa9001aee27c28c4c20f09279bd4d9121597b0 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 0000000000000000000000000000000000000000..cf6aee291ae552d40bc76f3c0b6212e000e59e6a --- /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 0000000000000000000000000000000000000000..605d49b3bac912496425c022707b9834ab255454 --- /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 3138609dfd1f6a87466a5950bcc091c2506d1a6e..771603b1d0ac69ed896a4de09cf71c5cf10b00c1 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 70d67d7a391676bc963695f2509e276ffcb578c2..a5fe0cd446b424e25d8e910d447563df643151bb 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 b381ae1616e6cc6b4f29cef149b3717dd458aba7..40e53740a3d5eebe7c9730c34416134575420054 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 a58f3b30a59c810df7b70fb0a4b39709ef472c3a..1b6c3bdf543d15bc245e01186b2ad4de4de89cb6 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 9ae5bd0387feb6ce71754cb55ef4a28803ed10b6..dc630452e563fc7e230e11e87927ded1cbbd43c3 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 34b82a721503464c95974a72f9f300a918499acc..256b2bb73f0e0a22e69f807b0f9984e47553fac8 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 4805b20f41546db9a50a2a9b205ef4dfdbf72926..f6f89da3a3c7d5e11d07a1d46db52ce0acbbed36 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 471ac634ab277a257fd282109580b39e3c2e7c1a..962676260369ff13321d73176f6f1a4154680526 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 8891d79fa7ae6fcc235947caa459c3fa239d9b08..69efda0e8fd8359f8ba80c107e88090fbb5827d9 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 af555927fdeca8c6094dadb0203cdddf1686179c..ca6386a3f30310d0c8ea3d948eef0822c9cf51fd 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 0000000000000000000000000000000000000000..d6d8c7c6024dd19b446944403a4989a60f68a883 --- /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 0000000000000000000000000000000000000000..41009c345109ebcda2b6a6c0d87a24042fb9e1b3 --- /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 fde5ec7cf84b773bef7e063db0fd34cb8e2054a2..8a2b5065fa016baa5a4e51ea16650d1b9c9cf505 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 4e7d8c9a7dcb1edef4c478f0a3f56496a36328f4..f0bc77b2d5374cb7f2a5c2cf8c5cfed2197948e0 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 21b091606b40cdd1cf8a33939e9faf33bc064c56..09acb15745773baaf6b0b06d801926851059761b 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 5fa250362dacd437cb96d10053965ce2faac475b..f34f093b8aef087e2618adf8d845a5ee856f1195 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 0000000000000000000000000000000000000000..2ef7e5030f2e324d27ea6501e28b9522f5eb2e2e --- /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 141f91e071abf3427d476f9f42530baf2ce57978..fd4d57eea7a73287c6db733d9d18e0fc84eb299b 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 293702c4d113731c9c7f48d4fcac186e55991b2b..baefb22bae5c747c480097ae98eeef933be06450 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 0e000b97ddf2a3cd1e4ea02efe51fbdcfbdc03f7..04bfc26a31d58fe08363406a8c6a25bbd5ed9cce 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 7c07ddcdeff7ae6104f18ece4b01fa7c7f5e28ce..18b9911e5e6b496bb2d6ca260ffdac3d388785d9 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 2f68ea7501dafc14e5204bffceafddaade198258..9c0ed3994f5fb15d17c110a30fef2c010bd64d77 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 0000000000000000000000000000000000000000..dc123e3b16a51d596f92ab221cd783aaa8a60fb8 --- /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 0000000000000000000000000000000000000000..3ae2c38b7b63b120ea101452f9f06b22961faf42 --- /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 0000000000000000000000000000000000000000..39acc18f2ef7fb4a0b84f2dbaac9bc2a80ed241e --- /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 0000000000000000000000000000000000000000..6a2b9070244fb17b1ed92b06af69d5c50634392c --- /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 01bd503812f6719a28a942f18c87869b557a48c7..c176f658c9b34335510b1f2741a72529647fc130 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 0000000000000000000000000000000000000000..777fa5f7b3b239573e23c52f431996020eb67073 --- /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 0eaaae3dd652f4dcfa43d2a34381591865102a7e..0071f43d254cd8f537d3c926315d59919cbef730 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 bd0c5466e7cd3bab6e545d25de756c6c976a82df..3b754d72be2668b4eb633543100c996c8092bea1 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(); } }