if (input != null) { final Document document= getCachedDocument(path, input); try { input.close(); input= null; } catch (IOException exception) {  } monitor.worked(1); final Object result= transformDescriptor(descriptor); if (result instanceof Document) { final NodeList list= ((Document) result).getElementsByTagName(IRefactoringSerializationConstants.ELEMENT_REFACTORING); Assert.isTrue(list.getLength() == 1); document.getDocumentElement().appendChild(document.importNode(list.item(0), true)); addHistoryEntry(history, document, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); addIndexEntry(index, descriptor, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); }
final Document document= getCachedDocument(path, input); try { input.close(); input= null; } catch (IOException exception) {  } monitor.worked(1); final Object result= transformDescriptor(descriptor); if (result instanceof Document) { final NodeList list= ((Document) result).getElementsByTagName(IRefactoringSerializationConstants.ELEMENT_REFACTORING); Assert.isTrue(list.getLength() == 1); document.getDocumentElement().appendChild(document.importNode(list.item(0), true)); addHistoryEntry(history, document, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)); addIndexEntry(index, descriptor, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));
	void addRefactoringDescriptor(final RefactoringDescriptor descriptor, final IProgressMonitor monitor) throws CoreException {		try {			monitor.beginTask(RefactoringCoreMessages.RefactoringHistoryService_updating_history, 5);			final long stamp= descriptor.getTimeStamp();			if (stamp >= 0) {				final IPath path= stampToPath(stamp);				final IFileStore folder= fHistoryStore.getChild(path);				if (folder != null) {					final IFileStore history= folder.getChild(RefactoringHistoryService.NAME_HISTORY_FILE);					final IFileStore index= folder.getChild(RefactoringHistoryService.NAME_INDEX_FILE);					if (history != null && index != null) {						if (history.fetchInfo(EFS.NONE, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)).exists()) {							InputStream input= null;							try {								input= new BufferedInputStream(history.openInputStream(EFS.NONE, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL)));								if (input != null) {									final Document document= getCachedDocument(path, input);									try {										input.close();										input= null;									} catch (IOException exception) {										// Do nothing									}									monitor.worked(1);									final Object result= transformDescriptor(descriptor);									if (result instanceof Document) {										final NodeList list= ((Document) result).getElementsByTagName(IRefactoringSerializationConstants.ELEMENT_REFACTORING);										Assert.isTrue(list.getLength() == 1);										document.getDocumentElement().appendChild(document.importNode(list.item(0), true));										addHistoryEntry(history, document, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));										addIndexEntry(index, descriptor, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));									}								}							} catch (ParserConfigurationException exception) {								new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), 0, exception.getLocalizedMessage(), null));							} catch (IOException exception) {								new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), 0, exception.getLocalizedMessage(), null));							} catch (SAXException exception) {								new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), 0, exception.getLocalizedMessage(), null));							} finally {								if (input != null) {									try {										input.close();									} catch (IOException exception) {										// Do nothing									}								}							}						} else {							try {								final Object result= transformDescriptor(descriptor);								if (result instanceof Node) {									addHistoryEntry(history, (Node) result, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));									addIndexEntry(index, descriptor, new SubProgressMonitor(monitor, 1, SubProgressMonitor.SUPPRESS_SUBTASK_LABEL));								}							} catch (IOException exception) {								throw new CoreException(new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), 0, exception.getLocalizedMessage(), null));							}						}					}				}			}		} finally {			monitor.done();		}	}