Commit 80fcb0a6 authored by Danilo K. S. Yorinori's avatar Danilo K. S. Yorinori Committed by Rubens Suguimoto

Webservice server implementation and version file

First commmit of server implementation. Contains:
- Seed2.jws: server code
- version: plain text file with the lastest client version
- README: where to get informations
- AUTHORS: authors information
- COPYING: copyright information
- ChangeLog: changes information
- NEWS: new features and others news
- TODO: features and others things to do
- INSTALL: installation support
Signed-off-by: default avatarDanilo K. S. Yorinori <danilok@c3sl.ufpr.br>
Signed-off-by: default avatarRubens Suguimoto <rums04@inf.ufpr.br>
parent 006957f0
# SEED2 SERVER
C3SL - Centro de Computacao Cientifica e Software Livre
Agtha Cristina de Nadai
Bruno Cesar Ribas
Carlos Carvalho
Daniel Weingaertner
Danilo Kiyoshi Simizu Yorinori
Diego Giovane Pasqualin
Edson Ramiro Lucas Filho
Eduardo Cunha de Almeida
Erik Alexandre Pucci
Fabiano Silva
Jorge Augusto Meira
Josiney de Souza
Juliana Bueno
Lucio Foltran da Silva
Luis Carlos Erpen de Bona
Marcos Castilho
Renan Franca De Miranda
Ricardo Tavares De Oliveira
Rubens Massayuki Suguimoto
Thiago Henrique Dos Santos Picharski
Tiago Rodrigo Kepe
Vinicius Kwiecien Ruoso
This diff is collapsed.
SEED2 SERVER ChangeLog
v1.0.0:
- initial release
Installation Steps
==================
Dependecies:
apache-tomcat-6.0.20
axis-1_4
Before installation, be sure you have installed the postgresql-*.jar
(http://jdbc.postgresql.org/download.html) at $CATALINA_HOME/lib
After move Seed2.jws file to $AXIS_HOME/webapps/axis/, copy the version file to
the same directory and write full path to it in Seed2.jws (line 178).
README
======
########################################################
# SEED2 SERVER
########################################################
SEED2 SERVER provides services for validation,
availabitity and version.
For installation support read "INSTALL".
For changes read "ChangeLog".
For new features and other news read "NEWS".
For credits read "AUTHORS".
For copyright information read "COPYING".
/* Copyright (C) 2004-2009 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
*
* This file is part of server
*
* collect-agent is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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. */
/* General libs */
import java.util.*;
import java.text.*;
/* Database libs */
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
import java.sql.Timestamp;
import org.postgresql.Driver;
/* File libs */
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class Seed2 {
/**
* Return a string after the insertion of <Inep, MacAddr, Timestamp> into
* database.
*
* @author Danilo Kiyoshi Simizu Yorinori
* @param inep School's INEP number
* @param macAddr Client's Mac Address string
* @return String
*/
public static String availability(String inep, String macAddr)
throws Exception {
/* Get server time with timestamp format */
Date date = new Date();
long dateMilisecs = date.getTime();
Timestamp dateTimestamp = new Timestamp(dateMilisecs);
/* Insert into database */
try {
/* DB data */
String host = "localhost";
String port = "5432";
String schema = "seed";
String user = "seed";
String passwd = "brd";
String table = "tb_seed_disp";
/* Control variable */
int insert = -1;
Driver.class.newInstance();
/* Database connection */
try {
Connection c = DriverManager.getConnection("jdbc:postgresql://" +
host + ":" + port + "/" + schema, user, passwd);
Statement s = c.createStatement();
try {
insert = s.executeUpdate("INSERT INTO " + table +
" (inep, mac, data) VALUES (" + inep + ",'" +
macAddr + "','" + dateTimestamp + "')");
s.close(); /* Close statement */
c.close(); /* Close database connection */
/* insert will be greater than 0 if some line was inserted
into database */
if (insert > 0) {
return "Success";
}
else {
return "Error";
}
}
catch (SQLException e) {
return e.getMessage();
}
}
catch (SQLException e) {
return e.getMessage();
}
}
catch(Exception e) {
return e.getMessage();
}
}
/**
* Return a boolean value after verification of Inep's number existence in
* database.
*
* @author Danilo Kiyoshi Simizu Yorinori
* @param inep School's INEP number
* @return Boolean
*/
public static Boolean IDverification(String inep)
throws Exception {
try {
/* DB data */
String host = "localhost";
String port = "5432";
String schema = "seed";
String user = "seed";
String passwd = "brd";
String table = "tb_seed_escola";
Driver.class.newInstance();
Boolean find = false; /* Default value */
/* Database connection */
try {
Connection c = DriverManager.getConnection("jdbc:postgresql://" +
host + ":" + port + "/" + schema, user, passwd);
Statement s = c.createStatement();
try {
ResultSet rs = s.executeQuery("SELECT * FROM " + table
+ " WHERE inep=" + inep);
/* Verify if query result is not empty */
if (rs.next() == true) {
find = true; /* Change return value */
}
rs.close(); /* Close result set */
s.close(); /* Close statement */
c.close(); /* Close database connection */
return find;
}
catch (SQLException e) {
return false;
}
}
catch (SQLException e) {
return false;
}
}
catch(Exception e) {
return false;
}
}
/**
* Return a string with client/server version.
*
* @author Danilo Kiyoshi Simizu Yorinori
* @return String
*/
public static String agentVersion()
throws Exception {
try {
/* Version file path */
String versionFile = "/home/seed2/lib/axis/webapps/axis/version";
/* Verify file existence and open it if exists */
File file = new File(versionFile);
if (! file.exists()) {
return "Version file not found";
}
try {
/* Read file */
BufferedReader br = new BufferedReader(new FileReader
(versionFile));
StringBuffer bufOutput = new StringBuffer();
/* Read lines of file */
String line;
while( (line = br.readLine()) != null ) {
bufOutput.append(line);
}
br.close(); /* Close buffer */
return bufOutput.toString(); /* Return version string */
}
catch (Exception e) {
return e.getMessage();
}
}
catch (Exception e) {
return e.getMessage();
}
}
/**
* Return a string after insert inventory into database.
* PROTOTYPE
*
* @author Danilo Kiyoshi Simizu Yorinori
* @param xmlInventory XML string with inventory
* @return String
*
public static string inventario(String xmlInventory) {
return xmlInventory;
}
*/
}
- Store inventory
- Check bugs
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment