<commit_before>/**
 * openHAB, the open Home Automation Bus.
 * Copyright (C) 2010-2013, openHAB.org <<EMAIL>>
 *
 * See the contributors.txt file in the distribution for a
 * full listing of individual contributors.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 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 General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses>.
 *
 * Additional permission under GNU GPL version 3 section 7
 *
 * If you modify this Program, or any covered work, by linking or
 * combining it with Eclipse (or a modified version of that library),
 * containing parts covered by the terms of the Eclipse Public License
 * (EPL), the licensors of this Program grant you additional permission
 * to convey the resulting work.
 */
package org.openhab.action.nma.internal;

import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.openhab.core.scriptengine.action.ActionDoc;
import org.openhab.core.scriptengine.action.ParamDoc;
import org.openhab.io.net.http.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

/**
 * This class contains the methods that are made available in scripts and rules
 * for NotifyMyAndroid.
 * 
 * @author <NAME>
 * @since 1.3.0
 */
public class NotifyMyAndroid {

	private static final Logger logger = 
		LoggerFactory.getLogger(NotifyMyAndroid.class);

	private final static String API_URL = "https://www.notifymyandroid.com/publicapi/notify";
	private final static String CONTENT_TYPE = "application/x-www-form-urlencoded";
	private final static String UTF_8_ENCODING = "UTF-8";

	public static final String MESSAGE_KEY_API_KEY = "apikey";
	public static final String MESSAGE_KEY_APP = "application";
	public static final String MESSAGE_KEY_EVENT = "event";
	public static final String MESSAGE_KEY_DESC = "description";
	public static final String MESSAGE_KEY_PRIORITY = "priority";
	public static final String MESSAGE_KEY_DEV_KEY = "developerkey";
	public static final String MESSAGE_KEY_URL = "url";
	public static final String MESSAGE_KEY_CONTENT_TYPE = "content-type";

	static String appName = "openHAB";
	static String apiKey;
	static String url;
	static String developerKey;
	static int timeout = 10000;
	static int defaultPriotiy = 0;
	static String defaultUrl;
	

