public void copy() throws Exception {
LOGGER.log(Level.INFO, "Starting synchronization from ArcGIS Server "+source.getRestUrl()+" into Portal for ArcGIS "+destination.getConnection().getHost());
RequestContext requestContext = RequestContext.extract(null);
try {
ArcGISQueryBuilder qb = new ArcGISQueryBuilder(new IterationContext() {
@Override
public void onIterationException(Exception ex) {
LOGGER.log(Level.SEVERE, "Error iterating through AGS resources.", ex);
}
}, source);
Query newQuery = qb.newQuery(new CommonCriteria());
Result result = newQuery.execute();
this.destination.getConnection().generateToken();
Iterable<IServiceInfoProvider> records = new ServiceInfoProviderAdapter(new FlatResourcesAdapter(result.getResources()));