Skip to content

Commit

Permalink
fix: build source and javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
shawndenggh committed Dec 4, 2023
1 parent 13fe9a0 commit d9dc7fa
Show file tree
Hide file tree
Showing 71 changed files with 695 additions and 475 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
apply from: 'lib.gradle'

group = 'cn.vika'
version = '1.0.4'
version = '1.0.5'

java {
withJavadocJar()
Expand Down
7 changes: 6 additions & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ dependencies {
}

group = 'cn.vika'
version = '1.0.4'
version = '1.0.5'

java {
withJavadocJar()
withSourcesJar()
}

publishing {
publications {
Expand Down
7 changes: 6 additions & 1 deletion dingtalk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ dependencies {
}

group = 'cn.vika'
version = '1.0.4'
version = '1.0.5'

java {
withJavadocJar()
withSourcesJar()
}

publishing {
publications {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public interface DingTalk {

/**
* isv market application interface
* @return IsvAppOperations
*/
IsvAppOperations isvAppOperations();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,44 @@ public class DingTalkEventListenerManager {
* The processing memory corresponding to the callback event
* Event -> callbackHandler implementation
*/
private final Map<Class<? extends BaseEvent>, DingTalkEventCallbackHandler<?>> eventHandlerMap = new HashMap<>();
private final Map<Class<? extends BaseEvent>, DingTalkEventCallbackHandler<?>> eventHandlerMap =
new HashMap<>();

/**
* Handling callback events
* @param event callback event
* @param <T> Callback event infrastructure
*
* @param agentId agent id
* @param event callback event
* @param <T> Callback event infrastructure
* @return event specified response result
*/
public <T extends BaseEvent> Object fireEventCallback(String agentId, T event) {
Class<?> clazz = event.getClass();
DingTalkEventCallbackHandler<T> callbackHandler = null;
// Find the corresponding event handler
while (callbackHandler == null && BaseEvent.class.isAssignableFrom(clazz)) {
callbackHandler = MapUtil.get(eventHandlerMap, clazz, new TypeReference<DingTalkEventCallbackHandler<T>>() {
});
callbackHandler = MapUtil.get(eventHandlerMap, clazz,
new TypeReference<DingTalkEventCallbackHandler<T>>() {
});
clazz = clazz.getSuperclass();
}

if (callbackHandler == null) {
throw new IllegalStateException("Can't find a solution for the app" + event.getClass().getName());
throw new IllegalStateException(
"Can't find a solution for the app" + event.getClass().getName());
}
return callbackHandler.doHandle(agentId, event);
}

/**
* register event handler
*
* @param clazz callback event
* @param handler The handler corresponding to the callback event
* @param <T> Events that inherit Base Event
*/
public <T extends BaseEvent> void registerEventCallbackHandler(Class<T> clazz, DingTalkEventCallbackHandler<T> handler) {
public <T extends BaseEvent> void registerEventCallbackHandler(Class<T> clazz,
DingTalkEventCallbackHandler<T> handler) {
if (clazz != null && handler != null) {
eventHandlerMap.put(clazz, handler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,25 @@ public DingTalkTemplate getDingTalkTemplate() {
/**
* event subscription push
*
* @param agentId The agent ID of the app
* @param agentId The agent ID of the app
* @param msgSignature message body signature
* @param nonce random string
* @param encryptMsg Push the encrypt in the body data
* @param timeStamp timestamp
* @param nonce random string
* @param encryptMsg Push the encrypt in the body data
* @return String
*/
public String eventNotify(String agentId, String msgSignature, String timeStamp, String nonce, String encryptMsg) {
public String eventNotify(String agentId, String msgSignature, String timeStamp, String nonce,
String encryptMsg) {
// Parse into JSON structure
AgentApp agentApp = getDingTalkTemplate().getDingTalkConfig().getAgentAppStorage().getAgentApp(agentId);
AgentApp agentApp =
getDingTalkTemplate().getDingTalkConfig().getAgentAppStorage().getAgentApp(agentId);
DingTalkCallbackCrypto callbackCrypto;
String decryptMsg;
try {
callbackCrypto = new DingTalkCallbackCrypto(agentApp.getToken(), agentApp.getAesKey(), agentApp.getCustomKey());
callbackCrypto = new DingTalkCallbackCrypto(agentApp.getToken(), agentApp.getAesKey(),
agentApp.getCustomKey());
decryptMsg = callbackCrypto.getDecryptMsg(msgSignature, timeStamp, nonce, encryptMsg);
}
catch (DingTalkEncryptException e) {
} catch (DingTalkEncryptException e) {
LOGGER.error("DingTalk failed to parse event data", e);
return "";
}
Expand All @@ -128,7 +131,8 @@ public String eventNotify(String agentId, String msgSignature, String timeStamp,
LOGGER.info("DingTalk push eventType[{}]", eventType);
BaseEvent event = eventParser.parseEvent(eventTag, eventJson);
if (event == null) {
LOGGER.info("Cannot find DingTalk event listener, Whether a handler is not configured for this event, not handle by default");
LOGGER.info(
"Cannot find DingTalk event listener, Whether a handler is not configured for this event, not handle by default");
return "";
}
// Determine the current agent Id
Expand All @@ -139,8 +143,7 @@ public String eventNotify(String agentId, String msgSignature, String timeStamp,
try {
Map<String, String> jsonMap = callbackCrypto.getEncryptedMap("success");
return JSONUtil.toJsonStr(jsonMap);
}
catch (DingTalkEncryptException e) {
} catch (DingTalkEncryptException e) {
LOGGER.error("DingTalk encryption return message failed", e);
return "";
}
Expand All @@ -149,22 +152,23 @@ public String eventNotify(String agentId, String msgSignature, String timeStamp,
/**
* SyncHTTP ISV DingTalk event subscription push method
*
* @param suiteId suite Id
* @param suiteId suite Id
* @param msgSignature message body signature
* @param nonce random string
* @param encryptMsg Push the encrypt in the body data
* @param timeStamp timestamp
* @param nonce random string
* @param encryptMsg Push the encrypt in the body data
* @return response result
*/
public String syncHttpEventNotifyForIsv(String suiteId, String msgSignature, String timeStamp, String nonce,
String encryptMsg) {
public String syncHttpEventNotifyForIsv(String suiteId, String msgSignature, String timeStamp,
String nonce,
String encryptMsg) {
// Parse into JSON structure
DingTalkCallbackCrypto callbackCrypto;
String decryptMsg;
try {
callbackCrypto = getIsvDingTalkCallbackCrypto(suiteId);
decryptMsg = callbackCrypto.getDecryptMsg(msgSignature, timeStamp, nonce, encryptMsg);
}
catch (Exception e) {
} catch (Exception e) {
LOGGER.error("DingTalk isv parse event error", e);
return "";
}
Expand All @@ -178,10 +182,10 @@ public String syncHttpEventNotifyForIsv(String suiteId, String msgSignature, Str
return "";
}
try {
Map<String, String> jsonMap = callbackCrypto.getEncryptedMap(DING_TALK_CALLBACK_SUCCESS);
Map<String, String> jsonMap =
callbackCrypto.getEncryptedMap(DING_TALK_CALLBACK_SUCCESS);
return JSONUtil.toJsonStr(jsonMap);
}
catch (DingTalkEncryptException e) {
} catch (DingTalkEncryptException e) {
LOGGER.error("DingTalk isv encryption return message failed", e);
return "";
}
Expand All @@ -190,12 +194,14 @@ public String syncHttpEventNotifyForIsv(String suiteId, String msgSignature, Str
/**
* Parse and handle events
*
* @param bizId suite ID/ biz id
* @param bizId suite ID/ biz id
* @param eventJson event message body
* @param corpId corp id, can be null
* @param corpId corp id, can be null
* @param suiteId suite id, can be null
* @return Object
*/
public Object handleIsvAppEventNotify(String bizId, JSONObject eventJson, String corpId, String suiteId) {
public Object handleIsvAppEventNotify(String bizId, JSONObject eventJson, String corpId,
String suiteId) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("DingTalk isv event data:[{}]", eventJson);
}
Expand Down Expand Up @@ -225,13 +231,13 @@ public Object handleIsvAppEventNotify(String bizId, JSONObject eventJson, String
eventJson.set(EVENT_SYNC_ACTION_SUITE_ID_KEY, suiteId);
}
event = eventParser.parseEvent(syncAction, eventJson);
}
else {
} else {
LOGGER.info("DingTalk isv eventType[{}]", eventType);
event = eventParser.parseEvent(eventTag, eventJson);
}
if (event == null) {
LOGGER.info("Cannot find DingTalk isv event listener, Whether a handler is not configured for this event, not handle by default");
LOGGER.info(
"Cannot find DingTalk isv event listener, Whether a handler is not configured for this event, not handle by default");
return DING_TALK_CALLBACK_SUCCESS;
}
return eventListenerManager.fireEventCallback(bizId, event);
Expand All @@ -244,9 +250,9 @@ public DingTalkCallbackCrypto getIsvDingTalkCallbackCrypto(String suiteId) {
return null;
}
try {
return new DingTalkCallbackCrypto(isvApp.getToken(), isvApp.getAesKey(), isvApp.getSuiteKey());
}
catch (DingTalkEncryptException e) {
return new DingTalkCallbackCrypto(isvApp.getToken(), isvApp.getAesKey(),
isvApp.getSuiteKey());
} catch (DingTalkEncryptException e) {
LOGGER.error("DingTalk decrypt data error", e);
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public interface IsvAppOperations {
/**
* Obtain enterprise authorization information
* When third-party enterprise applications and customized service providers develop internal enterprise applications for enterprises,
* call this API to obtain enterprise authorization information
* call this API to obtain enterprise authorization information.
*
* @param suiteId suite id
* @param authCorpId The corpid of the authorized enterprise
Expand All @@ -100,7 +100,7 @@ public interface IsvAppOperations {
* Get the identity information of the application administrator
*
* @param suiteId suite id
* @param code The code brought to the URL through Oauth authentication
* @param code The code brought to the URL through Oauth authentication.
* @return DingTalkSsoUserInfoResponse
*/
DingTalkSsoUserInfoResponse getSsoUserInfoByCode(String suiteId, String code);
Expand Down Expand Up @@ -198,7 +198,7 @@ DingTalkSkuPageResponse getInternalSkuPage(String suiteId, String authCorpId, St

/**
* In-app purchase order processing completed
* Call this interface to complete in-app purchase order processing
* Call this interface to complete in-app purchase order processing.
*
* @param suiteId suite id
* @param authCorpId The corpid of the authorized enterprise
Expand Down
Loading

0 comments on commit d9dc7fa

Please sign in to comment.