Skip to content

Instantly share code, notes, and snippets.

@dieswaytoofast
Created November 12, 2012 23:13
Show Gist options
  • Save dieswaytoofast/4062711 to your computer and use it in GitHub Desktop.
Save dieswaytoofast/4062711 to your computer and use it in GitHub Desktop.
Oh Joyous Code, thy authorship is known to me...
public void persistSentFax( FaxSendEvent e ) throws
ApplicationException, Exception {
// XXX jwh - this logic really, really, REALLY needs to be broken out. I'M SERIOUS.
// I mean, this is getting ugly now. Really ugly. Uglier than your mom. And that's _ugly_.
// It would probably just be fine for JAKE (clarifying the antecedent just so you know that
// it's YOUR mom I'm talking about, not MINE.) to do one prepared statement that gets reused
String tmp = getSession().getVars().get(
PhoneplexServlet.APPLICATION_CLIENT_OID );
String tmp2 = getSession().getVars().get(
PhoneplexServlet.APPLICATION_USER_OID );
// XXX Yucky. Refactor this.
String sentDocs = ( e.getFaxDocList().substring(1 , e.getFaxDocList().length() ));
StringTokenizer tok = new StringTokenizer( sentDocs, "|" );
String tempDocList = "";
while ( tok.hasMoreTokens() ) {
String temp = tok.nextToken();
// XXX TEMPORARY HACK
// Move the file to the fax folder if outbound
if ( getSession().getVars().get(SessionVars.SESSION_SRC).equals( "WebFaxBack" ) ) {
File src = new File( temp );
File dest = new File( /*AppConfig.getClientDataRoot()*/
"U:/prod/clientdata" + "/" + getSession().getVars().get(PhoneplexServlet.APPLICATION_CLIENT_OID) +
"/fax/" + temp.substring( temp.indexOf("uploads")+8 ) );
CopyFileAction cFA = new CopyFileAction( src.toString(), dest.toString() );
cFA.execute();
src.delete();
temp = dest.toString();
}
if ( temp.indexOf("clientdata") != -1 ){
temp = ( temp.substring( temp.indexOf("clientdata")+11 ));
} else if ( temp.indexOf("phoneplex") != -1 ) {
temp = ( temp.substring( temp.indexOf("phoneplex") + 10 ));
}
tempDocList += convertSlashes( temp ) + "|";
}
long clientOID = Long.parseLong( tmp );
long userOID = clientOID;
if ( tmp2 != null ) {
userOID = Long.parseLong( tmp2 );
}
long callReference = getCallRefOID( );
long oid = createMessageOID( );
String relativeFileName = tempDocList.substring(0, tempDocList.length() - 1 );
// XXX THIS IS THE WORST HACK EVER. FIX IMMEDIATELY.
if ( relativeFileName.startsWith("honeplex") ) {
relativeFileName = relativeFileName.substring( 7, relativeFileName.length() );
relativeFileName = "../" + relativeFileName;
} else if ( relativeFileName.startsWith("oneplex") ) {
relativeFileName = relativeFileName.substring( 8, relativeFileName.length() );
relativeFileName = "../" + relativeFileName;
}
// snip for sanity's sake
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment