Skip to content
Snippets Groups Projects
Commit f233c97c authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Started changes for new configuration settings

parent f6295e1a
Branches
Tags
No related merge requests found
Showing
with 627 additions and 222 deletions
......@@ -22,8 +22,8 @@
*/
package it.inaf.ia2.tsm.datalayer;
import it.inaf.ia2.tsm.datalayer.DatabaseType;
import java.io.Serializable;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAttribute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
public class Credentials implements Serializable {
private static final long serialVersionUID = 1153912575502196261L;
private static final Logger log = LoggerFactory.getLogger(Credentials.class);
private static final Logger LOG = LoggerFactory.getLogger(Credentials.class);
private String hostname;
private int port;
......@@ -160,4 +160,46 @@ public class Credentials implements Serializable {
Credentials.class.getCanonicalName(),
databaseType, hostname, port, username, password, database);
}
@Override
public int hashCode() {
int hash = 3;
hash = 97 * hash + Objects.hashCode(this.hostname);
hash = 97 * hash + this.port;
hash = 97 * hash + Objects.hashCode(this.username);
hash = 97 * hash + Objects.hashCode(this.password);
hash = 97 * hash + Objects.hashCode(this.database);
hash = 97 * hash + Objects.hashCode(this.databaseType);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Credentials other = (Credentials) obj;
if (this.port != other.port) {
return false;
}
if (!Objects.equals(this.hostname, other.hostname)) {
return false;
}
if (!Objects.equals(this.username, other.username)) {
return false;
}
if (!Objects.equals(this.password, other.password)) {
return false;
}
if (!Objects.equals(this.database, other.database)) {
return false;
}
return this.databaseType == other.databaseType;
}
}
......@@ -5,5 +5,3 @@
# (It is necessary to put this list here because, unfortunately, there is no
# easy way to read an entire resource folder using the ClassLoader).
models = 1,1-IA2,1_1
allow_fictitious_keys = false
/*
* _____________________________________________________________________________
*
* 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.Configuration;
import it.inaf.ia2.tsm.webapp.xmlconfig.UserConfiguration;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Sonia Zorba {@literal <zorba at oats.inaf.it>}
*/
@Named("config")
@ApplicationScoped
public class ConfigurationData {
private static final Logger LOG = LoggerFactory.getLogger(ConfigurationData.class);
private File configFile;
private Configuration configuration;
@PostConstruct
public void init() {
try {
Properties prop = new Properties();
try (InputStream in = getClass().getClassLoader().getResourceAsStream("webapp.properties")) {
prop.load(in);
}
configFile = new File(prop.getProperty("config_file_path"));
if (!configFile.exists()) {
LOG.debug("Configuration file doesn't exist: creating a new one at " + configFile.getAbsolutePath());
configFile.getParentFile().mkdirs();
configFile.createNewFile();
configuration = new Configuration();
updateConfigurationFile();
} else {
// Configuration file exists, simply unmarshal it
configuration = JAXB.unmarshal(configFile, Configuration.class);
}
} catch (IOException e) {
throw new ExceptionInInitializerError(e);
}
}
public Configuration getData() {
return configuration;
}
public synchronized List<UserConfiguration> cloneUsersConfiguration() {
// JAXB is exploited for doing deep copy.
return JAXB.unmarshal(configFile, Configuration.class).getUsers();
}
public void updateConfigurationFile() throws IOException {
JAXB.marshal(configuration, configFile);
}
public synchronized void addUser(UserConfiguration user) throws IOException {
configuration.getUsers().add(user);
updateConfigurationFile();
}
public synchronized void updateUsersList(List<UserConfiguration> users) throws IOException {
configuration.getUsers().clear();
for (UserConfiguration user : users) {
configuration.getUsers().add(user);
}
updateConfigurationFile();
}
public String getRestPath() {
return FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath() + "/faces/rest";
}
public String getVersion() {
return Version.NUMBER;
}
}
/*
* _____________________________________________________________________________
*
* 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.TapCredentials;
import it.inaf.ia2.tsm.webapp.xmlconfig.UCDConfiguration;
import it.inaf.ia2.tsm.webapp.xmlconfig.UCDListConfiguration;
import it.inaf.ia2.tsm.webapp.xmlconfig.UsersConfiguration;
import it.inaf.ia2.tsm.webapp.xmlconfig.UserConfiguration;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Sonia Zorba {@literal <zorba at oats.inaf.it>}
*/
@Named("config")
@ApplicationScoped
public class ConfigurationManager {
private static final Logger LOG = LoggerFactory.getLogger(ConfigurationManager.class);
private static final String USERS_CONFIG_FILE_NAME = "users.xml";
private static final String UCD_CONFIG_FILE_NAME = "ucd.xml";
private File configDirectory;
private File usersConfigFile;
private File ucdConfigFile;
private UsersConfiguration usersConfig;
private UCDListConfiguration ucdListConfig;
@PostConstruct
public void init() {
try {
Properties prop = new Properties();
try (InputStream in = getClass().getClassLoader().getResourceAsStream("webapp.properties")) {
prop.load(in);
}
configDirectory = new File(prop.getProperty("config_directory"));
usersConfigFile = configDirectory.toPath().resolve(USERS_CONFIG_FILE_NAME).toFile();
ucdConfigFile = configDirectory.toPath().resolve(UCD_CONFIG_FILE_NAME).toFile();
if (!configDirectory.exists()) {
configDirectory.mkdirs();
}
if (!usersConfigFile.exists()) {
usersConfigFile.createNewFile();
usersConfig = new UsersConfiguration();
updateUsersConfigurationFile();
} else {
usersConfig = JAXB.unmarshal(usersConfigFile, UsersConfiguration.class);
}
if (!ucdConfigFile.exists()) {
ucdConfigFile.createNewFile();
ucdListConfig = new UCDListConfiguration();
updateUCDConfigurationFile();
} else {
ucdListConfig = JAXB.unmarshal(ucdConfigFile, UCDListConfiguration.class);
}
} catch (IOException e) {
throw new ExceptionInInitializerError(e);
}
}
public List<UserConfiguration> getUsersConfiguration() {
return Collections.unmodifiableList(usersConfig.getUsers());
}
public List<UCDConfiguration> getUCDConfiguration() {
return Collections.unmodifiableList(ucdListConfig.getUCDList());
}
private void updateUsersConfigurationFile() {
JAXB.marshal(usersConfig, usersConfigFile);
}
private void updateUCDConfigurationFile() {
JAXB.marshal(ucdListConfig, ucdConfigFile);
}
/**
* Add a new user to the list, but only if none of the existing users have
* the same username.
*
* @return true if the user has been added to the list, false otherwise.
*/
public synchronized boolean addUser(UserConfiguration user) {
if (user.getUsername() == null) {
return false;
}
for (UserConfiguration u : usersConfig.getUsers()) {
if (u.getUsername().equals(user.getUsername())) {
return false;
}
}
usersConfig.getUsers().add(user);
updateUsersConfigurationFile();
return true;
}
public synchronized boolean deleteUser(String username) {
Iterator<UserConfiguration> ite = usersConfig.getUsers().iterator();
while (ite.hasNext()) {
UserConfiguration userConfig = ite.next();
if (userConfig.getUsername().equals(username)) {
ite.remove();
updateUsersConfigurationFile();
return true;
}
}
return false;
}
/**
* Add a new UCD to the list, but only if the word has not already been
* entered.
*
* @return true if the UCD has been added to the list, false otherwise.
*/
public synchronized boolean addUCD(UCDConfiguration ucdConfig) {
for (UCDConfiguration ucd : ucdListConfig.getUCDList()) {
if (ucd.getWord().equals(ucdConfig.getWord())) {
return false;
}
}
ucdListConfig.getUCDList().add(ucdConfig);
updateUCDConfigurationFile();
return true;
}
/**
* @return true if the UCD has been deleted from the list, false otherwise.
*/
public synchronized boolean deleteUCD(UCDConfiguration ucdConfig) {
Iterator<UCDConfiguration> ite = ucdListConfig.getUCDList().iterator();
while (ite.hasNext()) {
UCDConfiguration ucd = ite.next();
if (ucd.getWord().equals(ucdConfig.getWord())) {
ite.remove();
updateUCDConfigurationFile();
return true;
}
}
return false;
}
public List<TapCredentials> getCredentials(String username) {
for (UserConfiguration user : usersConfig.getUsers()) {
if (user.getUsername().equals(username)) {
return Collections.unmodifiableList(user.getCredentialsInfo());
}
}
return null;
}
/**
* Add a new credentials to the list, but only if the credentials has not
* already been inserted.
*
* @return true if the credentials has been added to the list, false
* otherwise.
*/
public synchronized boolean addCredentials(String username, TapCredentials credentials) {
for (UserConfiguration user : usersConfig.getUsers()) {
if (user.getUsername().equals(username)) {
for (TapCredentials tapCredentials : user.getCredentialsInfo()) {
if (tapCredentials.equals(credentials)) {
return false;
}
}
user.getCredentialsInfo().add(credentials);
updateUsersConfigurationFile();
return false;
}
}
return false;
}
/**
* @return true if the credentials has been deleted from the list, false
* otherwise.
*/
public synchronized boolean deleteCredentials(String username, TapCredentials credentials) {
for (UserConfiguration user : usersConfig.getUsers()) {
if (user.getUsername().equals(username)) {
Iterator<TapCredentials> ite = user.getCredentialsInfo().iterator();
while (ite.hasNext()) {
TapCredentials tapCredentials = ite.next();
if (tapCredentials.equals(credentials)) {
ite.remove();
updateUsersConfigurationFile();
return true;
}
}
}
}
return false;
}
public String getRestPath() {
return FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath() + "/faces/rest";
}
public String getVersion() {
return Version.NUMBER;
}
}
......@@ -22,6 +22,7 @@
*/
package it.inaf.ia2.tsm.webapp;
import it.inaf.ia2.tsm.webapp.xmlconfig.SeparatedCredentials;
import it.inaf.ia2.tsm.datalayer.Credentials;
import it.inaf.ia2.tsm.datalayer.DBWrapper;
import java.io.IOException;
......@@ -52,7 +53,7 @@ public class CredentialsEditing implements Serializable {
private User user;
@Inject
private ConfigurationData config;
private ConfigurationManager config;
@Inject
private SchemaSelectionBean schemaSelectionBean;
......@@ -80,7 +81,7 @@ public class CredentialsEditing implements Serializable {
currentEditingRow = index;
}
public void editSeparateCredentials(SeparateCredentials sc, int index) {
public void editSeparateCredentials(SeparatedCredentials sc, int index) {
this.sourceCredentials = sc.getSourceCredentials();
this.tapSchemaCredentials = sc.getTapSchemaCredentials();
currentEditingRow = index;
......@@ -118,25 +119,25 @@ public class CredentialsEditing implements Serializable {
}
public void removeCredentials(int index) throws IOException {
getSavedCredentials().remove(index);
config.updateConfigurationFile();
// getSavedCredentials().remove(index);
// config.updateUsersConfigurationFile();
}
public void saveCredentialsEdited() throws IOException {
// If is editing existing, remove old for creating a new one
if (currentEditingRow < getSavedCredentials().size()) {
getSavedCredentials().remove(currentEditingRow);
}
if (separateCredentials) {
SeparateCredentials sc = new SeparateCredentials(sourceCredentials, tapSchemaCredentials);
getSavedCredentials().add(currentEditingRow, sc);
} else {
getSavedCredentials().add(currentEditingRow, sourceCredentials);
}
config.updateConfigurationFile();
//
// // If is editing existing, remove old for creating a new one
// if (currentEditingRow < getSavedCredentials().size()) {
// getSavedCredentials().remove(currentEditingRow);
// }
//
// if (separateCredentials) {
// SeparatedCredentials sc = new SeparatedCredentials(sourceCredentials, tapSchemaCredentials);
// getSavedCredentials().add(currentEditingRow, sc);
// } else {
// getSavedCredentials().add(currentEditingRow, sourceCredentials);
// }
//
// config.updateUsersConfigurationFile();
}
public boolean isSeparateCredentials() {
......
......@@ -17,7 +17,7 @@ import javax.inject.Named;
public class FirstSetup {
@Inject
ConfigurationData config;
ConfigurationManager config;
private String adminUsername;
private String adminPassword;
......
......@@ -38,7 +38,7 @@ import javax.inject.Named;
public class Login {
@Inject
private ConfigurationData config;
private ConfigurationManager config;
@Inject
private User user;
......@@ -62,7 +62,7 @@ public class Login {
}
public String login() {
for (UserConfiguration u : config.getData().getUsers()) {
for (UserConfiguration u : config.getUsersConfiguration()) {
if (u.getUsername().equals(username) && u.getPassword().equals(password)) {
user.login(u);
return "credentialsEditing.xhtml?faces-redirect=true";
......
......@@ -40,7 +40,10 @@ public class SearchUCDDialog implements Serializable {
private static final long serialVersionUID = -3503024742241865133L;
@Inject
User user;
private ConfigurationManager config;
@Inject
private User user;
private boolean manualInsertion;
......@@ -153,7 +156,7 @@ public class SearchUCDDialog implements Serializable {
if (UCDManualText == null || UCDManualText.isEmpty() || UCDManualText.trim().isEmpty()) {
parsedUCD = null;
} else {
parsedUCD = new ParsedUCD(UCDManualText, user.getUserConfiguration().getCustomUCDs());
parsedUCD = new ParsedUCD(UCDManualText, config.getUCDConfiguration());
}
}
......
......@@ -3,7 +3,6 @@ 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;
......@@ -22,7 +21,7 @@ public class UCDEditor implements Serializable {
private static final long serialVersionUID = -9117203239681234534L;
@Inject
private ConfigurationData config;
private ConfigurationManager config;
@Inject
private User user;
......@@ -30,20 +29,11 @@ public class UCDEditor implements Serializable {
private boolean viewExisting;
private UCDConfiguration newUCDConfiguration;
private String invalidUCDMessage;
private List<UCDConfiguration> customUCDs;
public void openDialog() {
viewExisting = true;
newUCDConfiguration = new UCDConfiguration();
newUCDConfiguration = new UCDConfiguration(user.getUsername());
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() {
......@@ -60,7 +50,14 @@ public class UCDEditor implements Serializable {
}
public List<UCDConfiguration> getCustomUCDs() {
return customUCDs;
return config.getUCDConfiguration();
}
public boolean isEditable(UCDConfiguration ucdConfig) {
if (user.isAdmin()) {
return true;
}
return ucdConfig.getCreator().equals(user.getUsername());
}
public void addUCD() throws IOException {
......@@ -78,15 +75,15 @@ public class UCDEditor implements Serializable {
invalidUCDMessage = "Invalid UCD word syntax";
return;
}
customUCDs.add(newUCDConfiguration);
newUCDConfiguration = new UCDConfiguration();
config.updateConfigurationFile();
//
// newUCDConfiguration = new UCDConfiguration(user.getUsername());
// if(config.addUCD(newUCDConfiguration)) {
// ne
// }
}
public void removeUCD(int index) throws IOException {
customUCDs.remove(index);
config.updateConfigurationFile();
public void removeUCD(UCDConfiguration ucd) {
config.deleteUCD(ucd);
}
/**
......
......@@ -41,7 +41,7 @@ public class User implements Serializable {
private static final long serialVersionUID = 1L;
@Inject
ConfigurationData config;
ConfigurationManager config;
private UserConfiguration userConfiguration;
......
......@@ -23,11 +23,8 @@
package it.inaf.ia2.tsm.webapp;
import it.inaf.ia2.tsm.webapp.xmlconfig.UserConfiguration;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.deltaspike.core.api.scope.WindowScoped;
......@@ -43,34 +40,41 @@ public class UsersEditing implements Serializable {
private static final long serialVersionUID = -8758568990541836689L;
@Inject
private ConfigurationData config;
private ConfigurationManager config;
private List<UserConfiguration> users;
@PostConstruct
public void init() {
users = new ArrayList<>();
}
private UserConfiguration newUser;
public String open() {
// Copying users list (to avoid issues caused by simultaneously changes)
users = config.cloneUsersConfiguration();
return "usersEditing.xhtml?faces-redirect=true";
}
public List<UserConfiguration> getUsers() {
return users;
return config.getUsersConfiguration();
}
public void save() throws IOException {
config.updateUsersList(users);
public void save() {
//config.updateUsersList(users);
}
public void createNewUser() {
newUser = new UserConfiguration();
}
public void addUser() {
users.add(new UserConfiguration());
if (newUser != null) {
config.addUser(newUser);
}
}
public void removeUser(UserConfiguration user) {
config.deleteUser(user.getUsername());
}
public UserConfiguration getNewUser() {
return newUser;
}
public void removeUser(int index) {
users.remove(index);
public void setNewUser(UserConfiguration newUser) {
this.newUser = newUser;
}
}
......@@ -22,8 +22,7 @@
*/
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.ConfigurationManager;
import it.inaf.ia2.tsm.webapp.xmlconfig.UserConfiguration;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
......@@ -39,12 +38,11 @@ import javax.inject.Named;
public class FirstSetupChecker {
@Inject
private ConfigurationData config;
private ConfigurationManager config;
public boolean isFirstSetupCompleted() {
Configuration c = config.getData();
for (UserConfiguration user : c.getUsers()) {
if ("admin".equals(user.getRole())) {
for (UserConfiguration userConfig : config.getUsersConfiguration()) {
if ("admin".equals(userConfig.getRole())) {
return true;
}
}
......
/*
* _____________________________________________________________________________
*
* 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.xmlconfig;
import it.inaf.ia2.tsm.datalayer.Credentials;
import java.util.Objects;
/**
*
* @author Sonia Zorba {@literal <zorba at oats.inaf.it>}
*/
public class JoinedCredentials extends TapCredentials {
private static final long serialVersionUID = 6683479851687703335L;
private Credentials credentials;
public JoinedCredentials() {
}
public JoinedCredentials(Credentials credentials) {
this.credentials = credentials;
}
public Credentials getCredentials() {
return credentials;
}
public void setCredentials(Credentials credentials) {
this.credentials = credentials;
}
@Override
public int hashCode() {
int hash = 7;
hash = 53 * hash + Objects.hashCode(this.credentials);
hash = 53 * hash + Objects.hashCode(this.getTapSchemaName());
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final JoinedCredentials other = (JoinedCredentials) obj;
if (!Objects.equals(this.credentials, other.credentials)) {
return false;
}
return Objects.equals(this.getTapSchemaName(), other.getTapSchemaName());
}
}
......@@ -20,27 +20,27 @@
* 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.datalayer.Credentials;
import java.io.Serializable;
import java.util.Objects;
import javax.xml.bind.annotation.XmlElement;
/**
*
* @author Sonia Zorba {@literal <zorba at oats.inaf.it>}
*/
public class SeparateCredentials implements Serializable {
public class SeparatedCredentials extends TapCredentials {
private static final long serialVersionUID = 2108950341601128938L;
private Credentials sourceCredentials;
private Credentials tapSchemaCredentials;
public SeparateCredentials() {
public SeparatedCredentials() {
}
public SeparateCredentials(Credentials sourceCredentials, Credentials tapSchemaCredentials) {
public SeparatedCredentials(Credentials sourceCredentials, Credentials tapSchemaCredentials) {
this.sourceCredentials = sourceCredentials;
this.tapSchemaCredentials = tapSchemaCredentials;
}
......@@ -62,4 +62,35 @@ public class SeparateCredentials implements Serializable {
public void setTapSchemaCredentials(Credentials tapSchemaCredentials) {
this.tapSchemaCredentials = tapSchemaCredentials;
}
@Override
public int hashCode() {
int hash = 7;
hash = 53 * hash + Objects.hashCode(this.sourceCredentials);
hash = 53 * hash + Objects.hashCode(this.tapSchemaCredentials);
hash = 53 * hash + Objects.hashCode(this.getTapSchemaName());
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final SeparatedCredentials other = (SeparatedCredentials) obj;
if (!Objects.equals(this.sourceCredentials, other.getSourceCredentials())) {
return false;
}
if (!Objects.equals(this.tapSchemaCredentials, other.getTapSchemaCredentials())) {
return false;
}
return Objects.equals(this.getTapSchemaName(), other.getTapSchemaName());
}
}
/*
* _____________________________________________________________________________
*
* 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.xmlconfig;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlElement;
/**
*
* @author Sonia Zorba {@literal <zorba at oats.inaf.it>}
*/
public abstract class TapCredentials implements Serializable {
private static final long serialVersionUID = -3736612935129057338L;
private String tapSchemaName;
private String tapSchemaVersion;
private boolean hasObscore;
@XmlElement(name = "tap_schema_name")
public String getTapSchemaName() {
return tapSchemaName;
}
public void setTapSchemaName(String tapSchemaName) {
this.tapSchemaName = tapSchemaName;
}
@XmlElement(name = "tap_schema_version")
public String getTapSchemaVersion() {
return tapSchemaVersion;
}
public void setTapSchemaVersion(String tapSchemaVersion) {
this.tapSchemaVersion = tapSchemaVersion;
}
@XmlElement(name = "obscore")
public boolean isHasObscore() {
return hasObscore;
}
public void setHasObscore(boolean hasObscore) {
this.hasObscore = hasObscore;
}
}
......@@ -24,6 +24,7 @@ package it.inaf.ia2.tsm.webapp.xmlconfig;
import ari.ucidy.UCDSyntax;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
/**
......@@ -38,11 +39,17 @@ public class UCDConfiguration implements Serializable {
private UCDSyntax syntax;
private String word;
private String description;
private String creator;
public UCDConfiguration() {
private UCDConfiguration() {
syntax = UCDSyntax.BOTH;
}
public UCDConfiguration(String creator) {
this();
this.creator = creator;
}
@XmlElement(name = "code")
public UCDSyntax getSyntax() {
return syntax;
......@@ -73,6 +80,19 @@ public class UCDConfiguration implements Serializable {
this.description = description;
}
/**
* The user that created the UCD. This is used to assign delete privilege on
* the UCD.
*/
@XmlAttribute(name = "creator")
public String getCreator() {
return creator;
}
public void setCreator(String creator) {
this.creator = creator;
}
public String getCode() {
switch (syntax) {
case PRIMARY:
......
/*
* _____________________________________________________________________________
*
* 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.xmlconfig;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Sonia Zorba {@literal <zorba at oats.inaf.it>}
*/
@XmlRootElement(name = "ucd-configuration")
public class UCDListConfiguration implements Serializable {
private static final long serialVersionUID = -751858966136122647L;
private final List<UCDConfiguration> ucdConfigs;
public UCDListConfiguration() {
ucdConfigs = new ArrayList<>();
}
@XmlElements({
@XmlElement(name = "ucd")
})
public List<UCDConfiguration> getUCDList() {
return ucdConfigs;
}
}
......@@ -22,8 +22,6 @@
*/
package it.inaf.ia2.tsm.webapp.xmlconfig;
import it.inaf.ia2.tsm.datalayer.Credentials;
import it.inaf.ia2.tsm.webapp.SeparateCredentials;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
......@@ -43,12 +41,10 @@ public class UserConfiguration implements Serializable {
private String role;
private String username;
private String password;
private final List<UCDConfiguration> customUCDs;
private final List<Object> credentialsInfo;
private final List<TapCredentials> credentialsInfo;
public UserConfiguration() {
credentialsInfo = new ArrayList<>();
customUCDs = new ArrayList<>();
}
@XmlAttribute(name = "username")
......@@ -69,11 +65,11 @@ public class UserConfiguration implements Serializable {
this.password = password;
}
public void addCredentials(Credentials credentials) {
public void addCredentials(JoinedCredentials credentials) {
credentialsInfo.add(credentials);
}
public void addSeparateCredentials(SeparateCredentials separateCredentials) {
public void addSeparateCredentials(SeparatedCredentials separateCredentials) {
credentialsInfo.add(separateCredentials);
}
......@@ -88,17 +84,11 @@ public class UserConfiguration implements Serializable {
@XmlElementWrapper(name = "credentials-configuration")
@XmlElements({
@XmlElement(name = "credentials", type = Credentials.class)
@XmlElement(name = "credentials", type = JoinedCredentials.class)
,
@XmlElement(name = "separate-credentials", type = SeparateCredentials.class)
@XmlElement(name = "separated-credentials", type = SeparatedCredentials.class)
})
public List<Object> getCredentialsInfo() {
public List<TapCredentials> getCredentialsInfo() {
return credentialsInfo;
}
@XmlElementWrapper(name = "ucd-list")
@XmlElement(name = "ucd")
public List<UCDConfiguration> getCustomUCDs() {
return customUCDs;
}
}
......@@ -22,11 +22,9 @@
*/
package it.inaf.ia2.tsm.webapp.xmlconfig;
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;
......@@ -36,16 +34,14 @@ import javax.xml.bind.annotation.XmlRootElement;
*
* @author Sonia Zorba {@literal <zorba at oats.inaf.it>}
*/
@XmlRootElement(name = "configuration")
public class Configuration implements Serializable {
@XmlRootElement(name = "users-configuration")
public class UsersConfiguration implements Serializable {
private static final long serialVersionUID = 5424034991075602177L;
private final String version;
private final List<UserConfiguration> users;
public Configuration() {
version = Version.NUMBER;
public UsersConfiguration() {
users = new ArrayList<>();
}
......@@ -55,9 +51,4 @@ public class Configuration implements Serializable {
public List<UserConfiguration> getUsers() {
return users;
}
@XmlAttribute(name = "version")
public String getVersion() {
return version;
}
}
ucd_service_url=http://ia2-vo.oats.inaf.it/ucd/
config_file_path=/home/sonia/.tsm/config.xml
\ No newline at end of file
config_directory=/home/sonia/.tasman
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment