log.info("Invoking SCPInputHandler");
MessageContext input = jobExecutionContext.getInMessageContext();
Set<String> parameters = input.getParameters().keySet();
for (String paramName : parameters) {
ActualParameter actualParameter = (ActualParameter) input.getParameters().get(paramName);
String paramValue = MappingFactory.toString(actualParameter);
//TODO: Review this with type
if ("URI".equals(actualParameter.getType().getType().toString())) {
if (index < oldIndex) {
log.info("Input File: " + paramValue + " is already transfered, so we skip this operation !!!");
((URIParameterType) actualParameter.getType()).setValue(oldFiles.get(index));
data.append(oldFiles.get(index++)).append(","); // we get already transfered file and increment the index
} else {
String s = stageInputFiles(jobExecutionContext, paramValue);
((URIParameterType) actualParameter.getType()).setValue(s);
StringBuffer temp = new StringBuffer(data.append(s).append(",").toString());
GFacUtils.savePluginData(jobExecutionContext, temp.insert(0, ++index), this.getClass().getName());
}
} else if ("URIArray".equals(actualParameter.getType().getType().toString())) {
List<String> split = Arrays.asList(StringUtil.getElementsFromString(paramValue));
List<String> newFiles = new ArrayList<String>();
for (String paramValueEach : split) {
if (index < oldIndex) {
log.info("Input File: " + paramValue + " is already transfered, so we skip this operation !!!");
newFiles.add(oldFiles.get(index));
data.append(oldFiles.get(index++)).append(",");
} else {
String stageInputFiles = stageInputFiles(jobExecutionContext, paramValueEach);
status.setTransferState(TransferState.UPLOAD);
detail.setTransferStatus(status);
detail.setTransferDescription("Input Data Staged: " + stageInputFiles);
registry.add(ChildDataType.DATA_TRANSFER_DETAIL, detail, jobExecutionContext.getTaskData().getTaskID());
StringBuffer temp = new StringBuffer(data.append(stageInputFiles).append(",").toString());
GFacUtils.savePluginData(jobExecutionContext, temp.insert(0, ++index), this.getClass().getName());
newFiles.add(stageInputFiles);
}
}
((URIArrayType) actualParameter.getType()).setValueArray(newFiles.toArray(new String[newFiles.size()]));
}
inputNew.getParameters().put(paramName, actualParameter);
}
} catch (Exception e) {
log.error(e.getMessage());