Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
Correct database/data InitObject()
Browse files Browse the repository at this point in the history
  • Loading branch information
marakiis authored and fredericBregier committed Jul 22, 2019
1 parent 7a3f9bd commit a6fc529
Show file tree
Hide file tree
Showing 79 changed files with 2,394 additions and 1,401 deletions.
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>WaarpR66</artifactId>
<name>Waarp OpenR66</name>
<version>3.1.0</version>
<version>3.1.1</version>
<description>
OpenR66 is a File Transfer Monitor to be used in real production to transfer files between servers.
It allows to start/restart a transfer, check the remote MD5, check status, make pre or post
Expand Down Expand Up @@ -75,7 +75,7 @@
<dependency>
<groupId>Waarp</groupId>
<artifactId>WaarpCommon</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
<exclusions>
<exclusion>
<artifactId>xml-apis</artifactId>
Expand Down Expand Up @@ -115,13 +115,13 @@
<dependency>
<groupId>Waarp</groupId>
<artifactId>WaarpExec</artifactId>
<version>3.0.5</version>
<version>3.1.0</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>Waarp</groupId>
<artifactId>WaarpSnmp</artifactId>
<version>3.0.7</version>
<version>3.1.0</version>
<optional>true</optional>
</dependency>
<dependency>
Expand All @@ -137,7 +137,7 @@
<dependency>
<groupId>Waarp</groupId>
<artifactId>WaarpThrift</artifactId>
<version>3.0.7</version>
<version>3.1.0</version>
<optional>true</optional>
</dependency>
<dependency>
Expand Down Expand Up @@ -167,12 +167,12 @@
<dependency>
<groupId>Waarp</groupId>
<artifactId>WaarpGatewayKernel</artifactId>
<version>3.1.0</version>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>Waarp</groupId>
<artifactId>WaarpFtpClient</artifactId>
<version>3.0.7</version>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down
74 changes: 74 additions & 0 deletions src/main/java/org/waarp/openr66/client/AbstractTransfer.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.waarp.common.command.exception.CommandAbstractException;
import org.waarp.common.database.data.AbstractDbData.UpdatedInfo;
Expand All @@ -34,6 +36,7 @@
import org.waarp.openr66.context.ErrorCode;
import org.waarp.openr66.context.R66Result;
import org.waarp.openr66.context.R66Session;
import org.waarp.openr66.context.filesystem.R66Dir;
import org.waarp.openr66.context.filesystem.R66File;
import org.waarp.openr66.context.task.exception.OpenR66RunnerErrorException;
import org.waarp.openr66.database.DbConstant;
Expand All @@ -43,7 +46,10 @@
import org.waarp.openr66.protocol.configuration.Messages;
import org.waarp.openr66.protocol.configuration.PartnerConfiguration;
import org.waarp.openr66.protocol.exception.OpenR66DatabaseGlobalException;
import org.waarp.openr66.protocol.localhandler.packet.InformationPacket;
import org.waarp.openr66.protocol.localhandler.packet.RequestPacket;
import org.waarp.openr66.protocol.localhandler.packet.ValidPacket;
import org.waarp.openr66.protocol.networkhandler.NetworkTransaction;
import org.waarp.openr66.protocol.utils.FileUtils;
import org.waarp.openr66.protocol.utils.R66Future;

Expand Down Expand Up @@ -340,4 +346,72 @@ protected void finalizeInErrorTransferRequest(ClientRunner runner, DbTaskRunner
runner.changeUpdatedInfo(UpdatedInfo.INERROR, code, true);
}
}


public List<String> getRemoteFiles(DbRule dbrule, String[] localfilenames, String requested,
NetworkTransaction networkTransaction) {
List<String> files = new ArrayList<String>();
for (String filename : localfilenames) {
if (!(filename.contains("*") || filename.contains("?") || filename.contains("~"))) {
files.add(filename);
} else {
// remote query
R66Future futureInfo = new R66Future(true);
logger.info(Messages.getString("Transfer.3") + filename + " to " + requested); //$NON-NLS-1$
RequestInformation info = new RequestInformation(
futureInfo, requested, rulename, filename,
(byte) InformationPacket.ASKENUM.ASKLIST.ordinal(), -1, false, networkTransaction);
info.run();
futureInfo.awaitUninterruptibly();
if (futureInfo.isSuccess()) {
ValidPacket valid = (ValidPacket) futureInfo.getResult().getOther();
if (valid != null) {
String line = valid.getSheader();
String[] lines = line.split("\n");
for (String string : lines) {
File tmpFile = new File(string);
files.add(tmpFile.getPath());
}
}
} else {
logger.error(Messages.getString("Transfer.6") + filename + " to " + requested + ": " +
(futureInfo.getCause() == null ? "" : futureInfo.getCause().getMessage())); //$NON-NLS-1$
}
}
}
return files;
}

public List<String> getLocalFiles(DbRule dbrule, String[] localfilenames) {
List<String> files = new ArrayList<String>();
R66Session session = new R66Session();
session.getAuth().specialNoSessionAuth(false, Configuration.configuration.getHOST_ID());
R66Dir dir = new R66Dir(session);
try {
dir.changeDirectory(dbrule.getSendPath());
} catch (CommandAbstractException e) {
}
if (localfilenames != null) {
for (String filename : localfilenames) {
if (!(filename.contains("*") || filename.contains("?") || filename.contains("~"))) {
logger.info("Direct add: " + filename);
files.add(filename);
} else {
// local: must check
logger.info("Local Ask for " + filename + " from " + dir.getFullPath());
List<String> list;
try {
list = dir.list(filename);
if (list != null) {
files.addAll(list);
}
} catch (CommandAbstractException e) {
logger.warn(Messages.getString("Transfer.14") + filename + " : " + e.getMessage()); //$NON-NLS-1$
}
}
}
}
return files;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
*/
package org.waarp.openr66.client;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.waarp.common.command.exception.CommandAbstractException;
import org.waarp.common.database.exception.WaarpDatabaseException;
import org.waarp.common.logging.WaarpLoggerFactory;
import org.waarp.common.logging.WaarpSlf4JLoggerFactory;
Expand All @@ -30,14 +28,10 @@
import org.waarp.openr66.client.utils.OutputFormat.FIELDS;
import org.waarp.openr66.context.ErrorCode;
import org.waarp.openr66.context.R66Result;
import org.waarp.openr66.context.R66Session;
import org.waarp.openr66.context.filesystem.R66Dir;
import org.waarp.openr66.database.DbConstant;
import org.waarp.openr66.database.data.DbRule;
import org.waarp.openr66.protocol.configuration.Configuration;
import org.waarp.openr66.protocol.configuration.Messages;
import org.waarp.openr66.protocol.localhandler.packet.InformationPacket;
import org.waarp.openr66.protocol.localhandler.packet.ValidPacket;
import org.waarp.openr66.protocol.networkhandler.NetworkTransaction;
import org.waarp.openr66.protocol.utils.ChannelUtils;
import org.waarp.openr66.protocol.utils.R66Future;
Expand Down Expand Up @@ -72,71 +66,6 @@ public MultipleDirectTransfer(R66Future future, String remoteHost,
super(future, remoteHost, filename, rulename, fileinfo, isMD5, blocksize, id, networkTransaction);
}

public static List<String> getRemoteFiles(DbRule dbrule, String[] localfilenames, String requested,
NetworkTransaction networkTransaction) {
List<String> files = new ArrayList<String>();
for (String filename : localfilenames) {
if (!(filename.contains("*") || filename.contains("?") || filename.contains("~"))) {
files.add(filename);
} else {
// remote query
R66Future futureInfo = new R66Future(true);
logger.info(Messages.getString("Transfer.3") + filename + " to " + requested); //$NON-NLS-1$
RequestInformation info = new RequestInformation(futureInfo, requested, rule, filename,
(byte) InformationPacket.ASKENUM.ASKLIST.ordinal(), -1, false, networkTransaction);
info.run();
futureInfo.awaitUninterruptibly();
if (futureInfo.isSuccess()) {
ValidPacket valid = (ValidPacket) futureInfo.getResult().getOther();
if (valid != null) {
String line = valid.getSheader();
String[] lines = line.split("\n");
for (String string : lines) {
File tmpFile = new File(string);
files.add(tmpFile.getPath());
}
}
} else {
logger.error(Messages.getString("Transfer.6") + filename + " to " + requested + ": " +
(futureInfo.getCause() == null ? "" : futureInfo.getCause().getMessage())); //$NON-NLS-1$
}
}
}
return files;
}

public static List<String> getLocalFiles(DbRule dbrule, String[] localfilenames) {
List<String> files = new ArrayList<String>();
R66Session session = new R66Session();
session.getAuth().specialNoSessionAuth(false, Configuration.configuration.getHOST_ID());
R66Dir dir = new R66Dir(session);
try {
dir.changeDirectory(dbrule.getSendPath());
} catch (CommandAbstractException e) {
}
if (localfilenames != null) {
for (String filename : localfilenames) {
if (!(filename.contains("*") || filename.contains("?") || filename.contains("~"))) {
logger.info("Direct add: " + filename);
files.add(filename);
} else {
// local: must check
logger.info("Local Ask for " + filename + " from " + dir.getFullPath());
List<String> list;
try {
list = dir.list(filename);
if (list != null) {
files.addAll(list);
}
} catch (CommandAbstractException e) {
logger.warn(Messages.getString("Transfer.14") + filename + " : " + e.getMessage()); //$NON-NLS-1$
}
}
}
}
return files;
}

@Override
public void run() {
String[] localfilenames = filename.split(",");
Expand Down Expand Up @@ -169,7 +98,7 @@ public void run() {
long time1 = System.currentTimeMillis();
R66Future future = new R66Future(true);
DirectTransfer transaction = new DirectTransfer(future,
host, filename, rule, fileInfo, ismd5, block, idt,
host, filename, rulename, fileinfo, isMD5, blocksize, id,
networkTransaction);
transaction.normalInfoAsWarn = normalInfoAsWarn;
logger.debug("rhost: " + host + ":" + transaction.remoteHost);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void run() {
try {
dbrule = new DbRule(rulename);
} catch (WaarpDatabaseException e) {
logger.error(Messages.getString("SubmitTransfer.2") + rule); //$NON-NLS-1$
logger.error(Messages.getString("SubmitTransfer.2") + rulename); //$NON-NLS-1$
if (DetectionUtils.isJunit()) {
return;
}
Expand All @@ -100,7 +100,7 @@ public void run() {
}
List<String> files = null;
if (dbrule.isSendMode()) {
files = MultipleDirectTransfer.getLocalFiles(dbrule, localfilenames);
files = getLocalFiles(dbrule, localfilenames);
} else if (submit) {
files = new ArrayList<String>();
for (String string : localfilenames) {
Expand All @@ -111,15 +111,15 @@ public void run() {
host = host.trim();
if (host != null && !host.isEmpty()) {
if (!submit && dbrule.isRecvMode()) {
files = MultipleDirectTransfer.getRemoteFiles(dbrule, localfilenames, host, networkTransaction);
files = getRemoteFiles(dbrule, localfilenames, host, networkTransaction);
}
for (String filename : files) {
filename = filename.trim();
if (filename != null && !filename.isEmpty()) {
R66Future future = new R66Future(true);
SubmitTransfer transaction = new SubmitTransfer(future,
host, filename, rule, fileInfo, ismd5, block, idt,
ttimestart);
SubmitTransfer transaction = new SubmitTransfer(
future, host, filename, rulename, fileinfo,
isMD5, blocksize, id, startTime);
transaction.normalInfoAsWarn = normalInfoAsWarn;
transaction.run();
future.awaitUninterruptibly();
Expand Down
Loading

0 comments on commit a6fc529

Please sign in to comment.