Esempio n. 1
0
  public static AppModule findByName(String name)
      throws ElementNotFoundException, NotEmptyException, DataLengthException {

    if (name == null || name.length() == 0) throw new NotEmptyException("name cannot be empty");

    if (name.length() > 100)
      throw new DataLengthException("ident parameter is too long (max: 100 carac)");

    List<AppModule> elements = AppModule.findAllAppModules();
    for (AppModule element : elements)
      if (element.getName().compareToIgnoreCase(name) == 0) return element;
    throw new ElementNotFoundException("No Module Object found with name: " + name);
  }
Esempio n. 2
0
  public static AppModule create(String name, String description, String controller)
      throws AccessNotAllowedException, NotEmptyException, DataLengthException, NotUniqueException,
          DataFormatException {

    if (name == null || name.length() == 0) throw new NotEmptyException("name cannot be empty");

    if (name.length() > 100)
      throw new DataLengthException("ident parameter is too long (max: 100 carac)");

    if (controller == null || controller.length() == 0)
      throw new NotEmptyException("controller cannot be empty");

    if (isNameExist(name)) throw new NotUniqueException("name has to be unique");

    if (Tools.hasRight("ADD_MODULE")) {
      AppModule module = new AppModule();
      module.setName(name);
      module.setDescription(description);
      module.setModuleController(controller);
      module.persist();
      return module;
    } else throw new AccessNotAllowedException("You can't add a module entry");
  }