Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #160 from bsura/2.1_release
Browse files Browse the repository at this point in the history
Manual merge of 2.0 into develop
  • Loading branch information
dilipdevaraj-sfdc authored Sep 16, 2016
2 parents a79ba49 + 99640d1 commit c9513dd
Show file tree
Hide file tree
Showing 11 changed files with 933 additions and 512 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void run() {
while (!Thread.currentThread().isInterrupted()) {
try {
jobCounter.addAndGet(service.executeScheduledAlerts(10, timeout).size());
LOGGER.info("alerts evaluated so far: ", jobCounter.get());
LOGGER.info("alerts evaluated so far: {}", jobCounter.get());
Thread.sleep(POLL_INTERVAL_MS);
} catch (InterruptedException ex) {
LOGGER.info("Execution was interrupted.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.salesforce.dva.argus.system.SystemConfiguration;
import com.salesforce.dva.argus.system.SystemException;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.sql.Date;
import java.text.MessageFormat;
Expand Down Expand Up @@ -95,13 +96,13 @@ public GOCNotifier(MetricService metricService, AnnotationService annotationServ

//~ Methods **************************************************************************************************************************************

private PostMethod getRequestMethod(boolean refresh, String id) {
private PostMethod getRequestMethod(boolean refresh, String id) throws UnsupportedEncodingException {
GOCTransport gocTransport = new GOCTransport();
EndpointInfo endpointInfo = gocTransport.getEndpointInfo(_config, _logger, refresh);

// Create upsert URI with PATCH method
PostMethod post = new PostMethod(String.format("%s/services/data/v25.0/sobjects/SM_Alert__c/%s/%s", endpointInfo.getEndPoint(),
GOCData.SM_ALERT_ID__C_FIELD, id)) {
urlEncode(GOCData.SM_ALERT_ID__C_FIELD), urlEncode(id))) {

@Override
public String getName() {
Expand Down Expand Up @@ -144,9 +145,10 @@ public void sendMessage(Severity severity, String className, String elementName,

for (int i = 0; i < 2; i++) {

PostMethod post = getRequestMethod(refresh, gocData.getsm_Alert_Id__c());
PostMethod post = null;

try {
post=getRequestMethod(refresh, gocData.getsm_Alert_Id__c());
post.setRequestEntity(new StringRequestEntity(gocData.toJSON(), "application/json", null));

int respCode = httpclient.executeMethod(post);
Expand All @@ -166,7 +168,9 @@ public void sendMessage(Severity severity, String className, String elementName,
_logger.error("Failure - send GOC++ having element '{}' event '{}' severity {}. Exception '{}'", elementName, eventName,
severity.name(), e);
} finally {
post.releaseConnection();
if(post != null){
post.releaseConnection();
}
}
}
} catch (RuntimeException ex) {
Expand Down Expand Up @@ -268,6 +272,10 @@ public Properties getNotifierProperties() {
return notifierProps;
}

private String urlEncode(String s) throws UnsupportedEncodingException{
return URLEncoder.encode(s,org.apache.commons.lang3.CharEncoding.UTF_8).replace("+", "%20");
}

//~ Enums ****************************************************************************************************************************************

/**
Expand Down Expand Up @@ -296,9 +304,9 @@ public enum Property {
/** The GOC password with which to authenticate. */
GOC_PWD("notifier.property.goc.password", "test_password"),
/** The GOC proxy host. */
GOC_PROXY_HOST("notifier.property.goc.proxy.host", ""),
GOC_PROXY_HOST("notifier.property.proxy.host", ""),
/** The GOC port. */
GOC_PROXY_PORT("notifier.property.goc.proxy.port", ""),
GOC_PROXY_PORT("notifier.property.proxy.port", ""),
/** The GOC client ID. */
GOC_CLIENT_ID("notifier.property.goc.client.id", "default_client_id"),
/** The GOC client secret. */
Expand Down
Loading

0 comments on commit c9513dd

Please sign in to comment.