01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.geoserver.wfsv;
06:
07: import java.io.IOException;
08:
09: import net.opengis.wfs.TransactionType;
10:
11: import org.acegisecurity.context.SecurityContextHolder;
12: import org.acegisecurity.userdetails.UserDetails;
13: import org.geoserver.wfs.Transaction;
14: import org.geoserver.wfs.WFS;
15: import org.geotools.data.DefaultTransaction;
16: import org.geotools.data.postgis.VersionedPostgisDataStore;
17: import org.springframework.context.ApplicationContext;
18: import org.vfny.geoserver.global.Data;
19:
20: /**
21: * Extends the base transaction to handle extended versioning elements
22: *
23: * @author Andrea Aime, TOPP
24: */
25: public class VersioningTransaction extends Transaction {
26: public VersioningTransaction(WFS wfs, Data catalog,
27: ApplicationContext context) {
28: super (wfs, catalog, context);
29: }
30:
31: protected DefaultTransaction getDatastoreTransaction(
32: TransactionType request) throws IOException {
33: DefaultTransaction transaction = new DefaultTransaction();
34: // use handle as the log messages
35: String username = "anonymous";
36: Object principal = SecurityContextHolder.getContext()
37: .getAuthentication().getPrincipal();
38: if (principal instanceof UserDetails) {
39: username = ((UserDetails) principal).getUsername();
40: }
41: transaction.putProperty(VersionedPostgisDataStore.AUTHOR,
42: username);
43: transaction.putProperty(VersionedPostgisDataStore.MESSAGE,
44: request.getHandle());
45:
46: return transaction;
47: }
48:
49: }
|