Subversion Repositories bacoAlunos

Compare Revisions

Ignore whitespace Rev 1007 → Rev 1008

/impl/conf/app.properties
114,6 → 114,8
 
//seconds
ftp.timeout.seconds=10
 
ftp.data.store.timeout.seconds=60
##################################################
##Proxy Servers
#If is an HTTP Server needs encoding config if FTP needs user pass config
/impl/src/java/pt/estgp/estgweb/Globals.java
80,6 → 80,7
 
 
public static final int FTP_TIMEOUT_SECONDS = ConfigProperties.getIntProperty("ftp.timeout.seconds");
public static final int FTP_DATA_STORE_TIMEOUT_SECONDS = ConfigProperties.getIntProperty("ftp.data.store.timeout.seconds");
 
public static final boolean USE_TOP_FLASH_NEWS = ConfigProperties.getBooleanProperty("announcements.use.top.flash.news");
 
/impl/src/java/pt/estgp/estgweb/web/FtpServer.java
4,6 → 4,7
import org.apache.log4j.Logger;
 
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
45,7 → 46,7
private static final int FTP_TIMEOUT_SECONDS = pt.estgp.estgweb.Globals.FTP_TIMEOUT_SECONDS;
public FTPClient getClient() throws IOException
{
final FTPClient ftp = new FTPClient();
final FTPClient ftp = new MyFTPClient();
logger.info("CONNECTING... waiting " + FTP_TIMEOUT_SECONDS + " seconds");
Thread t = new Thread(new Runnable() {
@Override
191,5 → 192,50
return null;
}
 
public static final int FTP_DATA_STORE_TIMEOUT_SECONDS = pt.estgp.estgweb.Globals.FTP_DATA_STORE_TIMEOUT_SECONDS;
public class MyFTPClient extends FTPClient implements Runnable
{
String remote = "";
InputStream local = null;
boolean storeResult = false;
 
public void run() {
try {
storeResult = super.storeFile(remote, local);
} catch (IOException e) {
logger.error(e,e);
}
}
@Override
public boolean storeFile(String remote, InputStream local) throws IOException
{
this.remote = remote;
this.local = local;
Thread t = new Thread(this);
t.start();
try {
for(int i=0;i<FTP_DATA_STORE_TIMEOUT_SECONDS;i++)
{
Thread.sleep(1000);
if(!t.isAlive())
{
if(this.isConnected())
break;
}
}
if(!this.isConnected())
{
logger.info("Not Connected will interrupt");
t.interrupt();
return false;
}
} catch (InterruptedException e) {
logger.error(e,e);
}
return storeResult;
}
}
 
 
 
}