	@ActionDoc(text = "Send a notification to your Android device using the default api key", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
	public static boolean notifyMyAndroid(
			@ParamDoc(name = "event", text = "The event to notify") String event,
			@ParamDoc(name = "description", text = "A description of the event to notify") String description) {
		return notifyMyAndroid(apiKey, event, description);
	}

	@ActionDoc(text = "Send a notification to your Android device", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
	public static boolean notifyMyAndroid(
			@ParamDoc(name = "apiKey", text = "apiKey to use for the notification") String apiKey,
			@ParamDoc(name = "event", text = "The event to notify") String event,
			@ParamDoc(name = "description", text = "A description of the event to notify") String description) {
		return notifyMyAndroid(apiKey, event, description, defaultPriotiy);
	}

	@ActionDoc(text = "Send a notification to your Android device", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
	public static boolean notifyMyAndroid(
			@ParamDoc(name = "apiKey", text = "apiKey to use for the notification") String apiKey,
			@ParamDoc(name = "event", text = "The event to notify") String event,
			@ParamDoc(name = "description", text = "A description of the event to notify") String description,
			@ParamDoc(name = "priority", text = "The priority of the notification") int priority) {
		return notifyMyAndroid(apiKey, event, description, priority, null);
	}

	@ActionDoc(text = "Send a notification to your Android device", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
	public static boolean notifyMyAndroid(
			@ParamDoc(name = "apiKey", text = "apiKey to use for the notification") String apiKey,
			@ParamDoc(name = "event", text = "The event to notify") String event,
			@ParamDoc(name = "description", text = "A description of the event to notify") String description,
			@ParamDoc(name = "priority", text = "The priority of the notification") int priority,
			@ParamDoc(name = "url", text = "An URL representing this event") String url) {
		return notifyMyAndroid(apiKey, event, description, priority, url, false);
	}
<commit_msg>Add an extra overload to the notifyMyAndroid action (event, description, priority)<commit_after>/**
 * openHAB, the open Home Automation Bus.
 * Copyright (C) 2010-2013, openHAB.org <<EMAIL>>
 *
 * See the contributors.txt file in the distribution for a
 * full listing of individual contributors.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 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 General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses>.
 *
 * Additional permission under GNU GPL version 3 section 7
 *
 * If you modify this Program, or any covered work, by linking or
 * combining it with Eclipse (or a modified version of that library),
 * containing parts covered by the terms of the Eclipse Public License
 * (EPL), the licensors of this Program grant you additional permission
 * to convey the resulting work.
 */
package org.openhab.action.nma.internal;

import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.openhab.core.scriptengine.action.ActionDoc;
import org.openhab.core.scriptengine.action.ParamDoc;
import org.openhab.io.net.http.HttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

/**
 * This class contains the methods that are made available in scripts and rules
 * for NotifyMyAndroid.
 * 
 * @author <NAME>
 * @since 1.3.0
 */
public class NotifyMyAndroid {

	private static final Logger logger = 
		LoggerFactory.getLogger(NotifyMyAndroid.class);

	private final static String API_URL = "https://www.notifymyandroid.com/publicapi/notify";
	private final static String CONTENT_TYPE = "application/x-www-form-urlencoded";
	private final static String UTF_8_ENCODING = "UTF-8";

	public static final String MESSAGE_KEY_API_KEY = "apikey";
	public static final String MESSAGE_KEY_APP = "application";
	public static final String MESSAGE_KEY_EVENT = "event";
	public static final String MESSAGE_KEY_DESC = "description";
	public static final String MESSAGE_KEY_PRIORITY = "priority";
	public static final String MESSAGE_KEY_DEV_KEY = "developerkey";
	public static final String MESSAGE_KEY_URL = "url";
	public static final String MESSAGE_KEY_CONTENT_TYPE = "content-type";

	static String appName = "openHAB";
	static String apiKey;
	static String url;
	static String developerKey;
	static int timeout = 10000;
	static int defaultPriotiy = 0;
	static String defaultUrl;
	

	@ActionDoc(text = "Send a notification to your Android device using the default api key", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
	public static boolean notifyMyAndroid(
			@ParamDoc(name = "event", text = "The event to notify") String event,
			@ParamDoc(name = "description", text = "A description of the event to notify") String description) {
		return notifyMyAndroid(apiKey, event, description);
	}

	@ActionDoc(text = "Send a notification to your Android device using the default api key", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
	public static boolean notifyMyAndroid(
			@ParamDoc(name = "event", text = "The event to notify") String event,
			@ParamDoc(name = "description", text = "A description of the event to notify") String description,
			@ParamDoc(name = "priority", text = "The priority of the notification") int priority) {
		return notifyMyAndroid(apiKey, event, description, priority);
	}

	@ActionDoc(text = "Send a notification to your Android device", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
	public static boolean notifyMyAndroid(
			@ParamDoc(name = "apiKey", text = "apiKey to use for the notification") String apiKey,
			@ParamDoc(name = "event", text = "The event to notify") String event,
			@ParamDoc(name = "description", text = "A description of the event to notify") String description) {
		return notifyMyAndroid(apiKey, event, description, defaultPriotiy);
	}

	@ActionDoc(text = "Send a notification to your Android device", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
	public static boolean notifyMyAndroid(
			@ParamDoc(name = "apiKey", text = "apiKey to use for the notification") String apiKey,
			@ParamDoc(name = "event", text = "The event to notify") String event,
			@ParamDoc(name = "description", text = "A description of the event to notify") String description,
			@ParamDoc(name = "priority", text = "The priority of the notification") int priority) {
		return notifyMyAndroid(apiKey, event, description, priority, null);
	}

	@ActionDoc(text = "Send a notification to your Android device", returns = "<code>true</code>, if successful and <code>false</code> otherwise.")
	public static boolean notifyMyAndroid(
			@ParamDoc(name = "apiKey", text = "apiKey to use for the notification") String apiKey,
			@ParamDoc(name = "event", text = "The event to notify") String event,
			@ParamDoc(name = "description", text = "A description of the event to notify") String description,
			@ParamDoc(name = "priority", text = "The priority of the notification") int priority,
			@ParamDoc(name = "url", text = "An URL representing this event") String url) {
		return notifyMyAndroid(apiKey, event, description, priority, url, false);
	}

{'fraction_non_alphanumeric': 0.09793103448275862, 'fraction_numerical': 0.004655172413793103, 'mean_word_length': 4.9279509453244765, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, 'https://': 2, 'lorem ipsum': 0, 'www.': 6, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3026684', 'n_tokens_mistral': 3360, 'n_tokens_neox': 3211, 'n_words': 1252}