Revision 3315 org.gvsig.vcsgis/trunk/org.gvsig.vcsgis/org.gvsig.vcsgis.lib/org.gvsig.vcsgis.lib.impl/src/main/java/org/gvsig/vcsgis/lib/workspace/VCSGisWorkspaceImpl.java
VCSGisWorkspaceImpl.java | ||
---|---|---|
14 | 14 |
import java.util.Map; |
15 | 15 |
import java.util.Objects; |
16 | 16 |
import java.util.Set; |
17 |
import java.util.function.Consumer; |
|
18 | 17 |
import javax.json.JsonObject; |
19 | 18 |
import org.apache.commons.lang3.StringUtils; |
20 | 19 |
import org.apache.commons.lang3.mutable.MutableObject; |
... | ... | |
63 | 62 |
import org.gvsig.vcsgis.lib.VCSGisChange; |
64 | 63 |
import org.gvsig.vcsgis.lib.VCSGisCodeGenerator; |
65 | 64 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
66 |
import org.gvsig.vcsgis.lib.VCSGisEntityEditable; |
|
67 | 65 |
import static org.gvsig.vcsgis.lib.VCSGisManager.DEFAULT_DATA_TABLE; |
68 | 66 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_AUTHENTICATION_EXPIRED; |
69 | 67 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_CANCELLED_BY_USER; |
... | ... | |
108 | 106 |
import static org.gvsig.vcsgis.lib.VCSGisManagerImpl.INTERNAL_WORKSPACE_TABLES; |
109 | 107 |
import org.gvsig.vcsgis.lib.VCSGisRevision; |
110 | 108 |
import org.gvsig.vcsgis.lib.VCSGisRuntimeException; |
109 |
import org.gvsig.vcsgis.lib.VCSGisTopologyPlan; |
|
111 | 110 |
import org.gvsig.vcsgis.lib.VCSGisUser; |
112 | 111 |
import org.gvsig.vcsgis.lib.VCSGisUtils; |
113 | 112 |
import org.gvsig.vcsgis.lib.repository.VCSGisRepository; |
... | ... | |
135 | 134 |
import org.gvsig.vcsgis.lib.VCSGisUserIdentificationRequester; |
136 | 135 |
import org.gvsig.vcsgis.lib.repository.requests.VCSGisAuthenticateRequest; |
137 | 136 |
import org.gvsig.vcsgis.lib.repository.requests.VCSGisRequest; |
137 |
import org.gvsig.vcsgis.lib.repository.requests.VCSGisTopologyPlansRequest; |
|
138 |
import org.gvsig.vcsgis.lib.repository.requests.VCSGisUsersRequest; |
|
138 | 139 |
import org.gvsig.vcsgis.lib.workspace.tables.TopologyplanTable; |
140 |
import org.gvsig.vcsgis.lib.workspace.tables.UsersTable; |
|
139 | 141 |
|
140 | 142 |
/** |
141 | 143 |
* |
... | ... | |
1835 | 1837 |
lentity.update(entitiesStore); |
1836 | 1838 |
entitiesStore.finishEditing(); |
1837 | 1839 |
this.forceReloadWorkspaceEntities(); |
1840 |
|
|
1841 |
UsersTable usersTable = new UsersTable(); |
|
1842 |
if( StringUtils.isNotBlank(request.getUsersHashCode()) ) { |
|
1843 |
if( StringUtils.equalsIgnoreCase(usersTable.getHashCode(this), request.getUsersHashCode())) { |
|
1844 |
updateUsersFromRepository(status); |
|
1845 |
} |
|
1846 |
} |
|
1847 |
TopologyplanTable topologyPlansTable = new TopologyplanTable(); |
|
1848 |
if( StringUtils.isNotBlank(request.getTopologyPlansHashCode()) ) { |
|
1849 |
if( StringUtils.equalsIgnoreCase(topologyPlansTable.getHashCode(this), request.getTopologyPlansHashCode())) { |
|
1850 |
updateTopologyPlansFromRepository(status); |
|
1851 |
} |
|
1852 |
} |
|
1838 | 1853 |
request.dispose(); |
1839 | 1854 |
|
1840 | 1855 |
status.message("Checkout completed"); |
... | ... | |
1844 | 1859 |
LOGGER.warn("Can't checkout.", ex); |
1845 | 1860 |
status.message("Can't checkout"); |
1846 | 1861 |
status.abort(); |
1847 |
if (target != null) { |
|
1848 |
target.cancelEditingQuietly(); |
|
1849 |
} |
|
1850 |
if (entitiesStore != null) { |
|
1851 |
entitiesStore.cancelEditingQuietly(); |
|
1852 |
} |
|
1862 |
FeatureStore.cancelEditingQuietly(target); |
|
1863 |
FeatureStore.cancelEditingQuietly(entitiesStore); |
|
1853 | 1864 |
return errcode; |
1854 | 1865 |
} finally { |
1855 | 1866 |
DisposeUtils.disposeQuietly(request); |
... | ... | |
1862 | 1873 |
} |
1863 | 1874 |
} |
1864 | 1875 |
|
1876 |
private void updateUsersFromRepository(SimpleTaskStatus status) { |
|
1877 |
FeatureStore usersStore = null; |
|
1878 |
VCSGisUsersRequest request = null; |
|
1879 |
try { |
|
1880 |
request = this.getRepository().createUsersRequest(); |
|
1881 |
request.setAuthenticationToken(this.authenticationToken); |
|
1882 |
request.setUserCode(this.currentUser); |
|
1883 |
|
|
1884 |
status.message("Executing users request"); |
|
1885 |
if ( execute(request) != ERR_OK) { |
|
1886 |
status.message("Can't get users (error " + request.getLastErrorCode() + ")"); |
|
1887 |
return; |
|
1888 |
} |
|
1889 |
status.message("Updating users information"); |
|
1890 |
usersStore = this.openFeatureStore(UsersTable.TABLE_NAME); |
|
1891 |
usersStore.edit(FeatureStore.MODE_PASS_THROUGH); |
|
1892 |
usersStore.delete("TRUE"); |
|
1893 |
for (VCSGisUser user : request.getUsers()) { |
|
1894 |
UsersTable.UserRow row = new UsersTable.UserRow(this); |
|
1895 |
row.copyFrom(user); |
|
1896 |
row.insert(usersStore); |
|
1897 |
} |
|
1898 |
usersStore.finishEditing(); |
|
1899 |
|
|
1900 |
} catch(Exception ex) { |
|
1901 |
LOGGER.warn("Can't update users.", ex); |
|
1902 |
status.message("Can't update users"); |
|
1903 |
FeatureStore.cancelEditingQuietly(usersStore); |
|
1904 |
} finally { |
|
1905 |
DisposeUtils.disposeQuietly(request); |
|
1906 |
DisposeUtils.disposeQuietly(usersStore); |
|
1907 |
} |
|
1908 |
} |
|
1909 |
|
|
1910 |
private void updateTopologyPlansFromRepository(SimpleTaskStatus status) { |
|
1911 |
FeatureStore topologyPlanStore = null; |
|
1912 |
VCSGisTopologyPlansRequest request = null; |
|
1913 |
try { |
|
1914 |
request = this.getRepository().createTopologyPlansRequest(); |
|
1915 |
request.setAuthenticationToken(this.authenticationToken); |
|
1916 |
request.setUserCode(this.currentUser); |
|
1917 |
|
|
1918 |
status.message("Executing topology plans request"); |
|
1919 |
if ( execute(request) != ERR_OK) { |
|
1920 |
status.message("Can't get topology plans (error " + request.getLastErrorCode() + ")"); |
|
1921 |
return; |
|
1922 |
} |
|
1923 |
status.message("Updating topology plans information"); |
|
1924 |
topologyPlanStore = this.openFeatureStore(TopologyplanTable.TABLE_NAME); |
|
1925 |
topologyPlanStore.edit(FeatureStore.MODE_PASS_THROUGH); |
|
1926 |
topologyPlanStore.delete("TRUE"); |
|
1927 |
for (VCSGisTopologyPlan topologyPlan : request.getTopologyPlans()) { |
|
1928 |
TopologyplanTable.TopologyPlanRow row = new TopologyplanTable.TopologyPlanRow(this); |
|
1929 |
row.copyFrom(topologyPlan); |
|
1930 |
row.insert(topologyPlanStore); |
|
1931 |
} |
|
1932 |
topologyPlanStore.finishEditing(); |
|
1933 |
|
|
1934 |
} catch(Exception ex) { |
|
1935 |
LOGGER.warn("Can't update topology plans.", ex); |
|
1936 |
status.message("Can't update topology plans"); |
|
1937 |
FeatureStore.cancelEditingQuietly(topologyPlanStore); |
|
1938 |
} finally { |
|
1939 |
DisposeUtils.disposeQuietly(request); |
|
1940 |
DisposeUtils.disposeQuietly(topologyPlanStore); |
|
1941 |
} |
|
1942 |
} |
|
1943 |
|
|
1865 | 1944 |
@Override |
1866 | 1945 |
public int updateEntitiesFromRepository() { |
1867 | 1946 |
return this.updateEntitiesFromRepository(null); |
Also available in: Unified diff