Package org.apache.slide.projector.value

Examples of org.apache.slide.projector.value.URIValue


      int depth = 0;
      String depthProperty = (String)properties.get(DEPTH);
      if ( depthProperty != null ) {
        depth = Integer.valueOf(depthProperty).intValue();
      }
      Projector.getRepository().subscribe(method, new URIValue(uri), depth, activatedExpression, Projector.getCredentials());
      return activatedExpression;
    }
View Full Code Here


        }
    }

  public void notify(String uri, Map information) {
    eval = true;
      Projector.getRepository().unsubscribe(new URIValue((String)properties.get(URI)), this, Projector.getCredentials());
    Scheduler.getInstance().notify(job);
    }
View Full Code Here

    // FIXME: Should be used from applications classpath
    private ProjectorClassLoader factoryClassLoader = new ProjectorClassLoader(this.getClass().getClassLoader(), new URIValue(Projector.getProjectorDir()+CLASSES_DIR));
   
    private ApplicationManager() {
        logger.log(Level.INFO, "Starting application manager");
      Projector.getRepository().subscribe("Update/newmember", new URIValue(Projector.getApplicationsDir()), 1,
          new Subscriber() {
        public void notify(String uri, Map information) {
          logger.log(Level.FINE, "Package manager received add event");
          applicationManager.installApplications();
        }
      }, context.getCredentials());
      Projector.getRepository().subscribe("Delete", new URIValue(Projector.getApplicationsDir()), 1,
          new Subscriber() {
        public void notify(String uri, Map information) {
          logger.log(Level.FINE, "Package manager received delete event");
          applicationManager.installApplications();
        }
View Full Code Here

      List applicationsToInstall = new ArrayList();
      List applicationsToRemove = new ArrayList();
      try {
        List removedApplications = new ArrayList();
        removedApplications.addAll(installedApplications.keySet());
        applicationUris = ((ArrayValue)Projector.getRepository().getChildren(new URIValue(Projector.getApplicationsDir()), context.getCredentials())).getArray();
        for ( int i = 0; i < applicationUris.length; i++ ) {
          String applicationUri = applicationUris[i].toString();
          if ( !applicationUri.endsWith("/") ) {
            applicationUri = applicationUri + "/";
          }
          /* FIXME: Is this needed or can it be fixed in getChildren() ?
          if ( applicationUri.indexOf(Constants.REPOSITORY_DOMAIN) != -1  ) {
            applicationUri = applicationUri.substring(applicationUri.indexOf(Constants.REPOSITORY_DOMAIN)+Constants.REPOSITORY_DOMAIN.length());
          }
          */
          if ( !installedApplications.containsKey(applicationUri) ) {
            Application installedApplication = parseApplication(new URIValue(applicationUri));
            if ( installedApplication != null ) {
              applicationsToInstall.add(installedApplication);
            }
          } else {
            logger.log(Level.FINE, "Application '"+applicationUri+"' already installed");
            removedApplications.remove(applicationUri);
          }
        } 
        for ( Iterator i = removedApplications.iterator(); i.hasNext(); ) {
          Application removedApplication = (Application)installedApplications.get((URI)i.next());
          applicationsToRemove.add(removedApplication);
        }
        // install applications sorted by application dependencies
        List sortedApplications = sortApplications(applicationsToInstall);
        for ( Iterator i = sortedApplications.iterator(); i.hasNext(); ) {
          Application application = (Application)i.next();
            Projector.getRepository().subscribe("Update", application.getUri(), 0,
                new Subscriber() {
              public void notify(String uri, Map information) {
                applicationManager.updateApplication(uri);
              }
            }, context.getCredentials());
          install(Application.MESSAGES, application);
          install(Application.PROCESSORS, application);
        }
          Scheduler.getInstance().install(new URIValue(Projector.getWorkDir() + Scheduler.JOBS), true);
        for ( Iterator i = sortedApplications.iterator(); i.hasNext(); ) {
          Application application = (Application)i.next();
          install(Application.JOBS, application);
        }
        Scheduler.getInstance().saveJobs();
View Full Code Here

      uninstall(messagesUri);
      install(messagesUri);
    }
     
  public void notify(String uri, Map information) {
    URI messageUri = new URIValue(uri);
    uninstall(messageUri);
    install(messageUri);
  }
View Full Code Here

    }
   
    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);
View Full Code Here

      }
      return null;
    }
   
  private synchronized void updateApplication(String uri) {
    URI applicationUri = new URIValue(uri);
        logger.log(Level.FINE, "Updating application '"+applicationUri+"'");
        // Compare newly parsed application with previously installed and send diffs
        Application installedApplication = (Application)installedApplications.get(applicationUri);
        Application updatedApplication = parseApplication(applicationUri);
        for ( Iterator i = installedApplication.getContent().entrySet().iterator(); i.hasNext(); ) {
View Full Code Here

                } catch (Exception e) {
                    logger.log(Level.SEVERE, "Descriptor factory " + clazz + " could not loaded!", e);
                }
            } else if ( path.matches("application/content/processors") ) {
              String uri = attributes.getValue("uri");
              application.addContent(Application.PROCESSORS, new URIValue(applicationUri+attributes.getValue("uri")));     
            } else if ( path.matches("application/content/messages") ) {
              application.addContent(Application.MESSAGES, new URIValue(applicationUri+attributes.getValue("uri")));     
            } else if ( path.matches("application/content/jobs") ) {
              application.addContent(Application.JOBS, new URIValue(applicationUri+attributes.getValue("uri")));     
            }
        }
