@Override public void endWikiClass(FilterEventParameters parameters) throws FilterException { try { this.writer.writeEndElement(); } catch (Exception e) { throw new FilterException(String.format("Failed to write end xclass [%s] with version [%s]", this.currentDocumentReference, this.currentDocumentVersion), e); } }
public void closeEntry() throws FilterException { try { this.zipStream.closeArchiveEntry(); } catch (IOException e) { throw new FilterException("Failed to close zip archive entry", e); } }
@Override public void endWiki(String name, FilterEventParameters parameters) throws FilterException { try { this.wikiWriter.close(); } catch (IOException e) { throw new FilterException("Failed to close XAR writer", e); } this.wikiWriter = null; }
@Override public void endWikiObject(String name, FilterEventParameters parameters) throws FilterException { try { this.writer.writeEndElement(); this.currentObjectClass = null; this.currentObjectProperties = null; } catch (Exception e) { throw new FilterException( String.format("Failed to write end xobject [%s] from document [%s] with version [%s]", name, this.currentDocumentReference, this.currentDocumentVersion), e); } }
protected P createPropertiesBean(Map<String, Object> properties) throws FilterException { Class<P> beanClass = getPropertiesBeanClass(); if (beanClass.isInstance(properties)) { return (P) properties; } P parametersBean; try { parametersBean = beanClass.newInstance(); this.beanManager.populate(parametersBean, properties); } catch (Exception e) { throw new FilterException(String.format("Failed to read parameters [%s]", properties), e); } return parametersBean; }
@Override public Collection<Class<?>> getFilterInterfaces() throws FilterException { List<OutputFilterStreamFactory> factories; try { factories = this.contextComponentManager.get().getInstanceList(OutputFilterStreamFactory.class); } catch (ComponentLookupException e) { throw new FilterException("Failed to lookup OutputFilterFactory components instances", e); } Set<Class<?>> filters = new HashSet<>(); filters.add(UnknownFilter.class); for (OutputFilterStreamFactory factory : factories) { if (factory.getClass() != XMLOutputFilterFactory.class) { filters.addAll(factory.getFilterInterfaces()); } } return filters; }
private void readXAR(Object filter, XARInputFilter proxyFilter) throws FilterException { WikiReader wikiReader = this.wikiReaderProvider.get(); wikiReader.setProperties(this.properties); try { wikiReader.read(filter, proxyFilter); } catch (Exception e) { throw new FilterException("Failed to read XAR package", e); } }
@Override public void endWikiClassProperty(String name, String type, FilterEventParameters parameters) throws FilterException { try { this.writer.writeElement(XARClassPropertyModel.ELEMENT_CLASSTYPE, type); this.writer.writeEndElement(); } catch (Exception e) { throw new FilterException( String.format("Failed to write end property [%s] from class [%s] with version [%s]", name, this.currentDocumentReference, this.currentDocumentVersion), e); } }
@Override public Collection<Class<?>> getFilterInterfaces() throws FilterException { List<InputFilterStreamFactory> factories; try { factories = this.contextComponentManager.get().getInstanceList(InputFilterStreamFactory.class); } catch (ComponentLookupException e) { throw new FilterException("Failed to lookup InputFilterFactory components instances", e); } Set<Class<?>> filters = new HashSet<>(); filters.add(UnknownFilter.class); for (InputFilterStreamFactory factory : factories) { if (factory.getClass() != XMLInputFilterFactory.class) { filters.addAll(factory.getFilterInterfaces()); } } return filters; }
throw new FilterException( String.format("No <classType> element found for property [%s]", wikiClassProperty.name));
@Override public void onWikiClassPropertyField(String name, String value, FilterEventParameters parameters) throws FilterException { checkXMLWriter(); try { this.writer.writeElement(name, value); } catch (Exception e) { throw new FilterException( String.format("Failed to write property field [%s:%s] from class [%s] with version [%s]", name, value, this.currentDocumentReference, this.currentDocumentVersion), e); } }
private void writePackage() throws FilterException { try { this.xarPackage.write(this.zipStream, this.xarProperties.getEncoding()); } catch (Exception e) { throw new FilterException("Failed to write package.xml entry", e); } }
protected <T> T convert(Class<?> type, String source) throws FilterException { Object value = source; if (type == Locale.class) { value = toLocale(source); } else if (type == Date.class) { value = StringUtils.isNotEmpty(source) ? new Date(Long.parseLong(source)) : null; } else if (type == Boolean.class) { value = StringUtils.isNotEmpty(source) ? Boolean.parseBoolean(source) : null; } else if (type == Syntax.class) { if (StringUtils.isNotEmpty(source)) { try { value = Syntax.valueOf(source); } catch (ParseException e) { throw new FilterException(String.format("Failed to create Syntax istance for [%s]", source), e); } } else { value = null; } } else if (type == Integer.class) { value = StringUtils.isNotEmpty(source) ? Integer.parseInt(source) : null; } return (T) value; }
@Override public void beginWikiClassProperty(String name, String type, FilterEventParameters parameters) throws FilterException { checkXMLWriter(); try { this.writer.writeStartElement(name); if (this.currentObjectProperties != null) { this.currentObjectProperties.put(name, type); } } catch (Exception e) { throw new FilterException( String.format("Failed to write begin property [%s] from class [%s] with version [%s]", name, this.currentDocumentReference, this.currentDocumentVersion), e); } }
@Override protected void write(E entity, Object filter, F internalFilter, Map<String, Object> properties) throws FilterException { P propertiesBean; if (this.propertiesType.isInstance(properties)) { propertiesBean = (P) properties; } else { try { propertiesBean = this.propertiesType.newInstance(); this.beanManager.populate(propertiesBean, properties); } catch (Exception e) { throw new FilterException("Failed to convert properties to Java bean", e); } } write(entity, filter, internalFilter, propertiesBean); }
@Override public Collection<Class< ? >> getFilterInterfaces() throws FilterException { List<InstanceInputEventGenerator> eventGenerators; try { eventGenerators = this.componentManagerProvider.get().getInstanceList(InstanceInputEventGenerator.class); } catch (ComponentLookupException e) { throw new FilterException("Failed to get registered instance of InstanceInputEventGenerator components", e); } Set<Class< ? >> filters = new HashSet<Class< ? >>(); filters.addAll(super.getFilterInterfaces()); for (InstanceInputEventGenerator generator : eventGenerators) { filters.addAll(generator.getFilterInterfaces()); } return filters; } }
@Override public Collection<Class< ? >> getFilterInterfaces() throws FilterException { List<OutputInstanceFilterStreamFactory> factories; try { factories = this.componentManagerProvider.get().getInstanceList(OutputInstanceFilterStreamFactory.class); } catch (ComponentLookupException e) { throw new FilterException( "Failed to get regsitered instance of OutputInstanceFilterStreamFactory components", e); } Set<Class< ? >> filters = new HashSet<Class< ? >>(); filters.addAll(super.getFilterInterfaces()); for (OutputInstanceFilterStreamFactory factory : factories) { filters.addAll(factory.getFilterInterfaces()); } return filters; } }
@Override public void setProperties(InstanceInputProperties properties) throws FilterException { super.setProperties(properties); try { this.eventGenerators = this.componentManager.get().getInstanceList(InstanceInputEventGenerator.class); } catch (ComponentLookupException e) { throw new FilterException( "Failed to get regsitered instance of OutputInstanceFilterStreamFactory components", e); } for (InstanceInputEventGenerator eventGenerator : this.eventGenerators) { eventGenerator.setProperties(this.properties); } }
throw new FilterException("Resource [" + sourceString + "] does not exist");
stream = ((InputStreamInputSource) inputSource).getInputStream(); } catch (IOException e) { throw new FilterException("Failed to get input stream", e); iszip = isZip(stream); } catch (IOException e) { throw new FilterException("Failed to read input stream", e); } finally { try { inputSource.close(); } catch (IOException e) { throw new FilterException("Failed to close the source", e); throw new FilterException(String.format("Unsupported input source of type [%s]", inputSource.getClass()));