
templates.android.service.vm Maven / Gradle / Ivy
The newest version!
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library 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 Lesser General Public License for more
* details.
*/
##n
package $package;
##n
import com.liferay.mobile.android.http.file.UploadData;
import com.liferay.mobile.android.service.BaseService;
import com.liferay.mobile.android.service.JSONObjectWrapper;
import com.liferay.mobile.android.service.Session;
##n
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
##n
/**
* @author Bruno Farache
*/
public class $className extends BaseService {
##n
##t public $className(Session session) {
##t super(session);
##t }
##n
#foreach ($action in $actions)
#set ($parameters = $action.parameters)
##t #javaMethodSignature($action)
##t JSONObject _command = new JSONObject();
##n
##t try {
##t JSONObject _params = new JSONObject();
##n
#set ($invokeMethod = "invoke")
#foreach ($parameter in $parameters)
#set ($parameterName = $parameter.name)
#set ($parameterType = $languageUtil.getType($parameter.type))
#if ($parameterType == $UPLOAD_DATA)
#set ($invokeMethod = "upload")
#end
#set ($parameterValue = $parameterName)
#if ($parameterType == $JSON_OBJECT_WRAPPER)
##t mangleWrapper(_params, ${esc.q}$parameterName${esc.q}, ${esc.q}$parameter.type${esc.q}, $parameterValue);
#else
#if ($parameterType == $BYTE_ARRAY)
#set ($parameterValue = "toString(${parameterName})")
#elseif (!$languageUtil.isPrimitive($parameterType))
#set ($parameterValue = "checkNull(${parameterName})")
#end
##t _params.put(${esc.q}$parameterName${esc.q}, $parameterValue);
#end
#if (!$foreach.hasNext)
##n
#end
#end
##t _command.put(${esc.q}$action.path${esc.q}, _params);
##t }
##t catch (JSONException _je) {
##t throw new Exception(_je);
##t }
##n
#if ($returnType == $VOID)
##t session.${invokeMethod}(_command);
#else
#if ($returnType == $INTEGER)
#set ($returnType = "Int")
#end
##t JSONArray _result = session.${invokeMethod}(_command);
##n
##t if (_result == null) {
##t return null;
##t }
##n
##t return _result.get${returnType}(0);
#end
##t }
##n
#end
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy