Package com.alu.e3.data.model

Examples of com.alu.e3.data.model.ApiDetail


  public void process(Exchange exchange) throws Exception {
    Api api = this.dataManager.getApiById(apiId, false);
    HttpServletRequest request = (HttpServletRequest) exchange.getIn().getHeader(Exchange.HTTP_SERVLET_REQUEST);
    //retrieve the real IP adress from the request
    String remoteAddr = CommonTools.remoteAddr(request);
    CanonicalizedIpAddress ip = new CanonicalizedIpAddress(remoteAddr);
    if(this.dataManager.isIpAllowed(api, ip.getIp())) {
      exchange.setProperty(ExchangeConstantKeys.E3_API.toString(), api);   
    }
    else {
      Exception exception = new GatewayException(GatewayExceptionCode.AUTHORIZATION, "Not Authorized from this IP address");
      exchange.setException(exception);     
View Full Code Here


    this.apiId = apiId;
  }
 
  @Override
  public void process(Exchange exchange) throws Exception {
    Api api = this.dataManager.getApiById(apiId, false);
    HttpServletRequest request = (HttpServletRequest) exchange.getIn().getHeader(Exchange.HTTP_SERVLET_REQUEST);
    //retrieve the real IP adress from the request
    String remoteAddr = CommonTools.remoteAddr(request);
    CanonicalizedIpAddress ip = new CanonicalizedIpAddress(remoteAddr);
    if(this.dataManager.isIpAllowed(api, ip.getIp())) {
View Full Code Here

   
    if(targetHealthCheck != null)
      context2.getLoadBalancing().setTargetHealthCheck(targetHealthCheck);
   
    Api api = new Api();
    api.setApiDetail(new ApiDetail());
    api.getApiDetail().setEndpoint("/endpoint");
    api.getApiDetail().getContexts().add(context1);
    api.getApiDetail().getContexts().add(context2);
    return api;
  }
View Full Code Here

      api.getProperties().put(prop.getName(), prop.getValue());
    }

    api.setHeaderTransformation             (BeanConverterUtil.<HeaderTransformation, com.alu.e3.prov.restapi.model.HeaderTransformation>toDataModels(provisionData.getHeaderTransformations()));

    ApiDetail apiDetail = new ApiDetail();
    api.setApiDetail            (apiDetail);

    apiDetail.setDisplayName        (provisionData.getDisplayName());
    apiDetail.setEndpoint          (provisionData.getEndpoint());
    apiDetail.setHttps            (toDataModel(provisionData.getHttps()));
    apiDetail.setType            (toDataModel(provisionData.getType()));
    apiDetail.setSubscriptionStep      (toDataModel(provisionData.getSubscriptionStep()));
    apiDetail.setNotificationFormat      (toDataModel(provisionData.getNotificationFormat()));
    apiDetail.setVersion          (provisionData.getVersion());
    if(provisionData.getIpWhiteList() != null) {
      api.getWhiteListedIps().addAll(provisionData.getIpWhiteList().getIp());
    }
    apiDetail.getContexts().addAll      (BeanConverterUtil.<APIContext, com.alu.e3.prov.restapi.model.ApiContext>toDataModels(provisionData.getContexts()));
    apiDetail.setTdrEnabled          (toDataModel(provisionData.getTdrEnabled()));
    if (provisionData.getAuthentication() != null && provisionData.getAuthentication().getAuthKey() != null) {
      apiDetail.setAuthKeyName      (provisionData.getAuthentication().getAuthKey().getKeyName());
      apiDetail.setAuthHeaderName      (provisionData.getAuthentication().getAuthKey().getHeaderName());
    }
    if (provisionData.getAuthentication() != null)
      apiDetail.getEnabledAuthType().addAll  (BeanConverterUtil.<NBAuthType, AuthType>toDataModels(provisionData.getAuthentication().getAuths()));

    apiDetail.setStatus            (toDataModel(provisionData.getStatus()));

    // FIXME: The current WS API model does not support notification (true|false) attributes.
    apiDetail.setNotification      (null);

    apiDetail.setAllowedMethods(provisionData.getAllowedHttpMethodsAsString());

    api.setValidation(toDataModel(provisionData.getValidation()));   
    api.setHeaderTransEnabled(provisionData.getHeaderTransEnabled());
    api.setInternal(provisionData.getInternal());
   
View Full Code Here

        listner.usedBucketIdsRemoved(new Integer(apiIds.getApiBucketId()));
      }
    }

    // Remove endpoint from the used endpoints
    ApiDetail oldDetail = cachingTableApiDetails.get(api.getId());
    usedEndpoints.remove(oldDetail.getEndpoint());

    // add updated contexts
    internalSaveApiDetails(api);

    api.setPolicyIds(oldApi.getPolicyIds());
View Full Code Here

  @Override
  public void removeApi(String id) throws InvalidIDException {
    Api api = cachingTableApi.remove(id);

    ApiDetail detail = cachingTableApiDetails.remove(id);

    if (api == null) {
      throw new InvalidIDException("An API with that ID [" + id + "] doesn't exist");
    }

    // Find the policies associated, and remove this API
    for (String policyId : api.getPolicyIds()) {
      Policy policy = getPolicyById(policyId);
      if (policy != null) {
        policy.getApiIds().remove(api.getId());
        cachingTablePolicy.set(policyId, policy);
      }
    }

    // Remove the contexts
    for (ApiIds apiIds : api.getContextIds()) {
      cachingTableContext.remove(Integer.valueOf(apiIds.getApiContextId()));
      usedBucketIds.remove(new Integer(apiIds.getApiBucketId()));
      for (IDataManagerUsedBucketIdsListener listner : this.usedBucketIdslisteners)
      {
        listner.usedBucketIdsRemoved(new Integer(apiIds.getApiBucketId()));
      }
    }
    // Remove endpoint from the used endpoints
    usedEndpoints.remove(detail.getEndpoint());

    usedBucketIds.remove(api.getApiId());
    for (IDataManagerUsedBucketIdsListener listner : this.usedBucketIdslisteners)
    {
      listner.usedBucketIdsRemoved(new Integer(api.getApiId()));
View Full Code Here

      throw new InvalidIDException("An API with that ID [" + id + "] doesn't exist");
    }

    if (getFullDetails) {

      ApiDetail details = cachingTableApiDetails.get(id);

      if (details != null) {

        api.setApiDetail(details);
        // It's not because List<Context> is transient on ApiDetail
        // that it isn't stored in hazelcast memory locally.
        // For sure, it will not be replicated
        details.getContexts().clear();
        // We can't be sure here to reuse existing List<APIContext>
        // it may be not up to date.

        for (ApiIds ids : api.getContextIds()) {
          details.getContexts().add(cachingTableContext.get(ids.getApiContextId()).getApiContext());
        }
      }
    }
    else
      api.setApiDetail(null);
View Full Code Here

  public void testAddGetRemoveApi() {

    // Add a new API
    Api api = new Api();
    api.setId("id1");
    api.setApiDetail(new ApiDetail());
    api.getApiDetail().setEndpoint("http://www.google.com");
    dataManager.addApi(api);

    // Now, get the "simple" API and check that it's OK
    Api api2 = dataManager.getApiById("id1");
View Full Code Here

  public void testAddTwiceApi() {

    // Add a new API
    Api api = new Api();
    api.setId("id1");
    api.setApiDetail(new ApiDetail());
    api.getApiDetail().setEndpoint("http://www.google.com");
    dataManager.addApi(api);

    boolean exceptionRaised = false;
    try
View Full Code Here

  public void testGetAllApi() {

    // Add a new API
    Api api = new Api();
    api.setId("id10");
    api.setApiDetail(new ApiDetail());
    api.getApiDetail().setEndpoint("http://www.google.com");
    dataManager.addApi(api);

    // Add a new API
    Api api2 = new Api();
    api2.setId("id2");
    api2.setApiDetail(new ApiDetail());
    api2.getApiDetail().setEndpoint("http://www.yahoo.com");
    dataManager.addApi(api2);

    Set<String> apis = dataManager.getAllApiIds();
    assertNotNull("No apis found", apis);
View Full Code Here

TOP

Related Classes of com.alu.e3.data.model.ApiDetail

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.