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

Little fixes, set version to 1.3.0, added installer for tasman-embedded

parent 243decdb
Branches
Tags
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>it.inaf.ia2.tap</groupId> <groupId>it.inaf.ia2.tap</groupId>
<artifactId>tasman-core</artifactId> <artifactId>tasman-core</artifactId>
<version>1.2.0</version> <version>1.3.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>tasman-core</name> <name>tasman-core</name>
<properties> <properties>
......
...@@ -59,13 +59,6 @@ public class EntityProperty<T> implements Serializable { ...@@ -59,13 +59,6 @@ public class EntityProperty<T> implements Serializable {
return value; return value;
} }
/**
* Retrieve the current value.
*/
public <X> X getValue(Class<X> type) {
return (X) value;
}
public T getOriginalValue() { public T getOriginalValue() {
return originalValue; return originalValue;
} }
...@@ -74,10 +67,6 @@ public class EntityProperty<T> implements Serializable { ...@@ -74,10 +67,6 @@ public class EntityProperty<T> implements Serializable {
return defaultValue; return defaultValue;
} }
public <X> X getOriginalValue(Class<X> type) {
return (X) originalValue;
}
public <X> void setValue(X value) { public <X> void setValue(X value) {
this.setValue(value, true); this.setValue(value, true);
} }
......
...@@ -130,7 +130,7 @@ public abstract class TapSchemaEntity implements Serializable { ...@@ -130,7 +130,7 @@ public abstract class TapSchemaEntity implements Serializable {
* Retrieve the current value of the property (the last value set). * Retrieve the current value of the property (the last value set).
*/ */
public <T> T getValue(String key, Class<T> type) { public <T> T getValue(String key, Class<T> type) {
return (T) properties.get(key).getValue(type); return (T) properties.get(key).getValue();
} }
public void setValue(String key, Object value) { public void setValue(String key, Object value) {
...@@ -145,7 +145,7 @@ public abstract class TapSchemaEntity implements Serializable { ...@@ -145,7 +145,7 @@ public abstract class TapSchemaEntity implements Serializable {
* @return * @return
*/ */
public <T> T getOriginalValue(String key, Class<T> type) { public <T> T getOriginalValue(String key, Class<T> type) {
return (T) properties.get(key).getOriginalValue(type); return (T) properties.get(key).getOriginalValue();
} }
/** /**
......
...@@ -275,6 +275,9 @@ public class PostgresDBBroker extends DBBrokerTemplate { ...@@ -275,6 +275,9 @@ public class PostgresDBBroker extends DBBrokerTemplate {
if (!isArray && (ADQL.VARCHAR.equals(adqlType) || ADQL.CHAR.equals(adqlType))) { if (!isArray && (ADQL.VARCHAR.equals(adqlType) || ADQL.CHAR.equals(adqlType))) {
size = resultSet.getInt("character_maximum_length"); size = resultSet.getInt("character_maximum_length");
if (size == 0) {
size = null;
}
} }
cm.put(Column.DATATYPE_KEY, datatype); cm.put(Column.DATATYPE_KEY, datatype);
...@@ -283,10 +286,16 @@ public class PostgresDBBroker extends DBBrokerTemplate { ...@@ -283,10 +286,16 @@ public class PostgresDBBroker extends DBBrokerTemplate {
String arraySize = null; String arraySize = null;
if (isArray) { if (isArray) {
arraySize = formatArraySize(arraydimension); arraySize = formatArraySize(arraydimension);
} else if (size != null) { } else {
if (size != null) {
arraySize = String.valueOf(size); arraySize = String.valueOf(size);
}
// variable length columns must have a "*" symbol on arraysize // variable length columns must have a "*" symbol on arraysize
if (adqlType != null && ADQL.isVariable(adqlType)) { if (adqlType != null && ADQL.isVariable(adqlType)) {
if (arraySize == null) {
arraySize = "";
}
arraySize += "*"; arraySize += "*";
} }
} }
......
...@@ -655,7 +655,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ...@@ -655,7 +655,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<type>VARCHAR</type> <type>VARCHAR</type>
<updatable>true</updatable> <updatable>true</updatable>
<description>Identifier of proposal to which observation belongs</description> <description>Identifier of proposal to which observation belongs</description>
<standard>false</standard> <standard>true</standard>
<mandatory>true</mandatory> <mandatory>true</mandatory>
<utype>Provenance.Proposal.identifier</utype> <utype>Provenance.Proposal.identifier</utype>
<ucd>meta.id; obs.proposal</ucd> <ucd>meta.id; obs.proposal</ucd>
......
...@@ -459,6 +459,14 @@ public class TestAll { ...@@ -459,6 +459,14 @@ public class TestAll {
operations = new UpdateOperations(tapSchema); operations = new UpdateOperations(tapSchema);
assertFalse(operations.getHasOperations()); assertFalse(operations.getHasOperations());
// Checking size and arraysize detection
Column descriptionColumn = tapSchema.getChild(tapSchema.getName()).getChild("columns").getChild("utype");
assertEquals("char", descriptionColumn.getValue("datatype", String.class));
Integer size = descriptionColumn.getValue("size", Integer.class);
String arraySize = descriptionColumn.getValue("arraysize", String.class);
assertTrue(size == null || size == 255); // null -> Postgres, 255 -> MySQL
assertTrue("*".equals(arraySize) || "255*".equals(arraySize)); // * -> Postgres, 255* -> MySQL
// reloading // reloading
LOG.debug("----- Reloading saved TAP_SCHEMA -----"); LOG.debug("----- Reloading saved TAP_SCHEMA -----");
tapSchema = new TapSchema(dbWrapper, settings, true); tapSchema = new TapSchema(dbWrapper, settings, true);
......
package it.inaf.ia2.tap.tasman; package it.inaf.ia2.tap.tasman;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;
import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener; import javax.servlet.ServletContextListener;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
...@@ -14,14 +18,26 @@ import org.eclipse.jetty.webapp.WebAppContext; ...@@ -14,14 +18,26 @@ import org.eclipse.jetty.webapp.WebAppContext;
*/ */
public class Main { public class Main {
private static final int DEFAULT_PORT = 8080;
/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
int port = DEFAULT_PORT; Properties props = new Properties();
try (InputStream in = Main.class.getClassLoader().getResourceAsStream("app.properties")) {
props.load(in);
}
// Printing the header
try (BufferedReader br = new BufferedReader(new InputStreamReader(Main.class.getClassLoader().getResourceAsStream("header.txt")))) {
for (String line; (line = br.readLine()) != null;) {
System.out.println(line);
}
} catch (Exception e) {
}
int port = Integer.parseInt(props.getProperty("defaultPort").trim());
String warFilePath = props.getProperty("warFilePath").trim();
if (args.length == 1) { if (args.length == 1) {
try { try {
...@@ -40,7 +56,7 @@ public class Main { ...@@ -40,7 +56,7 @@ public class Main {
WebAppContext webapp = new WebAppContext(); WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/"); webapp.setContextPath("/");
File warFile = new File("/home/sonia/git/TASMAN/TASMAN-webapp/target/tasman-webapp-1.2.0.war"); File warFile = new File(warFilePath);
webapp.setWar(warFile.getAbsolutePath()); webapp.setWar(warFile.getAbsolutePath());
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=477705 // https://bugs.eclipse.org/bugs/show_bug.cgi?id=477705
...@@ -53,7 +69,10 @@ public class Main { ...@@ -53,7 +69,10 @@ public class Main {
webapp.addEventListener(new ServletContextListener() { webapp.addEventListener(new ServletContextListener() {
@Override @Override
public void contextInitialized(ServletContextEvent sce) { public void contextInitialized(ServletContextEvent sce) {
System.out.println("TASMAN initialized. Visit http://localhost:" + serverPort); String message = "# TASMAN initialized. Visit http://localhost:" + serverPort + " #";
printBorder(message);
System.out.println(message);
printBorder(message);
} }
@Override @Override
...@@ -68,4 +87,11 @@ public class Main { ...@@ -68,4 +87,11 @@ public class Main {
// wait until the server is done executing. // wait until the server is done executing.
server.join(); server.join();
} }
private static void printBorder(String text) {
for (int i = 0; i < text.length(); i++) {
System.out.print("#");
}
System.out.println();
}
} }
warFilePath=/home/sonia/git/TASMAN/TASMAN-webapp/target/tasman-webapp-1.3.0.war
defaultPort=8080
\ No newline at end of file
############################################
# _____ _ ____ __ __ _ _ _ #
# |_ _|/ \ / ___|| \/ | / \ | \ | | #
# | | / _ \ \___ \| |\/| | / _ \ | \| | #
# | |/ ___ \ ___) | | | |/ ___ \| |\ | #
# |_/_/ \_\____/|_| |_/_/ \_\_| \_| #
# #
# Powered by IA2 #
# #
############################################
\ No newline at end of file
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<groupId>it.inaf.ia2.tap</groupId> <groupId>it.inaf.ia2.tap</groupId>
<artifactId>tasman-webapp</artifactId> <artifactId>tasman-webapp</artifactId>
<version>1.2.0</version> <version>1.3.0</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>tasman-webapp</name> <name>tasman-webapp</name>
......
#!/bin/bash
echo "############################################"
echo "# _____ _ ____ __ __ _ _ _ #"
echo "# |_ _|/ \ / ___|| \/ | / \ | \ | | #"
echo "# | | / _ \ \___ \| |\/| | / _ \ | \| | #"
echo "# | |/ ___ \ ___) | | | |/ ___ \| |\ | #"
echo "# |_/_/ \_\____/|_| |_/_/ \_\_| \_| #"
echo "# #"
echo "# Powered by IA2 #"
echo "# #"
echo "############################################"
echo ""
echo "Welcome on the TASMAN installer"
# Run as root check
if [[ "$(id -u)" != "0" ]]; then
echo "** This script must be run as root **" 1>&2
exit 1
fi
# Default port
echo -e "Specify default port for TASMAN (you can change it runtime) [8080]: \c"
read default_port
if [[ -z "$default_port" ]]; then
default_port=8080
fi
if [[ ! "$default_port" =~ ^-?[0-9]+$ ]]; then
echo "Port must be a number"
exit 1
fi
if [[ "$default_port" -lt "1024" ]]; then
echo "Please choose a port number bigger than 1023 (TASMAN will be launched by a non-root user)"
exit 1
fi
# Tasman installation dir
echo -e "Specify TASMAN installation directory [/opt/tasman]: \c"
read install_dir
if [[ -z "$install_dir" ]]; then
install_dir="/opt/tasman"
fi
# UCD service URL
echo -e "Specify UCD service URL [http://ia2-vo.oats.inaf.it/ucd/]: \c"
read ucd_service_url
if [[ -z "$ucd_service_url" ]]; then
ucd_service_url="http://ia2-vo.oats.inaf.it/ucd/"
fi
# TASMAN configuration directory
echo -e "Specify TASMAN configuration directory [/etc/tasman]: \c"
read tasman_config_dir
if [[ -z "$tasman_config_dir" ]]; then
tasman_config_dir="/etc/tasman"
fi
mkdir -p "$tasman_config_dir"
if [ ! $? -eq 0 ]; then
echo "Unable to create configuration directory $tasman_config_dir"
exit 1
fi
# Creating tasman user if it is necessary
#if [[ ! $(getent passwd tasman) ]]; then
# useradd -r tasman
#fi
# Creating installation directory
mkdir -p "$install_dir"
if [ ! $? -eq 0 ]; then
echo "Unable to create installation directory $install_dir"
exit 1
fi
# Add final slash to installation dir if it is necessary
if [[ "$install_dir" != *\/ ]]; then
install_dir="$install_dir/"
fi
# Copying files
cp data/tasman-embedded.jar "$install_dir"
cp data/tasman-webapp.war "$install_dir"
cd $install_dir
# Configuring tasman-embedded
echo "warFilePath=$install_dir""tasman-webapp.war" > app.properties
echo "defaultPort=$default_port" >> app.properties
jar uf tasman-embedded.jar app.properties
rm app.properties
# Configuring tasman-webapp
echo "ucd_service_url=$ucd_service_url" > webapp.properties
echo "config_directory=$tasman_config_dir" >> webapp.properties
mkdir -p WEB-INF/classes
mv webapp.properties WEB-INF/classes
jar uf tasman-webapp.war WEB-INF/classes/webapp.properties
rm -Rf WEB-INF
cd - 1> /dev/null
# Creating executable
tasman_bin="$install_dir""tasman"
echo "#!/bin/bash" > $tasman_bin
echo "java -jar $install_dir""tasman-embedded.jar" >> $tasman_bin
chmod +x $tasman_bin
# Creating executable symbolic link
ln -s $tasman_bin /usr/bin/tasman
# Setting permissions
chmod -R 777 $tasman_config_dir
echo "######################################"
echo "# TASMAN installation completed! :-) #"
echo "######################################"
echo "Notice that $tasman_config_dir has 777 permissions. If you are planning to use TASMAN only with a specific user you may want to restrict permissions on that folder."
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment