View Javadoc
1   package fr.paris.lutece.plugins.appcenter.modules.openam.business;
2   
3   import com.fasterxml.jackson.annotation.JsonIgnore;
4   import fr.paris.lutece.plugins.appcenter.business.Application;
5   import fr.paris.lutece.plugins.appcenter.business.ApplicationHome;
6   import javax.validation.constraints.Size;
7   
8   import org.hibernate.validator.constraints.NotEmpty;
9   
10  import fr.paris.lutece.plugins.appcenter.business.Demand;
11  import fr.paris.lutece.plugins.appcenter.service.ApplicationService;
12  import fr.paris.lutece.plugins.appcenter.web.Constants;
13  import fr.paris.lutece.portal.service.template.AppTemplateService;
14  import fr.paris.lutece.portal.service.util.AppLogService;
15  import java.io.IOException;
16  import java.util.HashMap;
17  import java.util.Locale;
18  import java.util.Map;
19  
20  /**
21   * 
22   * OpenamDemand
23   *
24   */
25  public class OpenamDemand extends Demand
26  {
27  
28      public static final String ID_DEMAND_TYPE = "openam";
29      public static final String DEMAND_TYPE = "openam";
30  
31      private static final String TEMPLATE_SOURCES_DEMAND_INFOS = "skin/plugins/appcenter/modules/openam/openam_agents_demand_infos.html";
32  
33      @NotEmpty( message = "#i18n{module.appcenter.openam.validation.openamagent.webapp.notEmpty}" )
34      @Size( max = 50, message = "#i18n{module.appcenter.openam.validation.openamagent.webapp.size}" )
35      private String _strWebAppName;
36      @NotEmpty( message = "#i18n{module.appcenter.openam.validation.openamagent.publicurl.notEmpty}" )
37      @Size( max = 250, message = "#i18n{module.appcenter.openam.validation.openamagent.publicurl.size}" )
38      private String _strPublicUrl;
39      private boolean _bG98SettingNeeded;
40  
41      public String getWebappName( )
42      {
43          return _strWebAppName;
44      }
45  
46      public void setWebappName( String strWebAppName )
47      {
48          _strWebAppName = strWebAppName;
49      }
50  
51      public String getPublicUrl( )
52      {
53          return _strPublicUrl;
54      }
55  
56      public void setPublicUrl( String strPublicUrl )
57      {
58          _strPublicUrl = strPublicUrl;
59      }
60  
61      /**
62       * Returns a boolean describing whether a G98 setting is needed or not
63       *
64       * @return True if a G98 setting is needed
65       */
66      public boolean getG98SettingNeeded( )
67      {
68          return _bG98SettingNeeded;
69      }
70  
71      /**
72       * Sets a boolean describing whether a G98 setting is needed or not
73       *
74       * @param bG98SettingNeeded
75       *            True if a G98 setting is needed
76       */
77      public void setG98SettingNeeded( boolean bG98SettingNeeded )
78      {
79          _bG98SettingNeeded = bG98SettingNeeded;
80      }
81  
82      @Override
83      public String getComplementaryInfos( )
84      {
85          Map<String, Object> model = new HashMap<String, Object>( );
86          model.put( MARK_DEMAND, this );
87  
88          if ( this.getIdApplicationData(  ) != null )
89          {
90              Application application = ApplicationHome.findByPrimaryKey( this.getIdApplication( ) );
91  
92              try
93              {
94                  OpenamAgentData./../../../../../fr/paris/lutece/plugins/appcenter/modules/openam/business/OpenamAgentData.html#OpenamAgentData">OpenamAgentData data = (OpenamAgentData) ApplicationService.loadApplicationDataById(this.getIdApplicationData(), application, OpenamAgentsData.class );
95                  model.put( Constants.MARK_DATA, data );
96              }
97              catch( IOException e )
98              {
99                  AppLogService.error( e );
100             }
101         }
102 
103         return AppTemplateService.getTemplate( TEMPLATE_SOURCES_DEMAND_INFOS, Locale.FRENCH, model ).getHtml( );
104     }
105 
106     /**
107      * Get the demand type id
108      * 
109      * @return the demand type id
110      */
111     @JsonIgnore
112     @Override
113     public String getIdDemandType( )
114     {
115         return ID_DEMAND_TYPE;
116     }
117 
118     /**
119      * Get the demand type id
120      * 
121      * @return the demand type id
122      */
123     @JsonIgnore
124     @Override
125     public String getDemandType( )
126     {
127         return DEMAND_TYPE;
128     }
129 
130     @JsonIgnore
131     @Override
132     public boolean isDependingOfEnvironment()
133     {
134         return true;
135     }
136 
137 }