/** * This will rename an asset and apply the change immediately. * * @return the UUID of the new asset */ public String renameAsset(String uuid, String newAssetName) { try { AssetItem itemOriginal = loadAssetByUUID(uuid); log.info("Renaming asset: " + itemOriginal.getNode().getPath() + " to " + newAssetName); Node node = itemOriginal.getNode(); String sourcePath = node.getPath(); String destPath = node.getParent().getPath() + "/" + newAssetName; this.session.move(sourcePath, destPath); this.session.save(); itemOriginal.updateTitle(newAssetName); itemOriginal.checkin("Renamed asset " + itemOriginal.getName()); return itemOriginal.getUUID(); } catch (RepositoryException e) { log.error(e.getMessage(), e); throw new RulesRepositoryException(e); } }
/** * This will rename an asset and apply the change immediately. * * @return the UUID of the new asset */ public String renameAsset(String uuid, String newAssetName) { try { AssetItem itemOriginal = loadAssetByUUID(uuid); log.info("Renaming asset: " + itemOriginal.getNode().getPath() + " to " + newAssetName); Node node = itemOriginal.getNode(); String sourcePath = node.getPath(); String destPath = node.getParent().getPath() + "/" + newAssetName; this.session.move(sourcePath, destPath); this.session.save(); itemOriginal.updateTitle(newAssetName); itemOriginal.checkin("Renamed asset " + itemOriginal.getName()); return itemOriginal.getUUID(); } catch (RepositoryException e) { log.error(e.getMessage(), e); throw new RulesRepositoryException(e); } }
dest.node.setProperty(AssetItem.VERSION_NUMBER_PROPERTY_NAME, 0); dest.updateTitle(destinationName); dest.checkin("Copied from " + source.getModuleName() + "/" + source.getName()); return dest.getUUID();
dest.node.setProperty(AssetItem.VERSION_NUMBER_PROPERTY_NAME, 0); dest.updateTitle(destinationName); dest.checkin("Copied from " + source.getModuleName() + "/" + source.getName()); return dest.getUUID();
@Test public void testSaveAndCheckinDescriptionAndTitle() throws Exception { AssetItem ruleItem1 = getRepo().loadDefaultModule().addAsset("testGetDescription", ""); ruleItem1.checkin( "version0" ); //it should be "" to begin with assertEquals("", ruleItem1.getDescription()); ruleItem1.updateDescription("test description"); assertEquals("test description", ruleItem1.getDescription()); assertTrue(getRepo().getSession().hasPendingChanges()); ruleItem1.updateTitle( "This is a title" ); assertTrue(getRepo().getSession().hasPendingChanges()); ruleItem1.checkin( "ya" ); //we can save without a checkin getRepo().getSession().save(); assertFalse(getRepo().getSession().hasPendingChanges()); try { ruleItem1.getPrecedingVersion().updateTitle( "baaad" ); fail("should not be able to do this"); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage()); } }
@Test public void testSaveAndCheckinDescriptionAndTitleForShareableAsset() throws Exception { AssetItem asset = getRepo().loadGlobalArea().addAsset("testSaveAndCheckinDescriptionAndTitleForShareableAsset", "desc"); asset.checkin("version0"); AssetItem linkedAsset = getDefaultPackage().addAssetImportedFromGlobalArea(asset.getName()); // it should be "" to begin with assertEquals("desc", linkedAsset.getDescription()); linkedAsset.updateDescription("test description"); assertEquals("test description", linkedAsset.getDescription()); assertTrue(getRepo().getSession().hasPendingChanges()); linkedAsset.updateTitle("This is a title"); assertTrue(getRepo().getSession().hasPendingChanges()); linkedAsset.checkin("ya"); // we can save without a checkin getRepo().getSession().save(); assertFalse(getRepo().getSession().hasPendingChanges()); try { linkedAsset.getPrecedingVersion().updateTitle("baaad"); fail("should not be able to do this"); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage()); } }