12-13-2019 03:00 AM - edited 12-13-2019 03:03 AM
Hi Team,
I am facing one issue while access the file in FTP server.
Our requirements is Copy the file and create folder placed over there for every call , i placed this custom element after record with confirm elements.
when i tired with main method it was working. after overwritten the Decision element. for Every call folders are created successfully but files are not copied to created folders. but it was working in main method.
Steps 1 : i am able to connect the FTP server
Steps 2 : i am able to create the floder+ANI for every call.
Steps 3: i am not able to copy those file to Created folder step 2
Guys could you please give me some idea to fix this please,
FYI my code below,
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import com.audium.server.session.DecisionElementData;
import com.audium.server.voiceElement.DecisionElementBase;
import com.audium.server.voiceElement.ElementData;
import com.audium.server.voiceElement.ElementException;
import com.audium.server.voiceElement.ElementInterface;
import com.audium.server.voiceElement.ExitState;
import com.audium.server.voiceElement.Setting;
public class Main_classTesting extends DecisionElementBase implements ElementInterface
{
@Override
public String doDecision(String DNISS, DecisionElementData actionData) throws Exception
{
String dirToList = "/CCPA_IVR_COPY";
String r="";
// static String dirToList1 = "/CCPA_ACCESS/Destination_folder";
String directorypath = "/Testing_Please dont open/CCPA/CCPA_IVR";
String server = "********";
int port = 21;
String user = "********";
String pass = "********";
String dnis;
FTPClient ftpClient = new FTPClient();
try {
dnis =(String) actionData.getAni();
ftpClient.connect(server, port);
ftpClient.getReplyCode();
ftpClient.login(user, pass);
directorypath = directorypath.concat(dnis);
makeDirectory(ftpClient, directorypath);
listDirectory(ftpClient, dirToList, "", 0);
//actionData.setSessionData("DPEXIT","FCC_"+r);
//return r = FCC;
return "FCC";
}
catch (IOException ex) {
System.out.println("Oops! Something wrong happened");
actionData.setSessionData("DPEXIT", "NONE");
return "NONE";
}
}
public String getElementName()
{
return "CustomSabari";
}
public String getDisplayFolderName()
{
return "Video";
}
public String getDescription()
{
return "This class generates a random integer between 0 and some upper bound.\n" + "Provide an integer and it will return an integer between 0 and one less than the provided.\n" + "e.g. 6 (n-1) = between 0 and 5";
}
public Setting[] getSettings() throws ElementException
{
return null;
}
public ElementData[] getElementData() throws ElementException
{
return null;
}
public static void makeDirectory(FTPClient ftpClient, String directorypath) throws IOException {
String[] pathElements = directorypath.split("/");
if (pathElements != null && pathElements.length > 0) {
for (String singleDir : pathElements) {
boolean existed = ftpClient.changeWorkingDirectory(singleDir);
if (!existed) {
boolean created = ftpClient.makeDirectory(singleDir);
if (created) {
System.out.println("CREATED directory: " + singleDir);
ftpClient.changeWorkingDirectory(singleDir);
} else {
System.out.println("COULD NOT create directory: " + singleDir);
}
}
}
}
}
static void listDirectory(FTPClient ftpClient, String parentDir, String currentDir, int level) throws IOException, Exception {
FileInputStream os = null;
String dirToList = parentDir;
String dirToList1 = "/CCPA_ACCESS/";
if (!currentDir.equals("")) {
dirToList += "/" + currentDir;
}
FTPFile[] subFiles = ftpClient.listFiles(dirToList);
if (subFiles != null && subFiles.length > 0) {
for (FTPFile aFile : subFiles) {
String currentFileName = aFile.getName();
if (currentFileName.startsWith("CCPA_IVR") || currentFileName.equals("..")) {
System.out.println(" Current File name "+currentFileName);
System.out.println("found");
os = new FileInputStream("Testing_Please dont open/");
System.out.println("Dir list 1 =" + os.toString());
System.out.println("Dir list 1 =" + dirToList1);
ftpClient.storeFile(currentFileName, os);
}else{
System.out.println("Dir list 1 =" + os.toString());
}
}
}
}
@Override
public ExitState[] getExitStates(){
return new ExitState[] {
new ExitState("FCC","FCC","FURNCBK1"),
new ExitState("NONE","NONE","FURNCBK2")
};
}
}
ERROR I got after above the code:::::::::
===============================================================================
10.43.180.41.1576233573551.83.IVR_MAI_TEST,12/13/2019 04:40:36.320, The error was: The element CustomElement_01 returned the exit state NONE but this does not match any exit state expected from the element when the callflow was created.
com.audium.server.AudiumException: The element CustomSabari_01 returned the exit state NONE but this does not match any exit state expected from the element when the callflow was created.
at com.audium.server.controller.Controller.continueCall(Controller.java:3683)
at com.audium.server.controller.Controller.goToElement(Controller.java:4126)
at com.audium.server.controller.Controller.continueCall(Controller.java:3710)
at com.audium.server.controller.Controller.goToElement(Controller.java:4126)
at com.audium.server.controller.Controller.continueCall(Controller.java:3710)
at com.audium.server.controller.Controller.doPost(Controller.java:1124)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
if i missed anything please let me know.
Really appreciate your responses.
Thanks!
Solved! Go to Solution.
12-13-2019 09:44 AM
The code you posted doesn't seem to match the error you posted.
This error usually means that the getExitStates method doesn't match the value of the exit state the doDecision returns: "The element CustomElement_01 returned the exit state NONE but this does not match any exit state expected from the element when the callflow was created."
So, I suggest that you recompile the java code. Re-copy it into the Studio app and re-test.
By the way, during development and testing, continue to copy the java class into the Studio app for testing.
Do not copy it into the VXMLServer/common or eclipse/com.audium.studio.library.common or eclipse/com.audium.studio.debug.runtime/AUDIUM_HOME/common/
until you're happy with it.
NOTE if you already have the java code in one of these 3 directories listed above then that one takes precedence. So the system will ignore that class file if it's also in the application.
12-13-2019 09:44 AM
The code you posted doesn't seem to match the error you posted.
This error usually means that the getExitStates method doesn't match the value of the exit state the doDecision returns: "The element CustomElement_01 returned the exit state NONE but this does not match any exit state expected from the element when the callflow was created."
So, I suggest that you recompile the java code. Re-copy it into the Studio app and re-test.
By the way, during development and testing, continue to copy the java class into the Studio app for testing.
Do not copy it into the VXMLServer/common or eclipse/com.audium.studio.library.common or eclipse/com.audium.studio.debug.runtime/AUDIUM_HOME/common/
until you're happy with it.
NOTE if you already have the java code in one of these 3 directories listed above then that one takes precedence. So the system will ignore that class file if it's also in the application.
12-25-2019 08:13 PM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide