Method for renaming extents added.
1.1 --- a/mdr/src/org/netbeans/mdr/NBMDRepositoryImpl.java Thu Dec 09 17:12:57 2004 +0000
1.2 +++ b/mdr/src/org/netbeans/mdr/NBMDRepositoryImpl.java Fri Dec 10 09:50:12 2004 +0000
1.3 @@ -317,6 +317,22 @@
1.4 }
1.5 }
1.6
1.7 + public boolean renameExtent(RefPackage extent, String newName) {
1.8 + initCheck();
1.9 +
1.10 + boolean fail = true;
1.11 + beginTrans(true);
1.12 + try {
1.13 + boolean result = mdrStorage.renameContext(((BaseObjectHandler) extent)._getMofId(), newName);
1.14 + fail = false;
1.15 + return result;
1.16 + } catch (StorageException e) {
1.17 + throw new DebugException("Renaming failed: " + e);
1.18 + } finally {
1.19 + endTrans(fail);
1.20 + }
1.21 + }
1.22 +
1.23 /** Returns all name of registered outermost package instances,
1.24 * which can be passed to the {@link #getExtent(String)} method to obtain
1.25 * an outermost package instance.
2.1 --- a/mdr/src/org/netbeans/mdr/storagemodel/MdrStorage.java Thu Dec 09 17:12:57 2004 +0000
2.2 +++ b/mdr/src/org/netbeans/mdr/storagemodel/MdrStorage.java Fri Dec 10 09:50:12 2004 +0000
2.3 @@ -943,6 +943,20 @@
2.4 return result;
2.5 }
2.6
2.7 + public boolean renameContext(MOFID mofId, String newName) throws StorageException {
2.8 + SinglevaluedIndex context = (SinglevaluedIndex) this.contexts.get(mofId.getStorageID());
2.9 + if (context == null) throw new IllegalArgumentException();
2.10 + for (Iterator it = context.keySet().iterator(); it.hasNext();) {
2.11 + String oldName = (String) it.next();
2.12 + if (context.get(oldName).equals(mofId)) {
2.13 + context.remove(oldName);
2.14 + context.add(newName, mofId);
2.15 + return true;
2.16 + }
2.17 + }
2.18 + return false;
2.19 + }
2.20 +
2.21 /**
2.22 * Returns the outermost package proxy for the given context name.
2.23 *