/** * Sets the specified interface entry as the default for the involved model-gateway mapping. * * @param givModelFilename the filename of the model in the mapping * @param gwId the id of the gateway in the mapping * @param givIntefaceId the id of the interface to be deleted * @return true if successful, otherwise false. */ public static synchronized boolean setDefaultInterfaceEntry( String givModelFilename, String gwId, long givIntefaceId) { boolean successFlag = false; Model3dIndexEntry existingEntry = checkforGivenEntry(givModelFilename); if (existingEntry != null) { // // get the vector with the interfaces for this gateway/model AND check if the specified // interface (to be set as default) exists or not! // Vector<Model3dInterfaceEntry> tmpInterfaceVector = existingEntry.getInterfacesVecForGwId(gwId); if (givIntefaceId != existingEntry.getDefaultInterfaceIdForGwId(gwId)) { for (int i = 0; i < tmpInterfaceVector.size(); i++) { if (tmpInterfaceVector.elementAt(i).getIntefaceId() == givIntefaceId) { existingEntry.setDefaultInterfaceIdForGwId(gwId, givIntefaceId); // // save changes to Index. // Model3dIndex.writeIndexBackToFile(); successFlag = true; break; } } } else { successFlag = true; } } return successFlag; }
/** * Deletes the specified interface from a model-gateway mapping. Should take care of consistency * issues such as: a) updating the default interface for the mapping (if we are deleting a default * interface then the interface that will be set as default will be the one with the minimum id) * and b) deleting the entire mapping, and the gateway entry from the Model3dIndexEntry if this is * the last interface for the specified model-gateway mapping. * * @param givModelFilename the filename of the model in the mapping * @param gwId the id of the gateway in the mapping * @param givIntefaceId the id of the interface to be deleted * @return true if successful, otherwise false. (To do )(Add code here) */ public static synchronized boolean deleteInterfaceEntry( String givModelFilename, String gwId, long givIntefaceId) { boolean successFlag = false; Model3dIndexEntry existingEntry = checkforGivenEntry(givModelFilename); if (existingEntry != null) { // // Remove the specified interface from the Metafile // existingEntry.removeInterfaceForGw(gwId, givIntefaceId); // // IF its the only interface then delete the gateway entry from the Model3dIndexEntry as well. // Vector<Model3dInterfaceEntry> tmpInterfaceVector = existingEntry.getInterfacesVecForGwId(gwId); if (tmpInterfaceVector != null && tmpInterfaceVector.isEmpty()) { existingEntry.deleteGatewayEntry(gwId); if (existingEntry.getMetaGatewaysVec().isEmpty()) { // then delete Metafile AND the entry from the Model3dIndex existingEntry.deleteMetafile(); Model3dIndex.deleteEntry(givModelFilename); existingEntry = null; } } else if (givIntefaceId == existingEntry.getDefaultInterfaceIdForGwId(gwId)) { // // IF its the default interface then, change the default interface to a remaining interface // with minimum id. // long newDefaultId = existingEntry.getMinInterfaceIdForGwId(gwId); existingEntry.setDefaultInterfaceIdForGwId(gwId, newDefaultId); } // // save changes to files. // Model3dIndex.writeIndexBackToFile(); return true; } return false; }