Skip to content

Commit 8988001

Browse files
committed
moving classes around
1 parent e9ac9d4 commit 8988001

File tree

96 files changed

+900
-889
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+900
-889
lines changed

src/main/java/com/pubnub/api/callbacks/PNCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.pubnub.api.callbacks;
22

33

4-
import com.pubnub.api.core.models.consumer_facing.PNStatus;
4+
import com.pubnub.api.core.models.consumer.PNStatus;
55

66
public abstract class PNCallback<X> {
77
public abstract void onResponse(X result, PNStatus status);
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.pubnub.api.callbacks;
22

3-
import com.pubnub.api.core.Pubnub;
3+
import com.pubnub.api.core.PubNub;
44
import com.pubnub.api.core.models.consumer_facing.PNMessageResult;
55
import com.pubnub.api.core.models.consumer_facing.PNPresenceEventResult;
6-
import com.pubnub.api.core.models.consumer_facing.PNStatus;
6+
import com.pubnub.api.core.models.consumer.PNStatus;
77

88
public abstract class SubscribeCallback {
9-
public abstract void status(Pubnub pubnub, PNStatus status);
10-
public abstract void message(Pubnub pubnub, PNMessageResult message);
11-
public abstract void presence(Pubnub pubnub, PNPresenceEventResult presence);
9+
public abstract void status(PubNub pubnub, PNStatus status);
10+
public abstract void message(PubNub pubnub, PNMessageResult message);
11+
public abstract void presence(PubNub pubnub, PNPresenceEventResult presence);
1212
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.pubnub.api.callbacks;
22

3-
import com.pubnub.api.core.models.consumer_facing.PNTimeResult;
3+
import com.pubnub.api.core.models.consumer.PNTimeResult;
44

55
public abstract class TimeCallback extends PNCallback<PNTimeResult> {
66
}

src/main/java/com/pubnub/api/core/Crypto.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public Crypto(String cipherKey, String customInitializationVector) {
3939
this.cipherKey = cipherKey;
4040
}
4141

42-
public void InitCiphers() throws PubnubException {
42+
public void InitCiphers() throws PubNubException {
4343
if (INIT)
4444
return;
4545
try {
@@ -50,26 +50,26 @@ public void InitCiphers() throws PubnubException {
5050
ivBytes = initializationVector.getBytes("UTF-8");
5151
INIT = true;
5252
} catch (UnsupportedEncodingException e) {
53-
throw PubnubException.builder().pubnubError(newCryptoError(11, e.toString())).errormsg(e.getMessage()).build();
53+
throw PubNubException.builder().pubnubError(newCryptoError(11, e.toString())).errormsg(e.getMessage()).build();
5454
}
5555
}
5656

57-
public static byte[] hexEncode(byte[] input) throws PubnubException {
57+
public static byte[] hexEncode(byte[] input) throws PubNubException {
5858
StringBuffer result = new StringBuffer();
5959
for (byte byt : input)
6060
result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1));
6161
try {
6262
return result.toString().getBytes("UTF-8");
6363
} catch (UnsupportedEncodingException e) {
64-
throw PubnubException.builder().pubnubError(newCryptoError(12, e.toString())).errormsg(e.getMessage()).build();
64+
throw PubNubException.builder().pubnubError(newCryptoError(12, e.toString())).errormsg(e.getMessage()).build();
6565
}
6666
}
6767

68-
private static PubnubError newCryptoError(int code, String message) {
69-
return PubnubError.getErrorObject(PubnubError.PNERROBJ_CRYPTO_ERROR, code, message);
68+
private static PubNubError newCryptoError(int code, String message) {
69+
return PubNubError.getErrorObject(PubNubError.PNERROBJ_CRYPTO_ERROR, code, message);
7070
}
7171

72-
public String encrypt(String input) throws PubnubException {
72+
public String encrypt(String input) throws PubNubException {
7373
try {
7474
InitCiphers();
7575
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
@@ -79,19 +79,19 @@ public String encrypt(String input) throws PubnubException {
7979
cipher.init(Cipher.ENCRYPT_MODE, newKey, ivSpec);
8080
return new String(Base64.encode(cipher.doFinal(input.getBytes("UTF-8")), 0));
8181
} catch (NoSuchAlgorithmException e) {
82-
throw PubnubException.builder().errormsg(e.toString()).build();
82+
throw PubNubException.builder().errormsg(e.toString()).build();
8383
} catch (NoSuchPaddingException e) {
84-
throw PubnubException.builder().errormsg(e.toString()).build();
84+
throw PubNubException.builder().errormsg(e.toString()).build();
8585
} catch (InvalidKeyException e) {
86-
throw PubnubException.builder().errormsg(e.toString()).build();
86+
throw PubNubException.builder().errormsg(e.toString()).build();
8787
} catch (InvalidAlgorithmParameterException e) {
88-
throw PubnubException.builder().errormsg(e.toString()).build();
88+
throw PubNubException.builder().errormsg(e.toString()).build();
8989
} catch (UnsupportedEncodingException e) {
90-
throw PubnubException.builder().errormsg(e.toString()).build();
90+
throw PubNubException.builder().errormsg(e.toString()).build();
9191
} catch (IllegalBlockSizeException e) {
92-
throw PubnubException.builder().errormsg(e.toString()).build();
92+
throw PubNubException.builder().errormsg(e.toString()).build();
9393
} catch (BadPaddingException e) {
94-
throw PubnubException.builder().errormsg(e.toString()).build();
94+
throw PubNubException.builder().errormsg(e.toString()).build();
9595
}
9696

9797
}
@@ -101,9 +101,9 @@ public String encrypt(String input) throws PubnubException {
101101
*
102102
* @param cipher_text
103103
* @return String
104-
* @throws PubnubException
104+
* @throws PubNubException
105105
*/
106-
public String decrypt(String cipher_text) throws PubnubException {
106+
public String decrypt(String cipher_text) throws PubNubException {
107107
try {
108108
InitCiphers();
109109
AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
@@ -112,21 +112,21 @@ public String decrypt(String cipher_text) throws PubnubException {
112112
cipher.init(Cipher.DECRYPT_MODE, newKey, ivSpec);
113113
return new String(cipher.doFinal(Base64.decode(cipher_text, 0)), "UTF-8");
114114
} catch (IllegalArgumentException e) {
115-
throw PubnubException.builder().errormsg(e.toString()).build();
115+
throw PubNubException.builder().errormsg(e.toString()).build();
116116
} catch (UnsupportedEncodingException e) {
117-
throw PubnubException.builder().errormsg(e.toString()).build();
117+
throw PubNubException.builder().errormsg(e.toString()).build();
118118
} catch (IllegalBlockSizeException e) {
119-
throw PubnubException.builder().errormsg(e.toString()).build();
119+
throw PubNubException.builder().errormsg(e.toString()).build();
120120
} catch (BadPaddingException e) {
121-
throw PubnubException.builder().errormsg(e.toString()).build();
121+
throw PubNubException.builder().errormsg(e.toString()).build();
122122
} catch (InvalidKeyException e) {
123-
throw PubnubException.builder().errormsg(e.toString()).build();
123+
throw PubNubException.builder().errormsg(e.toString()).build();
124124
} catch (InvalidAlgorithmParameterException e) {
125-
throw PubnubException.builder().errormsg(e.toString()).build();
125+
throw PubNubException.builder().errormsg(e.toString()).build();
126126
} catch (NoSuchAlgorithmException e) {
127-
throw PubnubException.builder().errormsg(e.toString()).build();
127+
throw PubNubException.builder().errormsg(e.toString()).build();
128128
} catch (NoSuchPaddingException e) {
129-
throw PubnubException.builder().errormsg(e.toString()).build();
129+
throw PubNubException.builder().errormsg(e.toString()).build();
130130
}
131131
}
132132

@@ -144,18 +144,18 @@ public static byte[] hexStringToByteArray(String s) {
144144
*
145145
* @param input
146146
* @return byte[]
147-
* @throws PubnubException
147+
* @throws PubNubException
148148
*/
149-
public static byte[] md5(String input) throws PubnubException {
149+
public static byte[] md5(String input) throws PubNubException {
150150
MessageDigest digest;
151151
try {
152152
digest = MessageDigest.getInstance("MD5");
153153
byte[] hashedBytes = digest.digest(input.getBytes("UTF-8"));
154154
return hashedBytes;
155155
} catch (NoSuchAlgorithmException e) {
156-
throw PubnubException.builder().pubnubError(newCryptoError(118, e.toString())).errormsg(e.getMessage()).build();
156+
throw PubNubException.builder().pubnubError(newCryptoError(118, e.toString())).errormsg(e.getMessage()).build();
157157
} catch (UnsupportedEncodingException e) {
158-
throw PubnubException.builder().pubnubError(newCryptoError(119, e.toString())).errormsg(e.getMessage()).build();
158+
throw PubNubException.builder().pubnubError(newCryptoError(119, e.toString())).errormsg(e.getMessage()).build();
159159
}
160160
}
161161

@@ -164,16 +164,16 @@ public static byte[] md5(String input) throws PubnubException {
164164
*
165165
* @param input
166166
* @return byte[]
167-
* @throws PubnubException
167+
* @throws PubNubException
168168
*/
169-
public static byte[] sha256(byte[] input) throws PubnubException {
169+
public static byte[] sha256(byte[] input) throws PubNubException {
170170
MessageDigest digest;
171171
try {
172172
digest = MessageDigest.getInstance("SHA-256");
173173
byte[] hashedBytes = digest.digest(input);
174174
return hashedBytes;
175175
} catch (NoSuchAlgorithmException e) {
176-
throw PubnubException.builder().pubnubError(newCryptoError(111, e.toString())).errormsg(e.getMessage()).build();
176+
throw PubNubException.builder().pubnubError(newCryptoError(111, e.toString())).errormsg(e.getMessage()).build();
177177
}
178178
}
179179

src/main/java/com/pubnub/api/core/PnConfiguration.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
@Getter
1212
@Setter
13-
public class PnConfiguration {
13+
public class PNConfiguration {
1414

1515
/**
1616
* By default, the origin is pointing directly to PubNub servers. If a proxy origin is neeeded, set a custom
@@ -81,10 +81,10 @@ public class PnConfiguration {
8181
@Setter private String filterExpression;
8282

8383
/**
84-
* Initialize the PnConfiguration with default values
84+
* Initialize the PNConfiguration with default values
8585
*/
86-
public PnConfiguration() {
87-
setPresenceTimingConfiguration(300);
86+
public PNConfiguration() {
87+
setPresenceTimeout(300);
8888

8989
uuid = UUID.randomUUID().toString();
9090

@@ -101,7 +101,7 @@ public PnConfiguration() {
101101
* @param interval presence announce interval, how often the client should announce itself.
102102
* @return returns itself.
103103
*/
104-
public PnConfiguration setPresenceTimingConfiguration(final int timeout, final int interval) {
104+
public PNConfiguration setPresenceTimeoutWithCustomInterval(final int timeout, final int interval) {
105105
this.presenceTimeout = timeout;
106106
this.heartbeatInterval = interval;
107107

@@ -113,8 +113,8 @@ public PnConfiguration setPresenceTimingConfiguration(final int timeout, final i
113113
* @param timeout presence timeout; how long before the server considers this client to be gone.
114114
* @return returns itself.
115115
*/
116-
public PnConfiguration setPresenceTimingConfiguration(final int timeout) {
117-
return setPresenceTimingConfiguration(timeout,(timeout / 2) - 1);
116+
public PNConfiguration setPresenceTimeout(final int timeout) {
117+
return setPresenceTimeoutWithCustomInterval(timeout,(timeout / 2) - 1);
118118
}
119119

120120
}

src/main/java/com/pubnub/api/core/PnResponse.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/main/java/com/pubnub/api/core/Pubnub.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929

3030
@Getter
3131
@Slf4j
32-
public class Pubnub {
32+
public class PubNub {
3333

34-
private PnConfiguration configuration;
34+
private PNConfiguration configuration;
3535

3636
@Getter(AccessLevel.NONE)
3737
private SubscriptionManager subscriptionManager;
@@ -42,7 +42,7 @@ public class Pubnub {
4242

4343
private String sdkVersion;
4444

45-
public Pubnub(final PnConfiguration initialConfig) {
45+
public PubNub(final PNConfiguration initialConfig) {
4646
this.configuration = initialConfig;
4747
this.subscriptionManager = new SubscriptionManager(this);
4848
this.basePathManager = new BasePathManager(initialConfig);
@@ -154,9 +154,9 @@ public final DeleteChannelGroup deleteChannelGroup() {
154154
* @param inputString String to be encrypted
155155
* @return String containing the encryption of inputString using cipherKey
156156
*/
157-
public final String decrypt(String inputString) throws PubnubException {
157+
public final String decrypt(String inputString) throws PubNubException {
158158
if (inputString == null) {
159-
throw PubnubException.builder().pubnubError(PubnubError.PNERROBJ_INVALID_ARGUMENTS).build();
159+
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_INVALID_ARGUMENTS).build();
160160
}
161161

162162
return decrypt(inputString, this.getConfiguration().getCipherKey());
@@ -166,12 +166,12 @@ public final String decrypt(String inputString) throws PubnubException {
166166
* Perform Cryptographic decryption of an input string using the cipher key
167167
* @param inputString String to be encrypted
168168
* @param cipherKey cipher key to be used for encryption
169-
* @throws PubnubException throws exception in case of failed encryption
169+
* @throws PubNubException throws exception in case of failed encryption
170170
* @return String containing the encryption of inputString using cipherKey
171171
*/
172-
public final String decrypt(final String inputString, final String cipherKey) throws PubnubException {
172+
public final String decrypt(final String inputString, final String cipherKey) throws PubNubException {
173173
if (inputString == null) {
174-
throw PubnubException.builder().pubnubError(PubnubError.PNERROBJ_INVALID_ARGUMENTS).build();
174+
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_INVALID_ARGUMENTS).build();
175175
}
176176

177177
return new Crypto(cipherKey).decrypt(inputString);
@@ -182,9 +182,9 @@ public final String decrypt(final String inputString, final String cipherKey) th
182182
* @param inputString String to be encrypted
183183
* @return String containing the encryption of inputString using cipherKey
184184
*/
185-
public final String encrypt(final String inputString) throws PubnubException {
185+
public final String encrypt(final String inputString) throws PubNubException {
186186
if (inputString == null) {
187-
throw PubnubException.builder().pubnubError(PubnubError.PNERROBJ_INVALID_ARGUMENTS).build();
187+
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_INVALID_ARGUMENTS).build();
188188
}
189189

190190
return encrypt(inputString, this.getConfiguration().getCipherKey());
@@ -194,12 +194,12 @@ public final String encrypt(final String inputString) throws PubnubException {
194194
* Perform Cryptographic encryption of an input string and the cipher key.
195195
* @param inputString String to be encrypted
196196
* @param cipherKey cipher key to be used for encryption
197-
* @throws PubnubException throws exception in case of failed encryption
197+
* @throws PubNubException throws exception in case of failed encryption
198198
* @return String containing the encryption of inputString using cipherKey
199199
*/
200-
public final String encrypt(final String inputString, final String cipherKey) throws PubnubException {
200+
public final String encrypt(final String inputString, final String cipherKey) throws PubNubException {
201201
if (inputString == null) {
202-
throw PubnubException.builder().pubnubError(PubnubError.PNERROBJ_INVALID_ARGUMENTS).build();
202+
throw PubNubException.builder().pubnubError(PubNubError.PNERROBJ_INVALID_ARGUMENTS).build();
203203
}
204204

205205
return new Crypto(cipherKey).encrypt(inputString);

0 commit comments

Comments
 (0)