Wiki

Imprimir Propiedades
Roma_users_module_user_module

Install Users module

 

The users module will allow us to manage user's accounts with different profiles and privileges. First of all we add this module from the Roma console:

./roma.sh add users

 

A set of files will be created in the current project. The structure and functionality of these files are as follow:

 

roma-users0.6.jar - Under /lib directory provide the java classes for the module

applicationContext-users.xml - Under WebContent/WEB-INF with some information like the dependences of the user module.

applicationContext.xml – Where are defined the modules currently installed in the application

CustomLogin – Under gesfor.roma.swrisks.view.domain package. This class extends Login and allow us to login in the application under different profiles. It has two methods:

onSuccess() - Where we can define the actions to perform if the introduced user and password corresponds to an existent user account.

onError() - Where we define the actions to perform if the user and/or password are incorrect.

 

By default, this class is rendered as “popup” so if we visualize this class in a browser a popup window requiring our user and password will appear. To visualize this class we will put a button in the class HomePage which is the initial page that Roma shows by default.

Inside the package gesfor.roma.swrisks.view.domain, in HomePage.java we replace the button() method (generated automatically when create a web-project) with:

 

@FlowAction(next=CustomLogin.class)

public void login() {

}

 

With the java annotation @FlowAction we can control the flow of the application when it is executed. The next attribute indicates that clicking on Login in the HomePage the CustomLogin class will be shown.

 

To indicate what to do when entering a correct user and password we modify the onSuccess() method inside CustomLogin located in gesfor.roma.swrisks.view.domain as follow:

 

@Override

protected void onSuccess() {

  super.onSuccess();

  ActivityLogHelper.getInstance().log(LoggingConstants.LEVEL_INFO, ActivityLogCategories.CATEGORY_LOGIN,"Connection from ip: " +WebRenderServlet.getActiveConnection().getRequest().getRemoteHost());

  try {

   ObjectContext.getInstance().getComponent(ViewAspect.class). show(AuthenticatedHomePage.class.newInstance());

  } catch (Exception e) {

   e.printStackTrace();

  }

}

 

With the ActivityLogHelper class we can register different kinds of information. In this case we are registering information of type LEVEL_INFO with the category CATEGORY_LOGIN and a String with the IP direction of the host connecting the application. Next, in the try section, we indicate Roma that shows the AuthenticatedHomePage class (this method is only called when user and password are correct).

 

The CustomLogin and HomePage classes are under package gesfor.roma.swrisks.view.domain where the classes related with the presentation are placed. In this package we will create the AuthenticatedHomePage class showed when any user log in. This class is as follow:

 

AuthenticatedHomePage

 

@CoreClass(orderActions = "Risks Attacks Companies Logout")

@ViewClass(layout = "screen://body")

public class AuthenticatedHomePage {

  @FlowAction(next=RiskMain.class)

  public void Risks() {

  }

  @FlowAction(next=AttackMain.class)

  public void Attacks() {

  }

  @FlowAction(next=CompanyMain.c  public void Companies() {

  }

  @FlowAction(next=HomePage.class)

  public void Logout() {

  }

}

Once we have fixed the required imports we can observe that different methods redirects the flow to the classes generated with the ./roma.sh crud command. Specifically the NameMain classes (where name is the name of the class which we have generated a CRUD) provides a filter as an instance of the generated nameFilter class and a result, as a list of instances of generated class nameListable. With the filter we can type the search restrictions and the result instance will show a list of coincidences. This provide an interface to manage data with CRUD (CReate Update Delete) operations as seen in the following figure for the RiskMain class.

 

 

The filter is the formulary shown on top, with the attributes of the Risk class and below are shown the result object with the CRUD operations and a list with the results.

 

<< Prev Roma Users module Next>>
2237 Accesos, 0 Ficheros adjuntos 0 Ficheros adjuntos

  • Comentarios