Search in sources :

Example 11 with ApplicationList

use of org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationList in project carbon-apimgt by wso2.

the class GatewayUtils method generateApplicationList.

public static ApplicationListDTO generateApplicationList(List<Application> applicationList, SubscriptionDataStore subscriptionDataStore) {
    ApplicationListDTO applicationListDTO = new ApplicationListDTO();
    List<ApplicationInfoDTO> applicationInfoDTOList = new ArrayList<>();
    for (Application application : applicationList) {
        ApplicationInfoDTO applicationInfoDTO = new ApplicationInfoDTO().id(application.getId()).name(application.getName()).policy(application.getPolicy()).attributes(application.getAttributes()).subName(application.getSubName()).uuid(application.getUUID()).tokenType(application.getTokenType()).keys(convertToApplicationKeyMapping(application.getId(), subscriptionDataStore));
        applicationInfoDTOList.add(applicationInfoDTO);
    }
    applicationListDTO.setList(applicationInfoDTOList);
    applicationListDTO.setCount(applicationInfoDTOList.size());
    return applicationListDTO;
}
Also used : ArrayList(java.util.ArrayList) ApplicationInfoDTO(org.wso2.carbon.apimgt.rest.api.gateway.dto.ApplicationInfoDTO) Application(org.wso2.carbon.apimgt.keymgt.model.entity.Application) ApplicationListDTO(org.wso2.carbon.apimgt.rest.api.gateway.dto.ApplicationListDTO)

Example 12 with ApplicationList

use of org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationList in project carbon-apimgt by wso2.

the class SubscriptionDataLoaderImpl method getApplicationById.

@Override
public Application getApplicationById(int appId) throws DataLoadingException {
    String endPoint = APIConstants.SubscriptionValidationResources.APPLICATIONS + "?appId=" + appId;
    Application application = null;
    String responseString;
    try {
        responseString = invokeService(endPoint, null);
    } catch (IOException e) {
        String msg = "Error while executing the http client " + endPoint;
        log.error(msg, e);
        throw new DataLoadingException(msg, e);
    }
    if (responseString != null && !responseString.isEmpty()) {
        ApplicationList list = new Gson().fromJson(responseString, ApplicationList.class);
        if (list.getList() != null && !list.getList().isEmpty()) {
            application = list.getList().get(0);
        }
    }
    return application;
}
Also used : DataLoadingException(org.wso2.carbon.apimgt.keymgt.model.exception.DataLoadingException) ApplicationList(org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationList) Gson(com.google.gson.Gson) IOException(java.io.IOException) Application(org.wso2.carbon.apimgt.keymgt.model.entity.Application)

Aggregations

ArrayList (java.util.ArrayList)10 Application (org.wso2.carbon.apimgt.core.models.Application)8 Test (org.junit.Test)4 Response (javax.ws.rs.core.Response)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Application (org.wso2.carbon.apimgt.keymgt.model.entity.Application)3 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)2 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)2 ApplicationCreationResponse (org.wso2.carbon.apimgt.core.workflow.ApplicationCreationResponse)2 GeneralWorkflowResponse (org.wso2.carbon.apimgt.core.workflow.GeneralWorkflowResponse)2 ApplicationDTO (org.wso2.carbon.apimgt.rest.api.core.dto.ApplicationDTO)2 ApplicationListDTO (org.wso2.carbon.apimgt.rest.api.core.dto.ApplicationListDTO)2 ApplicationListDTO (org.wso2.carbon.apimgt.rest.api.gateway.dto.ApplicationListDTO)2 Request (org.wso2.msf4j.Request)2 Gson (com.google.gson.Gson)1 IOException (java.io.IOException)1