コード例 #1
0
ファイル: TypeChecker.java プロジェクト: wrmsr/jaskell
  /** @see jaskell.compiler.JaskellVisitor#visit(QualifiedVariable) */
  public Object visit(QualifiedVariable a) {
    Module mod = null;
    Iterator it = a.getPath().iterator();
    while (it.hasNext()) {
      String mname = (String) it.next();
      if (mod != null) mod = (Module) mod.lookup(mname);
      else mod = (Module) Module.getToplevels().get(mname);
    }
    /* module found */
    if (mod != null) {
      Expression def = mod.lookup(a.getName());
      if (def == null) throw new CompilerException("Unknown variable " + a.getName());
      Type t = def.getType();
      if (t == null) t = (Type) def.visit(this);

      /* as it is the case for variable, we assume
       * that a defined symbol may be overloaded (only for primitive types)
       * so we return a type variable and defers choice of
       * symbol to a later stage
       */
      a.setType(t);
      return t;
    }
    throw new CompilerException("Unable to find module needed for variable " + a.getName());
  }
コード例 #2
0
 private static Map<String, String> buildClassToSourceMap(
     ModuleChunk chunk,
     CompileContext context,
     Set<String> toCompilePaths,
     String moduleOutputPath)
     throws IOException {
   final Map<String, String> class2Src = new HashMap<String, String>();
   for (Module module : chunk.getModules()) {
     final String moduleName = module.getName().toLowerCase(Locale.US);
     final SourceToOutputMapping srcToOut =
         context.getDataManager().getSourceToOutputMap(moduleName, context.isCompilingTests());
     for (String src : srcToOut.getKeys()) {
       if (!toCompilePaths.contains(src) && isGroovyFile(src)) {
         final Collection<String> outs = srcToOut.getState(src);
         if (outs != null) {
           for (String out : outs) {
             if (out.endsWith(".class") && out.startsWith(moduleOutputPath)) {
               final String className =
                   out.substring(moduleOutputPath.length(), out.length() - ".class".length())
                       .replace('/', '.');
               class2Src.put(className, src);
             }
           }
         }
       }
     }
   }
   return class2Src;
 }
コード例 #3
0
 // same code as above!
 @Override
 public void checkAllHardwareStopped() throws HardwareException {
   Module mainModule = (Module) lookup.getComponentByName("main");
   if (mainModule == null) {
     throw new IllegalArgumentException("no component named main!");
     // TODO log ? or error
   }
   final MutableReference<HardwareException> excList = new MutableReference<>();
   mainModule.proceduralWalk(
       configurable -> {
         if (configurable instanceof HardwareController) {
           try {
             ((HardwareController) configurable).checkStopped();
           } catch (HardwareException e) {
             excList.reference =
                 new HardwareException(
                     configurable.toString() + "not stopped ", e, excList.reference);
           }
         }
       },
       null);
   /* */
   if (excList.reference != null) {
     throw excList.reference;
   }
 }
コード例 #4
0
  public static Module parse(final URI descriptor, final Handler defaultHandler)
      throws IOException, ParseException, IllegalArgumentException {
    if (descriptor == null)
      throw new IllegalArgumentException("The module descriptor URI cannot be null.");

    // Instantiate module and load document
    final Module module = new Module(descriptor, defaultHandler);
    final Document document;
    try {
      document = builderFactory.newDocumentBuilder().parse(new File(descriptor));
    } catch (SAXException e) {
      throw new ParseException("Cannot parse XML document, see inner exception for details.", e);
    } catch (ParserConfigurationException e) {
      throw new ParseException(
          "XML parser configuration invalid, see inner exception for details.", e);
    }

    // Verify root element
    final String moduleType = extract(document, "/module/@type", "Cannot extract module type");
    if (!"JAVA_MODULE".equals(moduleType))
      throw new ParseException("Module \"" + module.getName() + "\" is not a Java module.");

    try {
      module.processComponents(document);
    } catch (ParseException e) {
      throw new ParseException("Cannot parse module \"" + module.getName() + "\".", e);
    }

    return module;
  }
コード例 #5
0
  /**
   * invoke a <TT>checkHardware</TT> on all <TT>HardwareController</TT> (except when return diag
   * modifies the path of invocation)
   *
   * @throws HardwareException a list of HardwareException
   */
  @Override
  public void checkHardware() throws HardwareException {
    Module mainModule = (Module) lookup.getComponentByName("main");
    if (mainModule == null) {
      throw new IllegalArgumentException("no component named main!");
      // TODO log ? or error
    }
    final MutableReference<HardwareException> excList = new MutableReference<>();
    mainModule.treeWalk(
        configurable -> {
          if (configurable instanceof HardwareController) {
            try {
              return ((HardwareController) configurable).checkHardware();
            } catch (HardwareException e) {
              excList.reference =
                  new HardwareException(
                      configurable.toString() + " fails check", e, excList.reference);
              // todo: not correct: what if not fatal and we still want to return Handler-children
              if (e.isFatal()) {
                return TreeWalkerDiag.STOP;
              }
            }
          }
          return TreeWalkerDiag.GO;
        },
        null);
    /*

    */
    if (excList.reference != null) {
      throw excList.reference;
    }
  }
コード例 #6
0
 private ModuleClassLoader getModuleClassLoader(boolean logResolveError) {
   ResolutionReport report = resolve();
   if (logResolveError && !Module.RESOLVED_SET.contains(module.getState())) {
     String reportMessage = report.getResolutionReportMessage(module.getCurrentRevision());
     equinoxContainer
         .getEventPublisher()
         .publishFrameworkEvent(
             FrameworkEvent.ERROR,
             this,
             new BundleException(reportMessage, BundleException.RESOLVE_ERROR));
   }
   return AccessController.doPrivileged(
       new PrivilegedAction<ModuleClassLoader>() {
         @Override
         public ModuleClassLoader run() {
           ModuleWiring wiring = getModule().getCurrentRevision().getWiring();
           if (wiring != null) {
             ModuleLoader moduleLoader = wiring.getModuleLoader();
             if (moduleLoader instanceof BundleLoader) {
               return ((BundleLoader) moduleLoader).getModuleClassLoader();
             }
           }
           return null;
         }
       });
 }
コード例 #7
0
  private static boolean packageResources(
      @NotNull AndroidFacet facet, @NotNull CompileContext context) {
    final Module module = facet.getModule();

    try {
      context.processMessage(
          new ProgressMessage(
              AndroidJpsBundle.message(
                  "android.jps.progress.packaging.resources", module.getName())));

      final File manifestFile = AndroidJpsUtil.getManifestFileForCompilationPath(facet);
      if (manifestFile == null) {
        context.processMessage(
            new CompilerMessage(
                BUILDER_NAME,
                BuildMessage.Kind.ERROR,
                AndroidJpsBundle.message(
                    "android.jps.errors.manifest.not.found", module.getName())));
        return false;
      }
      final ArrayList<String> assetsDirPaths = new ArrayList<String>();
      collectAssetDirs(facet, assetsDirPaths);

      final File outputDir =
          AndroidJpsUtil.getOutputDirectoryForPackagedFiles(context.getProjectPaths(), module);
      if (outputDir == null) {
        context.processMessage(
            new CompilerMessage(
                BUILDER_NAME,
                BuildMessage.Kind.ERROR,
                AndroidJpsBundle.message(
                    "android.jps.errors.output.dir.not.specified", module.getName())));
        return false;
      }

      final Pair<AndroidSdk, IAndroidTarget> pair =
          AndroidJpsUtil.getAndroidPlatform(module, context, BUILDER_NAME);
      if (pair == null) {
        return false;
      }
      final IAndroidTarget target = pair.getSecond();

      final String outputFilePath = getPackagedResourcesFile(module, outputDir).getPath();
      final String[] resourceDirPaths =
          AndroidJpsUtil.collectResourceDirsForCompilation(facet, true, context);

      return doPackageResources(
          context,
          manifestFile,
          target,
          resourceDirPaths,
          ArrayUtil.toStringArray(assetsDirPaths),
          outputFilePath,
          AndroidJpsUtil.isReleaseBuild(context));
    } catch (IOException e) {
      AndroidJpsUtil.reportExceptionError(context, null, e, BUILDER_NAME);
      return false;
    }
  }
コード例 #8
0
ファイル: Project.java プロジェクト: Chrlis-zhang/RAP
 public Page findPage(int pageId) {
   for (Module module : getModuleList()) {
     for (Page page : module.getPageList()) {
       if (page.getId() == pageId) return page;
     }
   }
   return null;
 }
コード例 #9
0
 public Set<Module> getAllRequiredModules() {
   Set<Module> modules = new LinkedHashSet<Module>();
   modules.add(this);
   for (Module module : this.modules) {
     modules.addAll(module.getAllRequiredModules());
   }
   return modules;
 }
コード例 #10
0
  private static boolean runPngCaching(
      @NotNull CompileContext context,
      @NotNull Module module,
      @NotNull AndroidFileSetStorage storage,
      @Nullable AndroidFileSetState state)
      throws IOException {
    final AndroidFileSetState savedState = storage.getState(module.getName());
    if (context.isMake() && savedState != null && savedState.equalsTo(state)) {
      return true;
    }

    final AndroidFacet facet = AndroidJpsUtil.getFacet(module);
    if (facet == null) {
      return true;
    }

    context.processMessage(
        new CompilerMessage(
            BUILDER_NAME,
            BuildMessage.Kind.INFO,
            AndroidJpsBundle.message("android.jps.progress.res.caching", module.getName())));

    final File resourceDir = AndroidJpsUtil.getResourceDirForCompilationPath(facet);
    if (resourceDir == null) {
      return true;
    }

    final Pair<AndroidSdk, IAndroidTarget> pair =
        AndroidJpsUtil.getAndroidPlatform(module, context, BUILDER_NAME);
    if (pair == null) {
      return false;
    }

    final File resCacheDir = AndroidJpsUtil.getResourcesCacheDir(context, module);

    if (!resCacheDir.exists()) {
      if (!resCacheDir.mkdirs()) {
        context.processMessage(
            new CompilerMessage(
                BUILDER_NAME,
                BuildMessage.Kind.ERROR,
                "Cannot create directory " + resCacheDir.getPath()));
        return false;
      }
    }

    final IAndroidTarget target = pair.second;

    final Map<AndroidCompilerMessageKind, List<String>> messages =
        AndroidApt.crunch(
            target, Collections.singletonList(resourceDir.getPath()), resCacheDir.getPath());

    AndroidJpsUtil.addMessages(context, messages, BUILDER_NAME);

    final boolean success = messages.get(AndroidCompilerMessageKind.ERROR).isEmpty();
    storage.update(module.getName(), success ? state : null);
    return success;
  }
コード例 #11
0
ファイル: Project.java プロジェクト: Chrlis-zhang/RAP
 public Action findAction(int actionId) {
   for (Module module : getModuleList()) {
     for (Page page : module.getPageList()) {
       for (Action action : page.getActionList()) {
         if (action.getId() == actionId) return action;
       }
     }
   }
   return null;
 }
コード例 #12
0
 /** forwards a HALT signal to all components (that are signalHandlers) */
 @org.lsst.ccs.command.annotations.Command(description = "halt", type = SIGNAL)
 @Override
 public void abort() {
   super.abort();
   Module mainModule = (Module) lookup.getComponentByName("main");
   if (mainModule == null) {
     throw new IllegalArgumentException("no component named main!");
     // TODO log ? or error
   }
   mainModule.percolateSignal(new Signal(SignalLevel.HALT));
 }
コード例 #13
0
ファイル: Project.java プロジェクト: Chrlis-zhang/RAP
 public List<Action> getAllAction() {
   List<Action> list = new ArrayList<Action>();
   for (Module m : this.moduleList) {
     for (Page p : m.getPageList()) {
       for (Action a : p.getActionList()) {
         list.add(a);
       }
     }
   }
   return list;
 }
