Search in sources :

Example 31 with DocumentDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.dto.DocumentDTO in project carbon-apimgt by wso2.

the class DocumentationMappingUtil method fromDocumentationToDTO.

/**
 * Converts a APIM core Document object into corresponding REST API Document DTO object.
 *
 * @param documentation Documentation object
 * @return a new DocumentDTO object corresponding to given Documentation object
 */
public static DocumentDTO fromDocumentationToDTO(Documentation documentation) {
    DocumentDTO documentDTO = new DocumentDTO();
    documentDTO.setDocumentId(documentation.getId());
    documentDTO.setName(documentation.getName());
    documentDTO.setSummary(documentation.getSummary());
    documentDTO.setType(DocumentDTO.TypeEnum.fromValue(documentation.getType().toString()));
    documentDTO.setOtherTypeName(documentation.getOtherTypeName());
    documentDTO.setFileName(documentation.getFilePath());
    if (documentation.getSourceType() != null) {
        documentDTO.setSourceType(DocumentDTO.SourceTypeEnum.fromValue(documentation.getSourceType().toString()));
    }
    documentDTO.setSourceUrl(documentation.getSourceUrl());
    if (documentation.getVisibility() != null) {
        documentDTO.setVisibility(DocumentDTO.VisibilityEnum.fromValue(documentation.getVisibility().toString()));
    }
    return documentDTO;
}
Also used : DocumentDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.DocumentDTO)

Example 32 with DocumentDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.dto.DocumentDTO in project carbon-apimgt by wso2.

the class DocumentationMappingUtil method fromDTOtoDocumentation.

/**
 * Converts a REST API Document DTO object into corresponding APIM core Document object.
 *
 * @param documentDTO DocumentDTO object
 * @return a new Documentation object corresponding to given DocumentDTO object
 */
public static Documentation fromDTOtoDocumentation(DocumentDTO documentDTO) {
    Documentation documentation = new Documentation(DocumentationType.valueOf(documentDTO.getType().toString()), documentDTO.getName());
    documentation.setSummary(documentDTO.getSummary());
    if (documentDTO.getSourceType() != null) {
        documentation.setSourceType(Documentation.DocumentSourceType.valueOf(documentDTO.getSourceType().toString()));
    }
    documentation.setSourceUrl(documentDTO.getSourceUrl());
    documentation.setOtherTypeName(documentDTO.getOtherTypeName());
    documentation.setFilePath(documentDTO.getFileName());
    if (documentDTO.getVisibility() != null) {
        documentation.setVisibility(Documentation.DocumentVisibility.valueOf(documentDTO.getVisibility().toString()));
    }
    return documentation;
}
Also used : Documentation(org.wso2.carbon.apimgt.api.model.Documentation)

Aggregations

DocumentInfo (org.wso2.carbon.apimgt.core.models.DocumentInfo)13 Documentation (org.wso2.carbon.apimgt.api.model.Documentation)12 DocumentDTO (org.wso2.carbon.apimgt.rest.api.publisher.dto.DocumentDTO)12 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)11 APIPublisher (org.wso2.carbon.apimgt.core.api.APIPublisher)11 Response (javax.ws.rs.core.Response)9 Test (org.junit.Test)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)9 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)9 GeneralWorkflowResponse (org.wso2.carbon.apimgt.core.workflow.GeneralWorkflowResponse)9 DocumentDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.DocumentDTO)9 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)5 URI (java.net.URI)4 URISyntaxException (java.net.URISyntaxException)4 APIProductIdentifier (org.wso2.carbon.apimgt.api.model.APIProductIdentifier)4 HashMap (java.util.HashMap)3 APIInfo (org.wso2.carbon.apimgt.api.model.APIInfo)3 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)3 DocumentDTO (org.wso2.carbon.apimgt.rest.api.store.dto.DocumentDTO)3