URLEncoder in jolie from java

Signed-off-by: Luca Fulchir <luca@fulchir.it>
parent 42544ab8
This diff is collapsed. Click to expand it.
Everything
OAuth1 implementation:
-All
OAuth2 implementation:
-All
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
JAVAC=javac
BUILDDIR=../build/
JOLIEDIR=/opt/jolie/
java:
- mkdir -p ${BUILDDIR} 2>/dev/null
${JAVAC} -cp ${JOLIEDIR}/jolie.jar -d ${BUILDDIR} jolie/net/utils/URLEncoder.java
jar cvf ${BUILDDIR}/utils.jar ${BUILDDIR}/jolie/net/utils/*class
clean:
- rm -rf ${BUILDDIR}
demo1:
jolie jolie/net/OAuth1/demo.ol
/***************************************************************************
* Copyright (C) 2013 by Luca Fulchir <luca@fulchir.it> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* For details about the authors of this software, see the AUTHORS file. *
***************************************************************************/
include "console.iol"
include "security_utils.iol"
include "jolie/net/utils/URLEncoder.iol"
main
{
rnd = SecureRandomRequest;
rnd.size = 5;
secureRandom@SecurityUtils(rnd)(answer);
println@Console( "Answer is " + answer )();
input = URLEncoderRequest;
input.input = "http://printer.example.com/ready";
input.encoding = "UTF-8";
encode@URLEncoder(input)(output);
println@Console( "Answer is " + output )()
}
/***************************************************************************
* Copyright (C) 2013 by Luca Fulchir <luca@fulchir.it> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* For details about the authors of this software, see the AUTHORS file. *
***************************************************************************/
type URLEncoderRequest:void {
.input :string
.encoding :string
}
interface URLEncoderInterface {
RequestResponse:
encode (URLEncoderRequest) (string)
}
outputPort URLEncoder {
Interfaces:
URLEncoderInterface
}
embedded {
Java:
"jolie.net.utils.URLEncoder" in URLEncoder
}
/* *************************************************************************
* Copyright (C) 2013 by Luca Fulchir <luca@fulchir.it> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* For details about the authors of this software, see the AUTHORS file. *
***************************************************************************/
package jolie.net.utils;
import jolie.runtime.JavaService;
import jolie.runtime.Value;
import jolie.runtime.ValueVector;
import jolie.runtime.embedding.RequestResponse;
import jolie.runtime.FaultException;
public class URLEncoder extends JavaService
{
@RequestResponse
public static String encode (Value req) throws FaultException
{
String result = null;
try {
result = java.net.URLEncoder.encode(
req.getFirstChild( "input" ).strValue(),
req.getFirstChild( "encoding" ).strValue());
} catch (java.io.UnsupportedEncodingException e) {
throw new FaultException(e.getMessage());
}
return result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment