* Executes copy action.
* @throws Exception if anything fails
*/
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()));
for (IServiceInfoProvider r: records) {
if (!doContinue()) {
break;
}
ServiceInfo serviceInfo = r.getServiceInfo();
AgpItem agpItem = createAgpItem(serviceInfo);
if (agpItem!=null) {
syncItem(agpItem);
}
}
} finally {
requestContext.onExecutionPhaseCompleted();
LOGGER.log(Level.INFO, "Completed synchronization from ArcGIS Server "+source.getRestUrl()+" into Portal for ArcGIS "+destination.getConnection().getHost());
}
}