2 * An AOP (AspectJ) aspect to resolve the timezone related issue https://issues.collectionspace.org/browse/DRYD-182.
4 * See related config in files: src/main/resources/META-INF/aop.xml, src/main/webapp/WEB-INF/applicationContext-security.xml
7 package org.collectionspace.services.aspect;
10 import javax.xml.datatype.XMLGregorianCalendar;
12 import org.aspectj.lang.ProceedingJoinPoint;
13 import org.aspectj.lang.annotation.Aspect;
14 import org.aspectj.lang.annotation.Around;
15 import org.aspectj.lang.annotation.Pointcut;
18 public class HyperJaxb3TimezoneAspect {
20 @Around("methodsToBeProfiled()")
21 public Object profile(ProceedingJoinPoint pjp) throws Throwable {
23 Date fromDate = (Date)pjp.getArgs()[0];
24 XMLGregorianCalendar toDate = (XMLGregorianCalendar)pjp.getArgs()[1];
26 Object result = pjp.proceed();
28 // Marshal the timezone info from the 'fromDate' Date instance into the XMLGregorianCalendar 'toDate' instance
30 toDate.setTimezone(fromDate.getTimezoneOffset());
39 * Intercept all calls to the createCalendar() method of the XMLGregorianCalendarAsDateTime class. This is how HyperJaxb3 marshals datetime info from Hibernate/JPA into
40 * out AuthN/AuthZ class instances.
42 @Pointcut("execution(* org.jvnet.hyperjaxb3.xml.bind.annotation.adapters.XMLGregorianCalendarAsDateTime.createCalendar(java.util.Date, javax.xml.datatype.XMLGregorianCalendar))")
43 public void methodsToBeProfiled() {}