@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; }
@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); } }
@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 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); } }
@Override public void setProperties(InstanceOutputProperties properties) throws FilterException { super.setProperties(properties); List<OutputInstanceFilterStreamFactory> factories; try { factories = this.componentManager.get().getInstanceList(OutputInstanceFilterStreamFactory.class); } catch (ComponentLookupException e) { throw new FilterException( "Failed to get regsitered instance of OutputInstanceFilterStreamFactory components", e); } Object[] filters = new Object[factories.size()]; int i = 0; for (OutputInstanceFilterStreamFactory factory : factories) { filters[i++] = factory.createOutputFilterStream(properties).getFilter(); } this.filter = this.filterManager.createCompositeFilter(filters); }
public void send(XARInputFilter proxyFilter) throws FilterException { if (this.content != null) { try (InputStream is = new Base64InputStream(openStream())) { proxyFilter.onWikiAttachment(this.name, is, this.size, this.parameters); } catch (IOException e) { throw new FilterException(e); } finally { if (this.content.isInMemory()) { this.content.getFile().delete(); } } } else { proxyFilter.onWikiAttachment(this.name, null, this.size, this.parameters); } }
@Override public BeanInputFilterStream<P> createInputFilterStream(P properties) throws FilterException { BeanInputFilterStream<P> inputFilter; try { inputFilter = this.componentManager.getInstance(new DefaultParameterizedType(null, BeanInputFilterStream.class, getPropertiesBeanClass()), getType().serialize()); } catch (ComponentLookupException e) { throw new FilterException(String.format("Failed to get instance of [%s] for type [%s]", BeanInputFilterStream.class, getType()), e); } inputFilter.setProperties(properties); return inputFilter; } }
protected void readDocument(Object filter, XARInputFilter proxyFilter) throws FilterException { DocumentLocaleReader documentReader = documentLocaleReaderProvider.get(); documentReader.setProperties(this.properties); try { documentReader.read(filter, proxyFilter); } catch (Exception e) { throw new FilterException("Failed to read XAR XML document", e); } // Close remaining opened spaces if (documentReader.getSentSpaceReference() != null) { for (EntityReference space = documentReader.getSentSpaceReference(); space != null; space = space.getParent()) { proxyFilter.endWikiSpace(space.getName(), FilterEventParameters.EMPTY); } } }
@Override public BeanOutputFilterStream<P> createOutputFilterStream(P properties) throws FilterException { BeanOutputFilterStream<P> inputFilter; try { inputFilter = this.componentManager.getInstance(new DefaultParameterizedType(null, BeanOutputFilterStream.class, getPropertiesBeanClass()), getType().serialize()); } catch (ComponentLookupException e) { throw new FilterException(String.format("Failed to get instance of [%s] for type [%s]", BeanInputFilterStream.class, getType()), e); } inputFilter.setProperties(properties); return inputFilter; } }