View Full Code Here

        return routingConfigurations;
    }

    public void configure(Element element) {
    name = element.getAttributeValue("id");
        processorURI = new URIValue(element.getAttributeValue("processor"));
        List loadElements = element.getChildren("load");
    for ( Iterator i = loadElements.iterator(); i.hasNext(); ) {
      Element loadElement = (Element)i.next();
            String parameterName = loadElement.getAttributeValue("parameter");
            ParameterConfiguration parameterConfiguration = new ParameterConfiguration(parameterName);
View Full Code Here

      if ( trigger == null ) {
        throw new ValidationException(new ErrorMessage("trigger/triggerParameterMissing"));
      }
      // Decode instruction
    StringTokenizer tokenizer = new StringTokenizer(StringValueDescriptor.ANY.valueOf(parameter.get(INSTRUCTION_IDENTIFIER+trigger), context).toString(), ";");
    URI actionURI = new URIValue(tokenizer.nextToken());
    boolean validate = Boolean.valueOf(tokenizer.nextToken()).booleanValue();
    boolean wizard = Boolean.valueOf(tokenizer.nextToken()).booleanValue();
    String lastStep = tokenizer.nextToken();
    String targetStep = tokenizer.nextToken();
    String domain = tokenizer.nextToken();
    List involvedParamters = new ArrayList();
    while ( tokenizer.hasMoreTokens() ) {
      involvedParamters.add(tokenizer.nextToken());
    }
    Store store = context.getStore(Store.SESSION);
    // 1. Store all (request) parameters into requested domain
    Map map;
    MapValue mapResource = (MapValue)store.get(domain);
    if ( mapResource == null ) {
      map = new HashMap();
      mapResource = new MapValue(map);
      store.put(domain, mapResource);
    } else {
      map = mapResource.getMap();
    }
        map.put(ControlComposer.VALIDATE, new BooleanValue(validate));
      map.put(Process.STEP, new StringValue(targetStep));
      map.putAll(parameter);
      if ( validate ) {
        // 2. Validate parameters
        Processor processor = ProcessorManager.getInstance().getProcessor(actionURI);
        try {
          // Validate only given parameters to enable wizard like forms
          ParameterDescriptor[] parameterDescriptors = processor.getParameterDescriptors();
              for ( int i = 0; i < parameterDescriptors.length; i++ ) {
                String parameterName = parameterDescriptors[i].getName();
                  if ( involvedParamters.contains(parameterName) ) {
                    map.put(parameterName, ProcessorManager.prepareValue(parameterDescriptors[i], parameter.get(parameterName), context));
                  }
              }
              if ( wizard ) {
                  // Don't validate target step form
                map.put(ControlComposer.VALIDATE, BooleanValue.FALSE);
              }
          } catch ( ValidationException exception ) {
            // 3. Go back to form step if validation failes
          map.put(Process.STEP, new StringValue(lastStep));
        }
      }
      // 4. Launch target step if validation is successfull
    Processor formProcess = ProcessorManager.getInstance().getProcessor(new URIValue(domain));
        map.remove(RESULT);
        Result formResult = formProcess.process(parameter,  context);
        map.put(RESULT, formResult);
    Processor bookmark = ProcessorManager.getInstance().getProcessor(context.getBookmark());
        return bookmark.process(parameter,  context);
View Full Code Here

TOP

Related Classes of org.apache.slide.projector.value.URIValue

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.