ScopeApiHelper.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.core.config.rs.server.api.impl.scope;
  21. import org.openspcoop2.core.config.rs.server.api.impl.Enums;
  22. import org.openspcoop2.core.config.rs.server.api.impl.HttpRequestWrapper;
  23. import org.openspcoop2.core.config.rs.server.model.Scope;
  24. import org.openspcoop2.core.config.rs.server.model.ScopeItem;
  25. import org.openspcoop2.web.ctrlstat.servlet.scope.ScopeCostanti;

  26. /**
  27.  * ScopeApiHelper
  28.  *
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  *
  32.  */
  33. public class ScopeApiHelper {
  34.    
  35.    
  36.    

  37.     public static final org.openspcoop2.core.registry.Scope apiScopeToRegistroScope(Scope s, String userLogin) {
  38.         org.openspcoop2.core.registry.Scope ret = new org.openspcoop2.core.registry.Scope();
  39.        
  40.         ret.setNome(s.getNome());
  41.         if (s.getIdentificativoEsterno() != null)
  42.             ret.setNomeEsterno(s.getIdentificativoEsterno().trim());
  43.        
  44.         ret.setContestoUtilizzo(Enums.apiContestoToRegistroContesto.get(s.getContesto()));
  45.         ret.setDescrizione(s.getDescrizione());
  46.         ret.setSuperUser(userLogin);
  47.        
  48.         return ret;
  49.     }
  50.    
  51.     public static final ScopeItem registroScopeToScopeItem(org.openspcoop2.core.registry.Scope scope) {
  52.         ScopeItem ret = new ScopeItem();
  53.         ret.setContesto(Enums.registroContestoToApiContesto.get(scope.getContestoUtilizzo()));
  54.         ret.setNome(scope.getNome());
  55.         return ret;
  56.     }
  57.    
  58.     public static final Scope registroScopeToScope(org.openspcoop2.core.registry.Scope scope) {
  59.         Scope ret = new Scope();
  60.         ret.setContesto(Enums.registroContestoToApiContesto.get(scope.getContestoUtilizzo()));
  61.         ret.setNome(scope.getNome());
  62.         ret.setDescrizione(scope.getDescrizione());
  63.         ret.setIdentificativoEsterno(scope.getNomeEsterno());
  64.         return ret;
  65.     }
  66.    
  67.     public static final void ovverrideParameters(HttpRequestWrapper wrap, Scope scope) {

  68.         wrap.overrideParameter(ScopeCostanti.PARAMETRO_SCOPE_NOME, scope.getNome());
  69.         wrap.overrideParameter(ScopeCostanti.PARAMETRO_SCOPE_DESCRIZIONE, scope.getDescrizione());
  70.         wrap.overrideParameter(ScopeCostanti.PARAMETRO_SCOPE_NOME_ESTERNO, scope.getIdentificativoEsterno());
  71.        
  72.     }
  73. }