Commit ed3e01e9 authored by Brian Long's avatar Brian Long
Browse files

Merge branch 'develop' into stable

parents 93210840 bca4c401
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -136,8 +136,14 @@ public class RetryingTransactionAspect {
						if (txl.isReadOnly())
							throw new IllegalTransactionStateException("A read/write transaction exists where a read-only one is mandatory");
				}
			case NOT_SUPPORTED:
				switch (AlfrescoTransactionSupport.getTransactionReadState()) {
					case TXN_NONE:
						return false;
					default:
						throw new IllegalTransactionStateException("A transaction exists and pausing it is not supported");
				}
			case SUPPORTS:
			//case NOT_SUPPORTED:  not supported; we would have to create another thread to simulate
				return false;
			case REQUIRED:
				switch (AlfrescoTransactionSupport.getTransactionReadState()) {
+46 −6
Original line number Diff line number Diff line
@@ -9,6 +9,15 @@ import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.time.OffsetTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.Temporal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -479,7 +488,28 @@ public class MqAsyncService extends AbstractLifecycleBean implements AsyncServic
    	Class<?> paramType = param.getType();
		this.logger.trace("Unmarshaling parameter of type: {}", paramType);

		if (Version.class.isAssignableFrom(paramType)) {
    	if (arg instanceof String || arg instanceof Number || arg instanceof Boolean) {
			this.logger.trace("Unmarshaling primitive: {}", arg);
			return arg;
    	} else if (Temporal.class.isAssignableFrom(paramType)) {
    		if (OffsetDateTime.class.isAssignableFrom(paramType)) {
    			return OffsetDateTime.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(arg.toString()));
    		} else if (ZonedDateTime.class.isAssignableFrom(paramType)) {
    			return ZonedDateTime.from(DateTimeFormatter.ISO_ZONED_DATE_TIME.parse(arg.toString()));
    		} else if (LocalDate.class.isAssignableFrom(paramType)) {
    			return LocalDate.from(DateTimeFormatter.ISO_LOCAL_DATE.parse(arg.toString()));
    		} else if (LocalDateTime.class.isAssignableFrom(paramType)) {
    			return LocalDateTime.from(DateTimeFormatter.ISO_LOCAL_DATE_TIME.parse(arg.toString()));
    		} else if (Instant.class.isAssignableFrom(paramType)) {
    			return Instant.from(DateTimeFormatter.ISO_INSTANT.parse(arg.toString()));
    		} else if (LocalTime.class.isAssignableFrom(paramType)) {
    			return LocalTime.from(DateTimeFormatter.ISO_LOCAL_TIME.parse(arg.toString()));
    		} else if (OffsetTime.class.isAssignableFrom(paramType)) {
    			return OffsetTime.from(DateTimeFormatter.ISO_OFFSET_TIME.parse(arg.toString()));
    		} else {
    			throw new UnsupportedOperationException();
    		}
    	} else if (Version.class.isAssignableFrom(paramType)) {
			this.logger.trace("Unmarshaling as JSON object: {}", arg);
			Map<String, Object> argMap = (Map<String, Object>) this.om.convertValue(arg, Map.class);
			
@@ -515,13 +545,22 @@ public class MqAsyncService extends AbstractLifecycleBean implements AsyncServic
			return cons.invoke(null, arg.toString());
		} else {
			this.logger.trace("Unmarshaling as POJO: {}", arg);
			try {
				Constructor<?> cons = paramType.getConstructor(String.class);
				return cons.newInstance(arg.toString());
			} catch (NoSuchMethodException nsme) {
				Method method = paramType.getDeclaredMethod("valueOf", String.class);
				return method.invoke(null, arg.toString());
			}
		}
    }
    
    private Object marshal(Object arg) {
		if (arg instanceof Version) {
    	if (arg instanceof String || arg instanceof Number || arg instanceof Boolean) {
    		return arg;
    	} else if (arg instanceof Temporal) {
    		return arg.toString();
    	} else if (arg instanceof Version) {
			Version version = (Version) arg;
			Map<String, Object> map = new HashMap<>();
			map.put("nodeRef", version.getFrozenStateNodeRef());
@@ -555,7 +594,8 @@ public class MqAsyncService extends AbstractLifecycleBean implements AsyncServic
			this.logger.trace("Marshaling Java Map as JSON object: {}", map);
			return this.om.convertValue(map, String.class);
		} else {
			return arg;
			this.logger.trace("Marshaling Java object as JSON object: {}", arg);
			return this.om.convertValue(arg, String.class);
		}
    }
    
+32 −0
Original line number Diff line number Diff line
package com.inteligr8.alfresco.annotations.util;

import java.util.HashMap;
import java.util.Map;

import org.alfresco.util.Pair;

public class MapUtils {
	
	public static <K, V> Map<K, V> build(Pair<K, V>... pairs) {
		Map<K, V> map = new HashMap<>();
		for (Pair<K, V> pair : pairs) {
			map.put(pair.getFirst(), pair.getSecond());
		}
		
		return map;
	}
	
	public static Map<String, String> build(String... keyValuePairs) {
		if (keyValuePairs.length % 2 == 1)
			throw new IllegalArgumentException();
		
		Map<String, String> map = new HashMap<>();
		for (int pair = 0; pair < keyValuePairs.length / 2; pair++) {
			int base = pair * 2;
			map.put(keyValuePairs[base], keyValuePairs[base + 1]);
		}
		
		return map;
	}

}
+0 −0

File moved.

+0 −0

File moved.

Loading