use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-apimgt by wso2.
the class DocumentationMappingUtil method fromDocumentationListToDTO.
/**
* Converts a List object of ArtifactResourceMetaData into a DTO
*
* @param documentInfoList List of ArtifactResourceMetaData
* @param limit maximum number of APIs returns
* @param offset starting index
* @return DocumentListDTO object containing Document DTOs
*/
public static DocumentListDTO fromDocumentationListToDTO(List<DocumentInfo> documentInfoList, int offset, int limit) {
DocumentListDTO documentListDTO = new DocumentListDTO();
List<DocumentDTO> documentDTOs = documentListDTO.getList();
if (documentDTOs == null) {
documentDTOs = new ArrayList<>();
documentListDTO.setList(documentDTOs);
}
// add the required range of objects to be returned
int start = offset < documentInfoList.size() && offset >= 0 ? offset : Integer.MAX_VALUE;
int end = offset + limit - 1 <= documentInfoList.size() - 1 ? offset + limit - 1 : documentInfoList.size() - 1;
for (int i = start; i <= end; i++) {
documentDTOs.add(fromDocumentationToDTO(documentInfoList.get(i)));
}
documentListDTO.setCount(documentDTOs.size());
return documentListDTO;
}
use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-apimgt by wso2.
the class ApiApiServiceImpl method apiSubscriberCountByApiGet.
/**
* Get list of subscriptions for an API
*
* @param startTime Filter for start time stamp
* @param endTime Filter for end time stamp
* @param apiId Filter for apiId
* @param request MSF4J request
* @return API subscriptions count
* @throws NotFoundException When the particular resource does not exist in the system
*/
@Override
public Response apiSubscriberCountByApiGet(String startTime, String endTime, String apiId, Request request) throws NotFoundException {
String username = RestApiUtil.getLoggedInUsername(request);
try {
log.debug("Retrieving APIs created over time. [From: {} To: {} API Id: {}]");
Analyzer analyzer = RestApiUtil.getAnalyzer(username);
List<APISubscriptionCount> apiSubscriptionCountList = analyzer.getAPISubscriptionCount(fromISO8601ToInstant(startTime), fromISO8601ToInstant(endTime), apiId);
APISubscriptionCountListDTO apiSubscriptionListDTO = AnalyticsMappingUtil.fromAPISubscriptionCountListToDTO(apiSubscriptionCountList);
return Response.ok().entity(apiSubscriptionListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving API subscription info";
ErrorDTO errorDTO = RestApiUtil.getErrorDTO(e.getErrorHandler());
log.error(errorMessage, e);
return Response.status(e.getErrorHandler().getHttpStatusCode()).entity(errorDTO).build();
}
}
use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-apimgt by wso2.
the class ApiApiServiceImpl method apiListGet.
/**
* Get list of API Info
*
* @param startTime Filter for start time stamp
* @param endTime Filter for end time stamp
* @param createdBy Filter for created user
* @param request MSF4J request
* @return API List
* @throws NotFoundException When the particular resource does not exist in the system
*/
@Override
public Response apiListGet(String startTime, String endTime, String createdBy, Request request) throws NotFoundException {
String username = RestApiUtil.getLoggedInUsername(request);
try {
log.debug("Retrieving API information. [From: {} To: {} Created By:{} ]", startTime, endTime, createdBy);
Analyzer analyzer = RestApiUtil.getAnalyzer(username);
ZoneId requestTimezone = RestApiUtil.getRequestTimeZone(startTime);
List<APIInfo> apiInfoList = analyzer.getAPIInfo(fromISO8601ToInstant(startTime), fromISO8601ToInstant(endTime), createdBy);
APIInfoListDTO apiInfoListDTO = AnalyticsMappingUtil.fromAPIInfoListToDTO(apiInfoList, requestTimezone);
return Response.ok().entity(apiInfoListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving API information";
ErrorDTO errorDTO = RestApiUtil.getErrorDTO(e.getErrorHandler());
log.error(errorMessage, e);
return Response.status(e.getErrorHandler().getHttpStatusCode()).entity(errorDTO).build();
}
}
use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-apimgt by wso2.
the class ApplicationApiServiceImpl method applicationCountOverTimeGet.
/**
* Get list of Application count information
*
* @param startTime Filter for start time stamp
* @param endTime Filter for end time stamp
* @param createdBy Filter for application creator
* @param request MSF4J request
* @return Application count over time
* @throws NotFoundException When the particular resource does not exist in the system
*/
@Override
public Response applicationCountOverTimeGet(String startTime, String endTime, String createdBy, Request request) throws NotFoundException {
String username = RestApiUtil.getLoggedInUsername(request);
try {
log.debug("Retrieving applications created over time. [From: {} to: {} Created By: {}]", startTime, endTime, createdBy);
Analyzer analyzer = RestApiUtil.getAnalyzer(username);
ZoneId requestTimezone = RestApiUtil.getRequestTimeZone(startTime);
List<ApplicationCount> applicationCountList = analyzer.getApplicationCount(fromISO8601ToInstant(startTime), fromISO8601ToInstant(endTime), createdBy);
ApplicationCountListDTO applicationCountListDTO = AnalyticsMappingUtil.fromApplicationCountToListDTO(applicationCountList, requestTimezone);
return Response.ok().entity(applicationCountListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving application created over time info";
ErrorDTO errorDTO = RestApiUtil.getErrorDTO(e.getErrorHandler());
log.error(errorMessage, e);
return Response.status(e.getErrorHandler().getHttpStatusCode()).entity(errorDTO).build();
}
}
use of org.wso2.carbon.humantask.core.engine.commands.Start in project carbon-apimgt by wso2.
the class SubscriptionApiServiceImpl method subscriptionCountOverTimeGet.
/**
* Get list of subscriptions created over time
*
* @param startTime Filter for start time stamp
* @param endTime Filter for end time stamp
* @param createdBy Filter for createdBy
* @param request MSF4J request
* @return Subscriptions count over time
* @throws NotFoundException When the particular resource does not exist in the system
*/
@Override
public Response subscriptionCountOverTimeGet(String startTime, String endTime, String createdBy, Request request) throws NotFoundException {
String username = RestApiUtil.getLoggedInUsername(request);
try {
log.debug("Retrieving subscriptions created over time. [From: {} To: {} Created By: {}]", startTime, endTime, createdBy);
Analyzer analyzer = RestApiUtil.getAnalyzer(username);
ZoneId requestTimezone = RestApiUtil.getRequestTimeZone(startTime);
List<SubscriptionCount> subscriptionCount = analyzer.getSubscriptionCount(fromISO8601ToInstant(startTime), fromISO8601ToInstant(endTime), createdBy);
SubscriptionCountListDTO subscriptionListDTO = AnalyticsMappingUtil.fromSubscriptionCountListToDTO(subscriptionCount, requestTimezone);
return Response.ok().entity(subscriptionListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving Subscription Count";
ErrorDTO errorDTO = RestApiUtil.getErrorDTO(e.getErrorHandler());
log.error(errorMessage, e);
return Response.status(e.getErrorHandler().getHttpStatusCode()).entity(errorDTO).build();
}
}
Aggregations