public void processingInstruction(String target, String data) throws SAXException { if (PI_REPOSITORY_TARGET.equals(target)) { Version repositoryVersion = extractPIVersion(target, data); if (!MetadataRepositoryIO.XMLConstants.XML_TOLERANCE.isIncluded(repositoryVersion)) { throw new SAXException(NLS.bind(Messages.io_IncompatibleVersion, repositoryVersion, MetadataRepositoryIO.XMLConstants.XML_TOLERANCE)); } } }
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(); } }
bufferedInput = new BufferedInputStream(input); Parser repositoryParser = new Parser(Activator.getContext(), Activator.ID); repositoryParser.setErrorContext(location.toExternalForm()); repositoryParser.parse(input, monitor); IStatus result = repositoryParser.getStatus(); switch (result.getSeverity()) { case IStatus.CANCEL : LogHelper.log(result); return repositoryParser.getRepository(); } finally { if (bufferedInput != null)
bufferedInput = new BufferedInputStream(input); Parser repositoryParser = new Parser(Activator.getContext(), Activator.ID); repositoryParser.setErrorContext(location.toExternalForm()); repositoryParser.parse(input, monitor); IStatus result = repositoryParser.getStatus(); switch (result.getSeverity()) { case IStatus.CANCEL : LogHelper.log(result); return repositoryParser.getRepository(); } finally { if (bufferedInput != null)
bufferedInput = new BufferedInputStream(input); Parser repositoryParser = new Parser(Activator.getContext(), Activator.ID); repositoryParser.setErrorContext(location.toExternalForm()); repositoryParser.parse(input, monitor); IStatus result = repositoryParser.getStatus(); switch (result.getSeverity()) { case IStatus.CANCEL : LogHelper.log(result); return repositoryParser.getRepository(); } finally { if (bufferedInput != null)
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); } } } }
public void startElement(String name, Attributes attributes) { checkCancel(); if (PROPERTIES_ELEMENT.equals(name)) { if (propertiesHandler == null) { propertiesHandler = new PropertiesHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else if (INSTALLABLE_UNITS_ELEMENT.equals(name)) { if (unitsHandler == null) { unitsHandler = new InstallableUnitsHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else if (REPOSITORY_REFERENCES_ELEMENT.equals(name)) { if (repositoryReferencesHandler == null) { repositoryReferencesHandler = new RepositoryReferencesHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else { invalidElement(name, attributes); } }
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 void startElement(String name, Attributes attributes) { checkCancel(); if (PROPERTIES_ELEMENT.equals(name)) { if (propertiesHandler == null) { propertiesHandler = new PropertiesHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else if (INSTALLABLE_UNITS_ELEMENT.equals(name)) { if (unitsHandler == null) { unitsHandler = new InstallableUnitsHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else if (REPOSITORY_REFERENCES_ELEMENT.equals(name)) { if (repositoryReferencesHandler == null) { repositoryReferencesHandler = new RepositoryReferencesHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else { invalidElement(name, attributes); } }
public void startElement(String name, Attributes attributes) { checkCancel(); if (PROPERTIES_ELEMENT.equals(name)) { if (propertiesHandler == null) { propertiesHandler = new PropertiesHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else if (INSTALLABLE_UNITS_ELEMENT.equals(name)) { if (unitsHandler == null) { unitsHandler = new InstallableUnitsHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else if (REPOSITORY_REFERENCES_ELEMENT.equals(name)) { if (repositoryReferencesHandler == null) { repositoryReferencesHandler = new RepositoryReferencesHandler(this, attributes); } else { duplicateElement(this, name, attributes); } } else { invalidElement(name, attributes); } }
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 void processingInstruction(String target, String data) throws SAXException { if (PI_REPOSITORY_TARGET.equals(target)) { Version repositoryVersion = extractPIVersion(target, data); if (!MetadataRepositoryIO.XMLConstants.XML_TOLERANCE.isIncluded(repositoryVersion)) { throw new SAXException(NLS.bind(Messages.io_IncompatibleVersion, repositoryVersion, MetadataRepositoryIO.XMLConstants.XML_TOLERANCE)); } } }
protected void handleRootAttributes(Attributes attributes) { String[] values = parseAttributes(attributes, required, optional); Version version = checkVersion(this.elementHandled, VERSION_ATTRIBUTE, values[2]); state.Name = values[0]; state.Type = values[1]; state.Version = version; state.Description = values[3]; state.Provider = values[4]; state.Location = null; }
public void processingInstruction(String target, String data) throws SAXException { if (PI_REPOSITORY_TARGET.equals(target)) { Version repositoryVersion = extractPIVersion(target, data); if (!MetadataRepositoryIO.XMLConstants.XML_TOLERANCE.isIncluded(repositoryVersion)) { throw new SAXException(NLS.bind(Messages.io_IncompatibleVersion, repositoryVersion, MetadataRepositoryIO.XMLConstants.XML_TOLERANCE)); } } }
protected void handleRootAttributes(Attributes attributes) { String[] values = parseAttributes(attributes, required, optional); Version version = checkVersion(this.elementHandled, VERSION_ATTRIBUTE, values[2]); state.Name = values[0]; state.Type = values[1]; state.Version = version; state.Description = values[3]; state.Provider = values[4]; state.Location = null; }
protected void handleRootAttributes(Attributes attributes) { String[] values = parseAttributes(attributes, required, optional); Version version = checkVersion(this.elementHandled, VERSION_ATTRIBUTE, values[2]); state.Name = values[0]; state.Type = values[1]; state.Version = version; state.Description = values[3]; state.Provider = values[4]; state.Location = null; }