Skip to content

Instantly share code, notes, and snippets.

View billy-bacon's full-sized avatar

Billy Bacon billy-bacon

View GitHub Profile
<route id="patronBorrowsAvailableTimer">
<from uri="{{borrows.available.notification.timer}}"/>
<log message="start" loggingLevel="INFO"/>
<wireTap uri="{{cloud.watch.out}}" copy="false">
<!-- this adds a cloud watch metric -->
<setHeader headerName="metricName"><constant>PatronBorrowsAvailableTimer</constant></setHeader>
<setHeader headerName="metricUnit"><constant>Count</constant></setHeader>
<setHeader headerName="metricValue"><constant>1</constant></setHeader>
## Push Notifications (universal processor used for many types of push notification processing) ##
patron.device.list.processor=mock:patronDeviceListProcessor
# Fire at 10:15am on the 3rd Wednesday of every month
borrows.available.notification.timer=direct://borrows.available.notification.timer
borrows.available.trigger.out=mock:borrows.available
borrows.available.trigger.in=direct:borrows.available
borrows.available.processor=mock:borrowsAvailableProcessor
public class PatronBorrowsAvailableTimerRouteTest extends AbstractRouteTest {
@Produce(uri = "{{borrows.available.notification.timer}}")
protected ProducerTemplate start;
@EndpointInject(uri = "{{cloud.watch.out}}")
protected MockEndpoint cloudWatchEndpoint;
@EndpointInject(uri = "{{borrows.available.trigger.out}}")
@Component("pushNotificationListProcessor")
public class PushNotificationListProcessor {
private static final Logger log = LoggerFactory.getLogger(PushNotificationMessageProcessor.class);
private final PatronDeviceHelper patronDeviceHelper;
@Autowired
public PushNotificationListProcessor(final PatronDeviceHelper patronDeviceHelper) {
this.patronDeviceHelper = patronDeviceHelper;
}
package com.alexandria.licenseproxy.stripes.ebook;
import com.alexandria.licenseproxy.helper.CircHelper;
import com.alexandria.licenseproxy.helper.EBookHelper;
import com.google.inject.Inject;
import net.sourceforge.stripes.action.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletResponse;
<select id="getRemainingBorrowsForMonth" resultType="java.lang.Integer">
select
(
select circsPerPatronMonth
from Account
where libraryId = (select libraryId from Patron where id=#{value})
)
-
(
select count(*)
package com.alex.integration.processor;
import com.alex.integration.bean.PatronDevice;
import com.alex.integration.bean.Platform;
import com.alex.integration.bean.PushNotificationMessage;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.sns.AmazonSNS;
import com.amazonaws.services.sns.model.*;
import com.fasterxml.jackson.core.JsonProcessingException;
@Mock
private PublishResult publishResult;
@Value("${GOOGLE_SERVER_API_KEY}")
private String googleServerApiKey;
@Value("${APPLE_CERT_FILE}")
private String appleCertificate;
@Value("${APPLE_PRIVATE_KEY_FILE}")
private CreatePlatformApplicationResult createPlatformApplication(String applicationName, Platform platform, String principal, String credential) {
CreatePlatformApplicationRequest platformApplicationRequest = new CreatePlatformApplicationRequest();
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("PlatformPrincipal", principal == null ? "" : principal);
attributes.put("PlatformCredential", credential);
platformApplicationRequest.setAttributes(attributes);
platformApplicationRequest.setName(applicationName);
platformApplicationRequest.setPlatform(platform.name());
return snsClient.createPlatformApplication(platformApplicationRequest);
}
// todo: figure out how to load this from PEM file
// (ANDROID) not applicable; this will be null;
// (iOS) the certificate in pem format with \n at the end of each line.
private String principal;
// todo: figure out how to load this from PEM file
// (ANDROID) the server api key from the google api console
// (iOS) the private key in pem format with \n at the end of each line.
private String credential;