コード例 #14
0
  private ProjectWrapper(
      final GantBinding binding,
      final String prjDir,
      final String setupScript,
      final Map<String, String> pathVariables,
      final boolean loadHistory) {
    affectedFiles = new HashSet<String>();

    myProject = new GantBasedProject(binding == null ? new GantBinding() : binding);
    myProjectBuilder = myProject.getBuilder();

    final File prjFile = new File(prjDir);
    final boolean dirBased = !(prjFile.isFile() && prjDir.endsWith(".ipr"));

    myRoot = dirBased ? getCanonicalPath(prjDir) : getCanonicalPath(prjFile.getParent());

    final String loadPath = dirBased ? getAbsolutePath(myIDEADir) : prjDir;

    IdeaProjectLoader.loadFromPath(
        myProject,
        loadPath,
        pathVariables != null ? pathVariables : Collections.<String, String>emptyMap(),
        setupScript);

    myProjectSnapshot =
        myHomeDir
            + File.separator
            + myJPSDir
            + File.separator
            + myRoot.replace(File.separatorChar, myFileSeparatorReplacement);

    try {
      dependencyMapping = new Mappings(getMapDir());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    backendCallback = dependencyMapping.getCallback();

    for (Module m : myProject.getModules().values()) {
      myModules.put(m.getName(), new ModuleWrapper(m));
    }

    for (Library l : myProject.getLibraries().values()) {
      myLibraries.put(l.getName(), new LibraryWrapper(l));
    }

    myHistory = loadHistory ? loadSnapshot(affectedFiles) : null;

    if (loadHistory) {
      dependencyMapping = myHistory.dependencyMapping;
    }
  }
コード例 #15
0
 /** forwards a STOP signal to all components (that are signalHandlers) */
 @org.lsst.ccs.command.annotations.Command(
     description = "stops with expected max delay",
     type = ACTION)
 @Override
 public void stop(long expectedMaxDelay) throws HardwareException {
   super.stop(expectedMaxDelay);
   Module mainModule = (Module) lookup.getComponentByName("main");
   if (mainModule == null) {
     throw new IllegalArgumentException("no component named main!");
     // TODO log ? or error
   }
   mainModule.percolateSignal(new Signal(SignalLevel.STOP, expectedMaxDelay));
 }
コード例 #16
0
  public List<ContainerUnit> listContainers(String applicationName, boolean withModules)
      throws ServiceException {
    List<ContainerUnit> containers = new ArrayList<>();
    try {
      Application application =
          findByNameAndUser(authentificationUtils.getAuthentificatedUser(), applicationName);
      if (application != null) {
        try {
          // Serveurs
          List<Server> servers = application.getServers();
          // Ajout des containers de type server
          for (Server server : servers) {
            DockerContainer dockerContainer = new DockerContainer();
            dockerContainer.setName(server.getName());
            dockerContainer = DockerContainer.findOne(dockerContainer, application.getManagerIp());
            server = containerMapper.mapDockerContainerToServer(dockerContainer, server);
            ContainerUnit containerUnit =
                new ContainerUnit(server.getName(), server.getContainerID(), "server");
            containers.add(containerUnit);
          }
          if (withModules) {
            // Ajout des containers de type module
            List<Module> modules = application.getModules();
            for (Module module : modules) {
              // on evite de remonter les modules de type toolkit
              // (git, maven...)
              if (module.isTool()) {
                continue;
              }
              DockerContainer dockerContainer = new DockerContainer();
              dockerContainer.setName(module.getName());
              dockerContainer =
                  DockerContainer.findOne(dockerContainer, application.getManagerIp());
              module = containerMapper.mapDockerContainerToModule(dockerContainer, module);
              ContainerUnit containerUnit =
                  new ContainerUnit(module.getName(), module.getContainerID(), "module");
              containers.add(containerUnit);
            }
          }
        } catch (Exception ex) {
          // Si une application sort en erreur, il ne faut pas
          // arrêter la suite des traitements
          logger.error(application.toString(), ex);
        }
      }

    } catch (Exception e) {
      throw new ServiceException(e.getLocalizedMessage(), e);
    }
    return containers;
  }
コード例 #17
0
    public List<ClasspathItemWrapper> dependsOn(final boolean tests) {
      if (tests) {
        if (myTestDependsOn != null) {
          return myTestDependsOn;
        }
      } else if (myDependsOn != null) {
        return myDependsOn;
      }

      final List<ClasspathItemWrapper> result = new ArrayList<ClasspathItemWrapper>();

      for (ClasspathItem cpi : myModule.getClasspath(ClasspathKind.compile(tests))) {
        if (cpi instanceof Module) {
          result.add(getModule(((Module) cpi).getName()));
        } else if (cpi instanceof Library) {
          result.add(new LibraryWrapper((Library) cpi));
        } else {
          result.add(new GenericClasspathItemWrapper(cpi));
        }
      }

      if (tests) {
        myTestDependsOn = result;
      } else {
        myDependsOn = result;
      }

      return result;
    }
コード例 #18
0
  private void _loadConfig() {
    try {

      _configScope.set("__instance__", this);

      _loadConfigFromCloudObject(getSiteObject());
      _loadConfigFromCloudObject(getEnvironmentObject());

      File f;
      if (!_admin) {
        f = getFileSafe("_config.js");
        if (f == null || !f.exists()) f = getFileSafe("_config");
      } else
        f =
            new File(
                Module.getModule("core-modules/admin").getRootFile(getVersionForLibrary("admin")),
                "_config.js");

      _libraryLogger.info("config file [" + f + "] exists:" + f.exists());

      if (f == null || !f.exists()) return;

      Convert c = new Convert(f);
      JSFunction func = c.get();
      func.setUsePassedInScope(true);
      func.call(_configScope);

      _logger.debug("config things " + _configScope.keySet());
    } catch (Exception e) {
      throw new RuntimeException("couldn't load config", e);
    }
  }
コード例 #19
0
  /** Save the javac_state file. */
  public void save() throws IOException {
    if (!needsSaving) return;
    try (FileWriter out = new FileWriter(javacStateFilename)) {
      StringBuilder b = new StringBuilder();
      long millisNow = System.currentTimeMillis();
      Date d = new Date(millisNow);
      SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
      b.append("# javac_state ver 0.3 generated " + millisNow + " " + df.format(d) + "\n");
      b.append("# This format might change at any time. Please do not depend on it.\n");
      b.append("# M module\n");
      b.append("# P package\n");
      b.append("# S C source_tobe_compiled timestamp\n");
      b.append("# S L link_only_source timestamp\n");
      b.append("# G C generated_source timestamp\n");
      b.append("# A artifact timestamp\n");
      b.append("# D dependency\n");
      b.append("# I pubapi\n");
      b.append("# R arguments\n");
      b.append("R ").append(theArgs).append("\n");

      // Copy over the javac_state for the packages that did not need recompilation.
      now.copyPackagesExcept(prev, recompiledPackages, new HashSet<String>());
      // Save the packages, ie package names, dependencies, pubapis and artifacts!
      // I.e. the lot.
      Module.saveModules(now.modules(), b);

      String s = b.toString();
      out.write(s, 0, s.length());
    }
  }
コード例 #20
0
 @Override
 public boolean hasPermission(Object permission) {
   Generation current = (Generation) module.getCurrentRevision().getRevisionInfo();
   ProtectionDomain domain = current.getDomain();
   if (domain != null) {
     if (permission instanceof Permission) {
       SecurityManager sm = System.getSecurityManager();
       if (sm instanceof EquinoxSecurityManager) {
         /*
          * If the FrameworkSecurityManager is active, we need to do checks the "right" way.
          * We can exploit our knowledge that the security context of FrameworkSecurityManager
          * is an AccessControlContext to invoke it properly with the ProtectionDomain.
          */
         AccessControlContext acc = new AccessControlContext(new ProtectionDomain[] {domain});
         try {
           sm.checkPermission((Permission) permission, acc);
           return true;
         } catch (Exception e) {
           return false;
         }
       }
       return domain.implies((Permission) permission);
     }
     return false;
   }
   return true;
 }
コード例 #21
0
ファイル: Project.java プロジェクト: Chrlis-zhang/RAP
 public Parameter findParameter(int parameterId, boolean isRequestType) {
   for (Module module : getModuleList()) {
     for (Page page : module.getPageList()) {
       for (Action action : page.getActionList()) {
         for (Parameter parameter :
             (isRequestType
                 ? action.getRequestParameterList()
                 : action.getResponseParameterList())) {
           if (parameter.getId() == parameterId) {
             return parameter;
           }
         }
       }
     }
   }
   return null;
 }
コード例 #22
0
 @Override
 public void stop(int options) throws BundleException {
   if (options == 0 && equinoxContainer.getConfiguration().getDebug().MONITOR_ACTIVATION) {
     Debug.printStackTrace(
         new Exception("A persistent stop has been called on bundle: " + this)); // $NON-NLS-1$
   }
   module.stop(getStopOptions(options));
 }
コード例 #23
0
ファイル: TypeChecker.java プロジェクト: wrmsr/jaskell
 /* (non-Javadoc)
  * @see jaskell.compiler.JaskellVisitor#visit(jaskell.compiler.core.Module)
  */
 public Object visit(Module a) {
   try {
     return visit((Namespace) a);
   } catch (TypeError te) {
     if (te.getLineCol() == null) te.setLineCol(a.getTag("source"));
     log.severe("Type error at (" + te.getLineCol() + ") : " + te.getMessage());
     throw te;
   }
 }
コード例 #24
0
  /**
   * Lancer par signal de NoPublicController quand le processus sshd est démarré dans les containers
   * serveur et git
   */
  public Application updateEnv(Application application, User user) throws ServiceException {

    logger.info("--update Env of Server--");
    String command = null;
    Map<String, String> configShellModule = new HashMap<>();
    Map<String, String> configShellServer = new HashMap<>();

    Module moduleGit = moduleService.findGitModule(user.getLogin(), application);
    Server server = application.getServers().get(0);

    String rootPassword = application.getUser().getPassword();
    configShellModule.put("port", moduleGit.getSshPort());
    configShellModule.put("dockerManagerAddress", moduleGit.getApplication().getManagerIp());
    configShellModule.put("password", rootPassword);
    configShellModule.put("dockerManagerAddress", application.getManagerIp());
    logger.info("new server ip : " + server.getContainerIP());
    try {
      int counter = 0;
      while (!server.getStatus().equals(Status.START)
          || !moduleGit.getStatus().equals(Status.START)) {
        if (counter == 100) {
          break;
        }
        Thread.sleep(1000);
        logger.info(" wait git and server sshd processus start");
        logger.info(
            "SSHDSTATUS = server : " + server.getStatus() + " - module : " + moduleGit.getStatus());
        moduleGit = moduleService.findById(moduleGit.getId());
        server = serverService.findById(server.getId());
        counter++;
      }
      command = ". /cloudunit/scripts/update-env.sh " + server.getContainerIP();
      logger.info("command shell to execute [" + command + "]");

      shellUtils.executeShell(command, configShellModule);

      configShellServer.put("port", server.getSshPort());
      configShellServer.put("dockerManagerAddress", server.getApplication().getManagerIp());
      configShellServer.put("password", rootPassword);
      command = ". /cloudunit/scripts/rm-auth-keys.sh ";
      logger.info("command shell to execute [" + command + "]");

      shellUtils.executeShell(command, configShellServer);
      String cleanCommand = server.getServerAction().cleanCommand();
      if (cleanCommand != null) {
        shellUtils.executeShell(server.getServerAction().cleanCommand(), configShellServer);
      }
    } catch (Exception e) {
      moduleGit.setStatus(Status.FAIL);
      moduleGit = moduleService.saveInDB(moduleGit);
      server.setStatus(Status.FAIL);
      server = serverService.saveInDB(server);
      logger.error("Error :  Error during update Env var of GIT " + e);
      throw new ServiceException(e.getLocalizedMessage(), e);
    }
    return application;
  }
コード例 #25
0
 @Override
 public int getState() {
   switch (module.getState()) {
     case INSTALLED:
       return Bundle.INSTALLED;
     case RESOLVED:
       return Bundle.RESOLVED;
     case STARTING:
     case LAZY_STARTING:
       return Bundle.STARTING;
     case ACTIVE:
       return Bundle.ACTIVE;
     case STOPPING:
       return Bundle.STOPPING;
     case UNINSTALLED:
       return Bundle.UNINSTALLED;
     default:
       throw new IllegalStateException(
           "No valid bundle state for module state: " + module.getState()); // $NON-NLS-1$
   }
 }
コード例 #26
0
  private static boolean checkUpToDate(
      @NotNull Module module,
      @NotNull Map<Module, AndroidFileSetState> module2state,
      @NotNull AndroidFileSetStorage storage)
      throws IOException {
    final AndroidFileSetState moduleState = module2state.get(module);
    final AndroidFileSetState savedState = storage.getState(module.getName());
    if (savedState == null || !savedState.equalsTo(moduleState)) {
      return false;
    }

    for (AndroidFacet libFacet : AndroidJpsUtil.getAllAndroidDependencies(module, true)) {
      final Module libModule = libFacet.getModule();
      final AndroidFileSetState currentLibState = module2state.get(libModule);
      final AndroidFileSetState savedLibState = storage.getState(libModule.getName());

      if (savedLibState == null || !savedLibState.equalsTo(currentLibState)) {
        return false;
      }
    }
    return true;
  }
コード例 #27
0
ファイル: Project.java プロジェクト: Chrlis-zhang/RAP
  public Parameter findChildParameter(int parameterId) {
    for (Module module : getModuleList()) {
      for (Page page : module.getPageList()) {
        for (Action action : page.getActionList()) {
          for (Parameter parameter : action.getRequestParameterList()) {
            Parameter pRecur = findParameterRecursively(parameter, parameterId);
            if (pRecur != null) {
              return pRecur;
            }
          }

          for (Parameter parameter : action.getResponseParameterList()) {
            Parameter pRecur = findParameterRecursively(parameter, parameterId);
            if (pRecur != null) {
              return pRecur;
            }
          }
        }
      }
    }
    return null;
  }
コード例 #28
0
  /**
   * Add git container to application associated to server
   *
   * @param application
   * @return
   * @throws ServiceException
   * @throws CheckException
   */
  private Module addGitContainer(Application application, String tagName)
      throws ServiceException, CheckException {

    Module moduleGit = ModuleFactory.getModule("git");
    // todo : externaliser la variable
    String containerGitAddress = "/cloudunit/git/.git";

    try {
      // Assign fixed host ports for forwarding git ports (22)
      Map<String, String> mapProxyPorts = portUtils.assignProxyPorts(application);
      String freeProxySshPortNumber = mapProxyPorts.get("freeProxySshPortNumber");

      // Creation of git container fo application
      moduleGit.setName("git");
      moduleGit.setImage(imageService.findByName("git"));
      moduleGit.setApplication(application);

      moduleGit.setSshPort(freeProxySshPortNumber);
      moduleGit = moduleService.initModule(application, moduleGit, tagName);

      application.getModules().add(moduleGit);
      application.setGitContainerIP(moduleGit.getContainerIP());

      application.setGitSshProxyPort(freeProxySshPortNumber);

      // Update GIT respository informations in the current application
      application.setGitAddress(
          "ssh://"
              + AlphaNumericsCharactersCheckUtils.convertToAlphaNumerics(
                  application.getUser().getLogin())
              + "@"
              + application.getName()
              + "."
              + application.getSuffixCloudUnitIO().substring(1)
              + ":"
              + application.getGitSshProxyPort()
              + containerGitAddress);

      moduleGit.setStatus(Status.START);
      moduleGit = moduleService.update(moduleGit);

    } catch (UnsupportedEncodingException e) {
      moduleGit.setStatus(Status.FAIL);
      logger.error("Error :  Error during persist git module " + e);
      throw new ServiceException(e.getLocalizedMessage(), e);
    }
    return moduleGit;
  }
コード例 #29
0
ファイル: ModuleTest.java プロジェクト: Geo--/ExamTimetable
  @Test
  public void test() {
    // Create students, and populate them into a List of there studies.
    Student studenta = new Student("Paul Barber", "1000");
    Student studentb = new Student("Chris Cooper", "A1000");
    Student studentc = new Student("Paul, Barber", "B1000");
    List<Student> studiesHistory = new ArrayList<Student>();
    studiesHistory.add(studenta);
    studiesHistory.add(studentb);
    studiesHistory.add(studentc);
    List<Student> studiesSport = new ArrayList<Student>();
    studiesSport.add(studentb);

    // Create exams for the modules.
    Exam exam = new Exam(2);
    Exam exama = new Exam(1);

    // Create the modules with the above date.
    Module module = new Module("HIS100", "History", exam, studiesHistory);
    Module sport = new Module("SPO109", "Sport", exama, studiesSport);
    List<Module> allModules = new ArrayList<Module>();
    // add all the modules to an allModules list.
    allModules.add(module);
    allModules.add(sport);

    // Set the Modules List in the Student Class.
    System.out.println(module.getStudentsEnrolled());
    System.out.println(sport.getStudentsEnrolled());
    System.out.println(studenta.getStudiesModules());
    studenta.setModules(allModules);
    studentb.setModules(allModules);
    studentc.setModules(allModules);
    System.out.println(studenta.getStudiesModules());
    System.out.println(studentb.getStudiesModules());
    System.out.println(studentc.getStudiesModules());

    System.out.println(module.compareTo(sport));
  }
コード例 #30
0
    public ModuleWrapper(final Module m) {
      m.forceInit();
      myModule = m;
      myDependsOn = null;
      myTestDependsOn = null;
      myName = m.getName();
      myExcludes = new HashSet<String>(m.getExcludes());
      mySource = new Properties(m.getSourceRoots(), m.getOutputPath(), myExcludes);
      myTest = new Properties(m.getTestRoots(), m.getTestOutputPath(), myExcludes);

      myLibraries = new HashSet<LibraryWrapper>();

      for (Library lib : m.getLibraries().values()) {
        myLibraries.add(new LibraryWrapper(lib));
      }
    }