Package de.zeigermann.xml.simpleImporter

Examples of de.zeigermann.xml.simpleImporter.SimpleImporter


        }

        public List getEvents() {
            List events = new ArrayList();
            try {
                SimpleImporter importer = new SimpleImporter();
                importer.setIncludeLeadingCDataIntoStartElementCallback(true);
                ResponseHandler handler = new ResponseHandler(events);
                importer.addSimpleImportHandler(handler);
                importer.parse(new InputSource(getResponseBodyAsStream()));
                return handler.getEvents();
            } catch (Throwable exception) {
                logger.log(Level.SEVERE, "Exception while polling for new events: ", exception);
            }
            return events;
View Full Code Here


      try {
        Map applicationMessages = new HashMap();
        StreamableValue messagesResource = (StreamableValue)Projector.getRepository().getResource(messagesUri, Projector.getCredentials());
        if ( messagesResource != null ) {
          InputStream inputStream = messagesResource.getInputStream();
          SimpleImporter importer = new SimpleImporter();
          importer.setIncludeLeadingCDataIntoStartElementCallback(true);
          ConfigurationHandler handler = new ConfigurationHandler();
          importer.addSimpleImportHandler(handler);
          importer.parse(new InputSource(inputStream));
          Map parsedMessages = handler.getMessages();
          applicationMessages.putAll(parsedMessages);
          Projector.getRepository().subscribe("Update", messagesUri, 0, this, Projector.getCredentials());
        } else {
          logger.log(Level.FINE, "Configured messages resource '"+messagesUri+"' not found!");
View Full Code Here

    return null;
    }
   
    private Application parseApplication(URI applicationUri) {
      try {
        SimpleImporter importer = new SimpleImporter();
        URI applicationDefinition = new URIValue(applicationUri.toString()+APPLICATION_CONFIG);
        StreamableValue applicationDefinitionResouce = ((StreamableValue)Projector.getRepository().getResource(applicationDefinition, context.getCredentials()));
        if ( applicationDefinitionResouce != null ) {
          InputStream configuration = applicationDefinitionResouce.getInputStream();
          ConfigurationHandler handler = new ConfigurationHandler(applicationUri);
          importer.addSimpleImportHandler(handler);
          importer.parse(new InputSource(configuration));
          return handler.getApplication();
        } else {
          logger.log(Level.SEVERE, "Application definition (application.xml) not found in directory '"+applicationUri+"'. Application will not be installed!");
        }
      } catch (ParserConfigurationException e) {
View Full Code Here

        synchronized ( subscribers ) {
          File file = new File(filename);
          if ( file.exists() ) {
            try {
              FileInputStream inputStream = new FileInputStream(filename);
              SimpleImporter importer = new SimpleImporter();
              importer.addSimpleImportHandler(new DefaultSimpleImportHandler() {
                String callback, notificationType, uri;
                int depth, notificationDelay, subscriptionLifetime, id;
                List events = new ArrayList();
               
                public void startElement(SimplePath path, String name, AttributesImpl attributes, String leadingCDdata) {
                  if ( path.matches(E_SUBSCRIPTION) ) {
                    id = ConversionHelpers.getInt(attributes.getValue(A_ID));
                  } else if ( path.matches(E_URI) ) {
                    uri = leadingCDdata;
                  } else if ( path.matches(E_DEPTH) ) {
                    depth = Integer.valueOf(leadingCDdata).intValue();
                  } else if ( path.matches(E_CALLBACK) ) {
                    callback = leadingCDdata;
                  } else if ( path.matches(E_NOTIFICATION_DELAY) ) {
                    notificationDelay = Integer.valueOf(leadingCDdata).intValue();
                  } else if ( path.matches(E_NOTIFICATION_TYPE) ) {
                    notificationType = leadingCDdata;
                  } else if ( path.matches(E_SUBSCRIPTION_END) ) {
                    subscriptionLifetime = (int)(Long.valueOf(leadingCDdata).longValue() - System.currentTimeMillis());
                  }
                }
               
                public void endElement(SimplePath path, String name) {
                  if ( path.matches(E_SUBSCRIPTION) ) {
                    Subscriber subscriber = new Subscriber(uri, callback, notificationType, notificationDelay, subscriptionLifetime, depth);
                    subscribers.add(subscriber);
                    refreshSubscriber(subscriber, false);
                  }
                }
              });
              importer.parse(new InputSource(inputStream));
            } catch (Exception e) {
              Domain.log("Exception while restoring subscriptions. Skipping...");
            }       
          }
        }
View Full Code Here

    private static Result result = new Result(StateDescriptor.OK);

    public void configure(StreamableValue config) throws ConfigurationException {
        try {
            InputStream configuration = config.getInputStream();
            SimpleImporter importer = new SimpleImporter();
            ConfigurationHandler handler = new ConfigurationHandler();
            importer.addSimpleImportHandler(handler);
            importer.parse(new InputSource(configuration));
            Page rootPage = handler.getRootPage();
            List resources = new ArrayList();
            buildArray(resources, rootPage);
            Value[] array = new Value[resources.size()];
            ArrayValue arrayResource = new ArrayValue((Value [])resources.toArray(array));
View Full Code Here

   
    private void install(URI applicationUri, URI configurationUri) {
      logger.log(Level.FINE, "Installing processors '"+configurationUri+"'");
      try {
        InputStream configuration = ((StreamableValue)Projector.getRepository().getResource(configurationUri, Projector.getCredentials())).getInputStream();
        SimpleImporter importer = new SimpleImporter();
        List alreadyInstalledProcessors = (List)installedProcessors.get(configurationUri);
        if ( alreadyInstalledProcessors == null ) alreadyInstalledProcessors = new ArrayList();
        ConfigurationHandler handler = new ConfigurationHandler(applicationUri, alreadyInstalledProcessors);
        importer.addSimpleImportHandler(handler);
        importer.parse(new InputSource(configuration));
        List removedProcessors = new ArrayList();
        alreadyInstalledProcessors.addAll(handler.getAddedProcessors());
        for ( Iterator i = handler.getRemovedProcessors().iterator(); i.hasNext(); ) {
          URI removedProcessorUri = (URI)i.next();
          uninstallProcessor(removedProcessorUri);
View Full Code Here

    }

    public void configure(StreamableValue config) throws ConfigurationException {
        try {
            InputStream configuration = config.getInputStream();
            SimpleImporter importer = new SimpleImporter();
            ConfigurationHandler handler = new ConfigurationHandler();
            importer.addSimpleImportHandler(handler);
            importer.parse(new InputSource(configuration));
            parameterDescriptors = new ParameterDescriptor[] {
                new ParameterDescriptor(SimpleProcessor.INPUT, new ParameterMessage(handler.getDescription()), handler.getValueDesriptor())
            };
            resultDescriptor = new ResultDescriptor(handler.getStateDescriptors());
        } catch (Exception exception) {
View Full Code Here

TOP

Related Classes of de.zeigermann.xml.simpleImporter.SimpleImporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.