List of usage examples for javax.xml.registry.infomodel RegistryPackage getKey
Key getKey() throws JAXRException;
From source file:it.cnr.icar.eric.client.xml.registry.SecureSessionPerformanceTest.java
public void testImlicitSave() throws Exception { //Create the pkg that is the main object to save explicitly String createSecureSession = ProviderProperties.getInstance() .getProperty("jaxr-ebxml.security.createSecureSession"); log.info("jaxr-ebxml.security.createSecureSession: " + createSecureSession); long startTime = System.currentTimeMillis(); for (int i = 0; i < 3; i++) { //Create RegistryPackage ArrayList<RegistryPackage> saveObjects = new ArrayList<RegistryPackage>(); RegistryPackage pkg = lcm.createRegistryPackage("SecureSessionPerformanceTest.pkg" + i); saveObjects.add(pkg);/*from ww w . jav a2s .c om*/ //Save RegistryPackage BulkResponse br = lcm.saveObjects(saveObjects); assertTrue("Package creation failed.", br.getStatus() == BulkResponse.STATUS_SUCCESS); //Delete RegistryPackage ArrayList<Key> deleteObjects = new ArrayList<Key>(); deleteObjects.add(pkg.getKey()); br = lcm.deleteObjects(deleteObjects); assertTrue("Package deletion failed.", br.getStatus() == BulkResponse.STATUS_SUCCESS); } long endTime = System.currentTimeMillis(); log.info("Time to create and delete 10 objects (millisecs): " + (endTime - startTime)); }
From source file:it.cnr.icar.eric.client.xml.registry.infomodel.RegistryPackageTest.java
/** * Test that removeRegistryObject really does remove the * association between this RegistryPackage and the member * RegistryObject./*from w w w .j a v a2s. c o m*/ * * @exception Exception if an error occurs */ @SuppressWarnings("static-access") public void testRemoveRegistryObject() throws Exception { HashMap<String, String> saveObjectsSlots = new HashMap<String, String>(); //The bulk loader MUST turn off versioning because it updates //objects in its operations which would incorrectly be created as //new objects if versioning is ON when the object is updated. saveObjectsSlots.put(bu.CANONICAL_SLOT_LCM_DONT_VERSION, "true"); saveObjectsSlots.put(bu.CANONICAL_SLOT_LCM_DONT_VERSION_CONTENT, "true"); String testName = "testRemoveRegistryObject"; String uuid1 = it.cnr.icar.eric.common.Utility.getInstance().createId(); RegistryPackage pkg1 = getLCM().createRegistryPackage(uuid1); pkg1.setKey(getLCM().createKey(uuid1)); pkg1.setDescription(getLCM().createInternationalString(testName)); // -- Save the Object ArrayList<Object> objects = new ArrayList<Object>(); objects.add(pkg1); BulkResponse resp = ((LifeCycleManagerImpl) getLCM()).saveObjects(objects, saveObjectsSlots); JAXRUtility.checkBulkResponse(resp); System.out.println("Created Registry Package with Id " + uuid1); String uuid2 = it.cnr.icar.eric.common.Utility.getInstance().createId(); RegistryPackage pkg2 = getLCM().createRegistryPackage(uuid2); pkg2.setKey(getLCM().createKey(uuid2)); pkg2.setDescription(getLCM().createInternationalString(testName)); // -- Add pkg2 to Registry Package and save pkg1.addRegistryObject(pkg2); // -- Save the Object objects = new ArrayList<Object>(); objects.add(pkg1); objects.add(pkg2); resp = ((LifeCycleManagerImpl) getLCM()).saveObjects(objects, saveObjectsSlots); JAXRUtility.checkBulkResponse(resp); System.out.println("Added Registry Package with Id " + uuid2); // Remove the package. pkg1.removeRegistryObject(pkg2); // -- Save the Object objects = new ArrayList<Object>(); objects.add(pkg1); resp = ((LifeCycleManagerImpl) getLCM()).saveObjects(objects, saveObjectsSlots); JAXRUtility.checkBulkResponse(resp); System.out.println("Removed Registry Package with Id " + uuid2); // Get 'HasMember' associations of pkg1. ArrayList<String> associationTypes = new ArrayList<String>(); associationTypes.add(bu.CANONICAL_ASSOCIATION_TYPE_ID_HasMember); resp = getBQM().findAssociations(null, uuid1, null, associationTypes); JAXRUtility.checkBulkResponse(resp); Collection<?> coll = resp.getCollection(); if (coll.size() != 0) { Iterator<?> iter = coll.iterator(); while (iter.hasNext()) { Association ass = (Association) iter.next(); System.err.println("Association: " + ass.getKey().getId() + "; sourceObject: " + ass.getSourceObject().getKey().getId() + "; targetObject: " + ass.getTargetObject().getKey().getId()); } } assertEquals("uuid1 should not be the sourceObject in any HasMember associations.", 0, coll.size()); objects = new ArrayList<Object>(); objects.add(pkg1.getKey()); objects.add(pkg2.getKey()); if (coll.size() != 0) { Iterator<?> itr = coll.iterator(); while (itr.hasNext()) { RegistryObject ro = (RegistryObject) itr.next(); objects.add(ro.getKey()); } } resp = getLCM().deleteObjects(objects); JAXRUtility.checkBulkResponse(resp); }