@Test public void checkCopyCatalog() throws URISyntaxException, IOException { String docBaseUriString = "http: URI docBaseUri = new URI( docBaseUriString ); String catalogAsString = setupCatalogWithNestedDatasets(); InvCatalogFactory fac = InvCatalogFactory.getDefaultFactory( true ); InvCatalogImpl catalog = fac.readXML( catalogAsString, docBaseUri ); assertCatalogAsExpected( catalog, docBaseUri ); String origCatAsString = fac.writeXML( catalog ); InvCatalog resultCatalog = DeepCopyUtils.copyCatalog( catalog ); assertCatalogAsExpected( resultCatalog, docBaseUri); String resultCatalogAsString = fac.writeXML( (InvCatalogImpl) resultCatalog ); assertEquals( origCatAsString, resultCatalogAsString ); assertEquals( catalog, resultCatalog); }
public static InvCatalog copyCatalog( InvCatalog catalog ) { if ( catalog == null ) throw new IllegalArgumentException( "Catalog may not be null." ); InvCatalogImpl resultCatalog = new InvCatalogImpl( catalog.getName(), "1.0", catalog.getExpires(), ((InvCatalogImpl) catalog).getBaseURI() ); List<InvService> copiedServices = copyServicesIntoCopiedCatalog( catalog, resultCatalog ); for ( InvDataset curDs : catalog.getDatasets()) { resultCatalog.addDataset( (InvDatasetImpl) DeepCopyUtils.copyDataset( curDs, copiedServices, false ) ); } resultCatalog.finish(); return resultCatalog; }
DeepCopyUtils { public static InvCatalog copyCatalog( InvCatalog catalog ) { if ( catalog == null ) throw new IllegalArgumentException( "Catalog may not be null." ); InvCatalogImpl resultCatalog = new InvCatalogImpl( catalog.getName(), "1.0", catalog.getExpires(), ((InvCatalogImpl) catalog).getBaseURI() ); List<InvService> copiedServices = copyServicesIntoCopiedCatalog( catalog, resultCatalog ); for ( InvDataset curDs : catalog.getDatasets()) { resultCatalog.addDataset( (InvDatasetImpl) DeepCopyUtils.copyDataset( curDs, copiedServices, false ) ); } resultCatalog.finish(); return resultCatalog; } }
DeepCopyUtils { public static InvCatalog copyCatalog( InvCatalog catalog ) { if ( catalog == null ) throw new IllegalArgumentException( "Catalog may not be null." ); InvCatalogImpl resultCatalog = new InvCatalogImpl( catalog.getName(), "1.0", catalog.getExpires(), ((InvCatalogImpl) catalog).getBaseURI() ); List<InvService> copiedServices = copyServicesIntoCopiedCatalog( catalog, resultCatalog ); for ( InvDataset curDs : catalog.getDatasets()) { resultCatalog.addDataset( (InvDatasetImpl) DeepCopyUtils.copyDataset( curDs, copiedServices, false ) ); } resultCatalog.finish(); return resultCatalog; } private  DeepCopyUtils(); }
DeepCopyUtils { public static InvCatalog copyCatalog( InvCatalog catalog ) { if ( catalog == null ) throw new IllegalArgumentException( "Catalog may not be null." ); InvCatalogImpl resultCatalog = new InvCatalogImpl( catalog.getName(), "1.0", catalog.getExpires(), ((InvCatalogImpl) catalog).getBaseURI() ); List<InvService> copiedServices = copyServicesIntoCopiedCatalog( catalog, resultCatalog ); for ( InvDataset curDs : catalog.getDatasets()) { resultCatalog.addDataset( (InvDatasetImpl) DeepCopyUtils.copyDataset( curDs, copiedServices, false ) ); } resultCatalog.finish(); return resultCatalog; } private  DeepCopyUtils(); static InvCatalog copyCatalog( InvCatalog catalog ); static InvCatalog subsetCatalogOnDataset( InvCatalog catalog, String datasetId ); static InvCatalog subsetCatalogOnDataset( InvCatalog catalog, InvDataset dataset); static InvDataset copyDataset( InvDataset dataset, List<InvService> availableServices,
                                        boolean copyInheritedMetadataFromParents ); static InvAccess copyAccess( InvAccess access, InvDataset parentDataset, List<InvService> availableServices ); static InvService copyService( InvService service ); static InvProperty copyProperty( InvProperty property); }
DeepCopyUtils { public static InvCatalog copyCatalog( InvCatalog catalog ) { if ( catalog == null ) throw new IllegalArgumentException( "Catalog may not be null." ); InvCatalogImpl resultCatalog = new InvCatalogImpl( catalog.getName(), "1.0", catalog.getExpires(), ((InvCatalogImpl) catalog).getBaseURI() ); List<InvService> copiedServices = copyServicesIntoCopiedCatalog( catalog, resultCatalog ); for ( InvDataset curDs : catalog.getDatasets()) { resultCatalog.addDataset( (InvDatasetImpl) DeepCopyUtils.copyDataset( curDs, copiedServices, false ) ); } resultCatalog.finish(); return resultCatalog; } private  DeepCopyUtils(); static InvCatalog copyCatalog( InvCatalog catalog ); static InvCatalog subsetCatalogOnDataset( InvCatalog catalog, String datasetId ); static InvCatalog subsetCatalogOnDataset( InvCatalog catalog, InvDataset dataset); static InvDataset copyDataset( InvDataset dataset, List<InvService> availableServices,
                                        boolean copyInheritedMetadataFromParents ); static InvAccess copyAccess( InvAccess access, InvDataset parentDataset, List<InvService> availableServices ); static InvService copyService( InvService service ); static InvProperty copyProperty( InvProperty property);  }