diff --git a/src/main/java/com/devsu/push/sender/service/async/AsyncAndroidPushService.java b/src/main/java/com/devsu/push/sender/service/async/AsyncAndroidPushService.java index be0708d..1d34790 100644 --- a/src/main/java/com/devsu/push/sender/service/async/AsyncAndroidPushService.java +++ b/src/main/java/com/devsu/push/sender/service/async/AsyncAndroidPushService.java @@ -15,7 +15,8 @@ public class AsyncAndroidPushService extends AsyncPushServiceBase { private static final String BUILDER_OBJECT = Message.Builder.class.getSimpleName(); /** - * @see com.devsu.push.sender.service.sync.SyncAndroidPushService#AndroidPushService(String) + * Single param constructor. + * @param gcmApiKey The GCM API Key (also known as Sender ID). */ public AsyncAndroidPushService(String gcmApiKey){ super(new SyncAndroidPushService(gcmApiKey), null); @@ -34,8 +35,6 @@ public AsyncAndroidPushService(String gcmApiKey, PushCallback pushCallback) { * Sends a single push message. * @param msgBuilder The Message.Builder object. * @param token The push token. - * @return true if the push message request was sent. - * @throws Exception */ public void sendPush(final Message.Builder msgBuilder, final String token) { ExecutorService executorService = Executors.newSingleThreadExecutor(); @@ -61,9 +60,7 @@ public void run() { /** * Sends a bulk push message. * @param msgBuilder The Message.Builder object. - * @param token The push token. - * @return true if the push message request was sent. - * @throws Exception + * @param tokens The push tokens. */ public void sendPushInBulk(final Message.Builder msgBuilder, final String... tokens) { ExecutorService executorService = Executors.newSingleThreadExecutor(); @@ -87,56 +84,66 @@ public void run() { } /** - * @see com.devsu.push.sender.service.sync.SyncAndroidPushService#setMaxRetries(int) + * Sets the number of max retries when sending a push message. + * @param maxRetries The number of max retries when sending a push message. */ public void setMaxRetries(int maxRetries) { ((SyncAndroidPushService)pushService).setMaxRetries(maxRetries); } /** - * @see com.devsu.push.sender.service.sync.SyncAndroidPushService#setMessageKey(java.lang.String) + * Sets the message key that will store the key-value pair for the push message content. + * @param messageKey The message key that will store the key-value pair for the push message content. */ public void setMessageKey(String messageKey) { ((SyncAndroidPushService)pushService).setMessageKey(messageKey); } /** - * @see com.devsu.push.sender.service.sync.SyncAndroidPushService#setTitleKey(java.lang.String) + * Sets the title key that will store the key-value pair for the push message title. + * @param titleKey The title key that will store the key-value pair for the push message title. */ public void setTitleKey(String titleKey) { ((SyncAndroidPushService)pushService).setTitleKey(titleKey); } /** - * @see com.devsu.push.sender.service.sync.SyncAndroidPushService#setMaxBulkSize(int) + * Sets the quantity of push messages to be sent simultaneously on multicast requests. + * NOTE: As of December 2016, GCM states that there's a max limit of 1.000 simultaneous + * registration ids on multicast requests. See the registration_ids parameter here. + * @param maxBulkSize The quantity of push messages to be sent simultaneously on multicast requests. Has a max value of 1000. */ public void setMaxBulkSize(int maxBulkSize) { ((SyncAndroidPushService)pushService).setMaxBulkSize(maxBulkSize); } /** - * @see com.devsu.push.sender.service.sync.SyncAndroidPushService#setCollapseKeySingle(java.lang.String) + * Sets the collapse key for identifying single messages. + * @param collapseKeySingle The collapse key for identifying single messages. */ public void setCollapseKeySingle(String collapseKeySingle) { ((SyncAndroidPushService)pushService).setCollapseKeySingle(collapseKeySingle); } - /** - * @see com.devsu.push.sender.service.sync.SyncAndroidPushService#setCollapseKeyBulk(java.lang.String) + /** + * Sets the collapse key for identifying bulk messages. + * @param collapseKeyBulk The collapse key for identifying bulk messages. */ public void setCollapseKeyBulk(String collapseKeyBulk) { ((SyncAndroidPushService)pushService).setCollapseKeyBulk(collapseKeyBulk); } /** - * @see com.devsu.push.sender.service.sync.SyncAndroidPushService#setGcmApiKey(java.lang.String) + * Sets the GCM API Key (also known as Sender ID). + * @param gcmApiKey The GCM API Key (also known as Sender ID). */ public void setGcmApiKey(String gcmApiKey) { ((SyncAndroidPushService)pushService).setGcmApiKey(gcmApiKey); } /** - * @see com.devsu.push.sender.service.sync.SyncPushServiceBase#setPushEnabled(boolean) + * Enables/disables this service. + * @param pushEnabled The parameter that enables/disables this service. */ public void setPushEnabled(boolean pushEnabled) { ((SyncAndroidPushService)pushService).setPushEnabled(pushEnabled); diff --git a/src/main/java/com/devsu/push/sender/service/async/AsyncApplePushService.java b/src/main/java/com/devsu/push/sender/service/async/AsyncApplePushService.java index 7ff572e..0929c80 100644 --- a/src/main/java/com/devsu/push/sender/service/async/AsyncApplePushService.java +++ b/src/main/java/com/devsu/push/sender/service/async/AsyncApplePushService.java @@ -19,7 +19,12 @@ public class AsyncApplePushService extends AsyncPushServiceBase { private static final String BUILDER_OBJECT = PayloadBuilder.class.getSimpleName(); /** - * @see com.devsu.push.sender.service.sync.SyncApplePushService#ApplePushService(String, String, boolean) + * 3 param constructor. + * @param certificatePath The path of the p12 certificate file. + * @param certificatePassword The password for the p12 certificate. + * @param useProductionServer Indicates if the services uses a Production environment or a Sandbox environment. + * @throws RuntimeIOException An IO exception. + * @throws InvalidSSLConfig Certificates are corrupted, wrong or password is wrong. */ public AsyncApplePushService(String certificatePath, String certificatePassword, boolean useProductionServer) throws RuntimeIOException, InvalidSSLConfig { @@ -32,8 +37,8 @@ public AsyncApplePushService(String certificatePath, String certificatePassword, * @param certificatePassword The password for the p12 certificate. * @param useProductionServer Indicates if the services uses a Production environment or a Sandbox environment. * @param pushCallback The push callback. - * @throws RuntimeIOException - * @throws InvalidSSLConfig + * @throws RuntimeIOException An IO exception. + * @throws InvalidSSLConfig Certificates are corrupted, wrong or password is wrong. */ public AsyncApplePushService(String certificatePath, String certificatePassword, boolean useProductionServer, PushCallback pushCallback) throws RuntimeIOException, InvalidSSLConfig { @@ -44,8 +49,6 @@ public AsyncApplePushService(String certificatePath, String certificatePassword, * Sends a single push message. * @param msgBuilder The PayloadBuilder object. * @param token The push token. - * @return true if the push message request was sent. - * @throws Exception */ public void sendPush(final PayloadBuilder msgBuilder, final String token) { ExecutorService executorService = Executors.newSingleThreadExecutor(); @@ -71,9 +74,7 @@ public void run() { /** * Sends a bulk push message. * @param msgBuilder The Message.Builder object. - * @param token The push token. - * @return true if the push message request was sent. - * @throws Exception + * @param tokens The push token. */ public void sendPushInBulk(final PayloadBuilder msgBuilder, final String... tokens) { ExecutorService executorService = Executors.newSingleThreadExecutor(); @@ -97,26 +98,39 @@ public void run() { } /** - * @see com.devsu.push.sender.service.sync.SyncApplePushService#setupDevelopmentServer(java.lang.String, java.lang.String) + * Sets up the APNS Sandbox environment. + * @param certificatePath The path of the p12 certificate file. + * @param certificatePassword The password for the p12 certificate. + * @throws RuntimeIOException An IO exception. + * @throws InvalidSSLConfig Certificates are corrupted, wrong or password is wrong. */ public void setupDevelopmentServer(String certificatePath, String certificatePassword) throws RuntimeIOException, InvalidSSLConfig { ((SyncApplePushService)pushService).setupDevelopmentServer(certificatePath, certificatePassword); } /** - * @see com.devsu.push.sender.service.sync.SyncApplePushService#setupProductionServer(java.lang.String, java.lang.String) + * Sets up the APNS Production environment. + * @param certificatePath The path of the p12 certificate file. + * @param certificatePassword The password for the p12 certificate. + * @throws RuntimeIOException An IO exception. + * @throws InvalidSSLConfig Certificates are corrupted, wrong or password is wrong. */ public void setupProductionServer(String certificatePath, String certificatePassword) throws RuntimeIOException, InvalidSSLConfig { ((SyncApplePushService)pushService).setupProductionServer(certificatePath, certificatePassword); } /** - * @see com.devsu.push.sender.service.sync.SyncPushServiceBase#setPushEnabled(boolean) + * Enables/disables this service. + * @param pushEnabled The parameter that enables/disables this service. */ public void setPushEnabled(boolean pushEnabled) { ((SyncApplePushService)pushService).setPushEnabled(pushEnabled); } + /** + * Gets a map of inactive devices. + * @return a map of inactive devices. + */ public Map getInactiveDevices() { return ((SyncApplePushService)pushService).getInactiveDevices(); } diff --git a/src/main/java/com/devsu/push/sender/service/sync/SyncAndroidPushService.java b/src/main/java/com/devsu/push/sender/service/sync/SyncAndroidPushService.java index b394496..04df433 100644 --- a/src/main/java/com/devsu/push/sender/service/sync/SyncAndroidPushService.java +++ b/src/main/java/com/devsu/push/sender/service/sync/SyncAndroidPushService.java @@ -97,7 +97,7 @@ public boolean sendPush(final String title, final String message, final Maptrue if the push message request was sent. - * @throws Exception + * @throws Exception Any exception that may arise. */ public boolean sendPush(Message.Builder msgBuilder, String token) throws Exception { if (!validateToken(log, token)) { @@ -129,9 +129,9 @@ public boolean sendPushInBulk(final String title, final String message, /** * Sends a bulk push message. * @param msgBuilder The Message.Builder object. - * @param token The push token. + * @param tokens The push token. * @return true if the push message request was sent. - * @throws Exception + * @throws Exception Any exception that may arise. */ public boolean sendPushInBulk(Message.Builder msgBuilder, String... tokens) throws Exception { boolean booleanResult = true; diff --git a/src/main/java/com/devsu/push/sender/service/sync/SyncApplePushService.java b/src/main/java/com/devsu/push/sender/service/sync/SyncApplePushService.java index 4127bf6..a9a4e29 100644 --- a/src/main/java/com/devsu/push/sender/service/sync/SyncApplePushService.java +++ b/src/main/java/com/devsu/push/sender/service/sync/SyncApplePushService.java @@ -35,8 +35,8 @@ public class SyncApplePushService extends SyncPushServiceBase { * @param certificatePath The path of the p12 certificate file. * @param certificatePassword The password for the p12 certificate. * @param useProductionServer Indicates if the services uses a Production environment or a Sandbox environment. - * @throws RuntimeIOException - * @throws InvalidSSLConfig + * @throws RuntimeIOException An IO exception. + * @throws InvalidSSLConfig Certificates are corrupted, wrong or password is wrong. */ public SyncApplePushService(String certificatePath, String certificatePassword, boolean useProductionServer) throws RuntimeIOException, InvalidSSLConfig { @@ -77,7 +77,7 @@ public boolean sendPush(String title, String message, Map additi * @param msgBuilder The PayloadBuilder object. * @param token The push token. * @return true if the push message request was sent. - * @throws Exception + * @throws Exception Any exception that may arise. */ public boolean sendPush(PayloadBuilder msgBuilder, String token) throws Exception { if (!validateToken(log, token)) { @@ -111,9 +111,9 @@ public boolean sendPushInBulk(String title, String message, /** * Sends a bulk push message. * @param msgBuilder The PayloadBuilder object. - * @param token The push token. + * @param tokens The push token. * @return true if the push message request was sent. - * @throws Exception + * @throws Exception Any exception that may arise. */ public boolean sendPushInBulk(PayloadBuilder msgBuilder, String... tokens) throws Exception { apnsService.start(); @@ -146,8 +146,8 @@ private PayloadBuilder generateBuilder(String title, String message, Maptrue if the push message request was sent. - * @throws Exception + * @throws Exception Any exception that may arise. */ boolean sendPush(String message, String token) throws Exception; @@ -19,7 +19,7 @@ public interface SyncPushService { * @param message The push message content. * @param token The push token. * @return true if the push message request was sent. - * @throws Exception + * @throws Exception Any exception that may arise. */ boolean sendPush(String title, String message, String token) throws Exception; @@ -30,7 +30,7 @@ public interface SyncPushService { * @param additionalFields The additional fields sent on the push message. * @param token The push token. * @return true if the push message request was sent. - * @throws Exception + * @throws Exception Any exception that may arise. */ boolean sendPush(String title, String message, Map additionalFields, String token) throws Exception; @@ -39,7 +39,7 @@ public interface SyncPushService { * @param message The push message content. * @param tokens The push tokens. * @return true if the push message request was sent. - * @throws Exception + * @throws Exception Any exception that may arise. */ boolean sendPushInBulk(String message, String... tokens) throws Exception; @@ -49,7 +49,7 @@ public interface SyncPushService { * @param message The push message content. * @param tokens The push tokens. * @return true if the push message request was sent. - * @throws Exception + * @throws Exception Any exception that may arise. */ boolean sendPushInBulk(String title, String message, String... tokens) throws Exception; @@ -60,7 +60,7 @@ public interface SyncPushService { * @param additionalFields The additional fields sent on the push message. * @param tokens The push tokens. * @return true if the push message request was sent. - * @throws Exception + * @throws Exception Any exception that may arise. */ boolean sendPushInBulk(String title, String message, Map additionalFields, String... tokens) throws Exception; } diff --git a/src/main/java/com/devsu/push/sender/util/ArrayUtil.java b/src/main/java/com/devsu/push/sender/util/ArrayUtil.java index 714820c..d277369 100644 --- a/src/main/java/com/devsu/push/sender/util/ArrayUtil.java +++ b/src/main/java/com/devsu/push/sender/util/ArrayUtil.java @@ -11,6 +11,7 @@ public class ArrayUtil { /** * Splits an array in a list of subarrays of size maxSubArraySize. + * @param The class of the elements in the array. * @param elementArray The array to be split. * @param maxSubArraySize The final size of the subarrays. * @return The list containing the subarrays.