コード例 #1
0
 protected ServiceInfo createServiceInfo(
     ApiService service, String langCode, String defaultLangCode) {
   String description = service.getDescription().getProperty(langCode);
   if (null == description || description.trim().length() == 0) {
     description = service.getDescription().getProperty(defaultLangCode);
   }
   ServiceInfo smallService =
       new ServiceInfo(service.getKey(), description, service.getTag(), service.isMyEntando());
   String[] freeParameters = service.getFreeParameters();
   if (null != freeParameters && freeParameters.length > 0) {
     for (int i = 0; i < freeParameters.length; i++) {
       String freeParameter = freeParameters[i];
       ApiMethodParameter apiParameter = service.getMaster().getParameter(freeParameter);
       if (null != apiParameter) {
         ServiceParameterInfo spi = new ServiceParameterInfo(apiParameter);
         ApsProperties serviceParameters = service.getParameters();
         String defaultValue =
             (null != serviceParameters) ? serviceParameters.getProperty(freeParameter) : null;
         if (null != defaultValue) {
           spi.setDefaultValue(defaultValue);
           spi.setRequired(false);
         }
         smallService.addParameter(spi);
       }
     }
   }
   return smallService;
 }
コード例 #2
0
 public Map<String, ApiService> getServices(String tag, Boolean myentando)
     throws ApsSystemException {
   Map<String, ApiService> services = this.getServices();
   if ((null == tag || tag.trim().length() == 0) && null == myentando) {
     return services;
   }
   Map<String, ApiService> servicesToReturn = new HashMap<String, ApiService>();
   try {
     Iterator<ApiService> iter = services.values().iterator();
     while (iter.hasNext()) {
       ApiService apiService = iter.next();
       String serviceTag = apiService.getTag();
       boolean tagCheck =
           (null == tag
               || (null != serviceTag
                   && serviceTag.toLowerCase().indexOf(tag.trim().toLowerCase()) > -1));
       boolean myentandoCheck =
           (null == myentando || (myentando.booleanValue() == apiService.isMyEntando()));
       if (tagCheck && myentandoCheck) {
         servicesToReturn.put(apiService.getKey(), apiService);
       }
     }
   } catch (Throwable t) {
     ApsSystemUtils.logThrowable(t, this, "getServices", "Error extracting services");
     throw new ApsSystemException("Error extracting services", t);
   }
   return servicesToReturn;
 }
コード例 #3
0
 @Override
 public String edit() {
   try {
     String check = this.checkService(this.getServiceKey());
     if (null != check) return check;
     ApiService apiService = this.getApiCatalogManager().getApiService(this.getServiceKey());
     this.setApiParameters(apiService.getMaster().getParameters());
     this.setApiMethodName(apiService.getMaster().getMethodName());
     this.setApiParameterValues(apiService.getParameters());
     this.setDescriptions(apiService.getDescription());
     this.setPublicService(apiService.isPublicService());
     this.setActiveService(apiService.isActive());
     this.setMyEntandoService(apiService.isMyEntando());
     this.setServiceKey(apiService.getKey());
     if (null != apiService.getFreeParameters()) {
       List<String> freeParams = Arrays.asList(apiService.getFreeParameters());
       this.setFreeParameters(freeParams);
     }
     this.setTag(apiService.getTag());
     this.setStrutsAction(ApsAdminSystemConstants.EDIT);
   } catch (Throwable t) {
     ApsSystemUtils.logThrowable(t, this, "edit");
     return FAILURE;
   }
   return SUCCESS;
 }
コード例 #4
0
 public void updateService(ApiService service) {
   Connection conn = null;
   PreparedStatement stat = null;
   try {
     conn = this.getConnection();
     conn.setAutoCommit(false);
     stat = conn.prepareStatement(UPDATE_SERVICE);
     // SET resource = ? , description = ? , parameters = ? , tag = ? , freeparameters = ? ,
     // isactive = ? , ispublic = ? WHERE servicekey = ? ";
     stat.setString(1, service.getMaster().getResourceName());
     stat.setString(2, service.getDescription().toXml());
     stat.setString(3, service.getParameters().toXml());
     stat.setString(4, service.getTag());
     if (null == service.getFreeParameters() || service.getFreeParameters().length == 0) {
       stat.setNull(5, Types.VARCHAR);
     } else {
       ServiceExtraConfigDOM dom = new ServiceExtraConfigDOM();
       stat.setString(5, dom.extractXml(service.getFreeParameters()));
     }
     int isActive = (service.isActive()) ? 1 : 0;
     stat.setInt(6, isActive);
     int isPublic = (service.isPublicService()) ? 1 : 0;
     stat.setInt(7, isPublic);
     int isMyEntando = (service.isMyEntando()) ? 1 : 0;
     stat.setInt(8, isMyEntando);
     stat.setString(9, service.getKey());
     stat.executeUpdate();
     conn.commit();
   } catch (Throwable t) {
     this.executeRollback(conn);
     processDaoException(t, "Error while updating a service", "updateService");
   } finally {
     closeDaoResources(null, stat, conn);
   }
 }