public synchronized void parse(InputStream stream, IProgressMonitor monitor) throws IOException { this.status = null; setProgressMonitor(monitor); monitor.beginTask(Messages.repo_loading, IProgressMonitor.UNKNOWN); try { // TODO: currently not caching the parser since we make no assumptions // or restrictions on concurrent parsing getParser(); RepositoryHandler repositoryHandler = new RepositoryHandler(); xmlReader.setContentHandler(new RepositoryDocHandler(REPOSITORY_ELEMENT, repositoryHandler)); xmlReader.parse(new InputSource(stream)); if (isValidXML()) { theRepository = repositoryHandler.getRepository(); } } catch (SAXException e) { if (!(e.getException() instanceof OperationCanceledException)) throw new IOException(e.getMessage()); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage()); } finally { monitor.done(); stream.close(); } }
public synchronized void parse(InputStream stream, IProgressMonitor monitor) throws IOException { this.status = null; setProgressMonitor(monitor); monitor.beginTask(Messages.repo_loading, IProgressMonitor.UNKNOWN); try { // TODO: currently not caching the parser since we make no assumptions // or restrictions on concurrent parsing getParser(); RepositoryHandler repositoryHandler = new RepositoryHandler(); xmlReader.setContentHandler(new RepositoryDocHandler(REPOSITORY_ELEMENT, repositoryHandler)); xmlReader.parse(new InputSource(stream)); if (isValidXML()) { theRepository = repositoryHandler.getRepository(); } } catch (SAXException e) { if (!(e.getException() instanceof OperationCanceledException)) throw new IOException(e.getMessage()); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage()); } finally { monitor.done(); stream.close(); } }
public synchronized void parse(InputStream stream, IProgressMonitor monitor) throws IOException { this.status = null; setProgressMonitor(monitor); monitor.beginTask(Messages.repo_loading, IProgressMonitor.UNKNOWN); try { // TODO: currently not caching the parser since we make no assumptions // or restrictions on concurrent parsing getParser(); RepositoryHandler repositoryHandler = new RepositoryHandler(); xmlReader.setContentHandler(new RepositoryDocHandler(REPOSITORY_ELEMENT, repositoryHandler)); xmlReader.parse(new InputSource(stream)); if (isValidXML()) { theRepository = repositoryHandler.getRepository(); } } catch (SAXException e) { if (!(e.getException() instanceof OperationCanceledException)) { IOException ioException = new IOException(e.getMessage()); ioException.initCause(e); throw ioException; } } catch (ParserConfigurationException e) { IOException ioException = new IOException(e.getMessage()); ioException.initCause(e); throw ioException; } finally { monitor.done(); stream.close(); } }
protected void finished() { if (isValidXML()) { state.Properties = (propertiesHandler == null ? new OrderedProperties(0) // : propertiesHandler.getProperties()); state.Units = (unitsHandler == null ? new IInstallableUnit[0] // : unitsHandler.getUnits()); state.Repositories = repositoryReferencesHandler == null ? new IRepositoryReference[0] : repositoryReferencesHandler.getReferences(); Object repositoryObject = null; //can't create repository if missing type - this is already logged when parsing attributes if (state.Type == null) return; try { Class<?> clazz = Class.forName(state.Type); Constructor<?> ctor = clazz.getConstructor(IProvisioningAgent.class); repositoryObject = ctor.newInstance(agent); } catch (Exception e) { // TODO: Throw a SAXException e.printStackTrace(); } if (repositoryObject instanceof AbstractMetadataRepository) { repository = (AbstractMetadataRepository) repositoryObject; repository.initialize(state); } } } }
protected void finished() { if (isValidXML()) { state.Properties = (propertiesHandler == null ? new OrderedProperties(0) // : propertiesHandler.getProperties()); state.Units = (unitsHandler == null ? new IInstallableUnit[0] // : unitsHandler.getUnits()); state.Repositories = repositoryReferencesHandler == null ? new IRepositoryReference[0] : repositoryReferencesHandler.getReferences(); Object repositoryObject = null; //can't create repository if missing type - this is already logged when parsing attributes if (state.Type == null) return; try { Class<?> clazz = Class.forName(state.Type); Constructor<?> ctor = clazz.getConstructor(IProvisioningAgent.class); repositoryObject = ctor.newInstance(agent); } catch (Exception e) { // TODO: Throw a SAXException e.printStackTrace(); } if (repositoryObject instanceof AbstractMetadataRepository) { repository = (AbstractMetadataRepository) repositoryObject; repository.initialize(state); } } } }
protected void finished() { if (isValidXML()) { state.Properties = (propertiesHandler == null ? new OrderedProperties(0) // : propertiesHandler.getProperties()); state.Units = (unitsHandler == null ? new IInstallableUnit[0] // : unitsHandler.getUnits()); state.Repositories = repositoryReferencesHandler == null ? new IRepositoryReference[0] : repositoryReferencesHandler.getReferences(); Object repositoryObject = null; //can't create repository if missing type - this is already logged when parsing attributes if (state.Type == null) return; try { Class<?> clazz = Class.forName(state.Type); Constructor<?> ctor = clazz.getConstructor(IProvisioningAgent.class); repositoryObject = ctor.newInstance(agent); } catch (Exception e) { // TODO: Throw a SAXException e.printStackTrace(); } if (repositoryObject instanceof AbstractMetadataRepository) { repository = (AbstractMetadataRepository) repositoryObject; repository.initialize(state); } } } }