Revision ce18bb89
Added by Cherian Mathew over 8 years ago
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/service/CdmServiceRequestExecutor.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 | 4 |
import java.io.OutputStream; |
5 |
import java.util.HashSet; |
|
6 |
import java.util.Set; |
|
5 | 7 |
|
6 | 8 |
import org.apache.log4j.Logger; |
7 | 9 |
import org.springframework.remoting.httpinvoker.HttpInvokerClientConfiguration; |
... | ... | |
23 | 25 |
|
24 | 26 |
private RemoteInvocation currentRemoteInvocation; |
25 | 27 |
|
28 |
protected final static Set<String> cachableMethods = new HashSet<String>(); |
|
26 | 29 |
|
27 | 30 |
|
31 |
|
|
32 |
public CdmServiceRequestExecutor() { |
|
33 |
cachableMethods.add("merge"); |
|
34 |
cachableMethods.add("save"); |
|
35 |
cachableMethods.add("findWithUpdate"); |
|
36 |
cachableMethods.add("loadWithUpdate"); |
|
37 |
} |
|
38 |
|
|
28 | 39 |
@Override |
29 | 40 |
protected void writeRemoteInvocation(RemoteInvocation invocation, OutputStream os) throws IOException { |
30 | 41 |
if(cdmEntitySessionManager == null) { |
... | ... | |
42 | 53 |
java.lang.ClassNotFoundException { |
43 | 54 |
RemoteInvocationResult rir = fromCache(currentRemoteInvocation); |
44 | 55 |
|
45 |
// if rir is not null at this point we assume that the |
|
46 |
// the object has already been loaded in the cache and |
|
47 |
// does not need to be reloaded |
|
48 |
|
|
49 | 56 |
if(rir == null) { |
50 | 57 |
logger.info("Remote invoking : " + currentRemoteInvocation.getMethodName() + "@" + config.getServiceUrl()); |
51 | 58 |
rir = super.doExecuteRequest(config, baos); |
52 | 59 |
if(rir.getValue() != null && !rir.hasException()) { |
53 |
if("merge".equals(currentRemoteInvocation.getMethodName()) || |
|
54 |
"save".equals(currentRemoteInvocation.getMethodName()) || |
|
55 |
"findWithUpdate".equals(currentRemoteInvocation.getMethodName())) { |
|
56 |
rir = new RemoteInvocationResult(cdmEntitySessionManager.load(rir.getValue(), true)); |
|
60 |
if(cachableMethods.contains(currentRemoteInvocation.getMethodName())) { |
|
61 |
rir = new RemoteInvocationResult(cdmEntitySessionManager.load(rir.getValue(), true)); |
|
57 | 62 |
} else if(rir.getValue() instanceof UpdateResult){ |
58 | 63 |
UpdateResult result = (UpdateResult)rir.getValue(); |
59 | 64 |
if(result.isOk()){ |
Also available in: Unified diff
#5309, #5310 Add load method to retrieve user entity after create and password change