use of org.wso2.carbon.apimgt.api.model.Provider in project siddhi by wso2.
the class MkdocsGitHubPagesDeployMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
// Finding the root maven project
MavenProject rootMavenProject = mavenProject;
while (rootMavenProject.getParent().getBasedir() != null) {
rootMavenProject = rootMavenProject.getParent();
}
// Setting the relevant modules target directory if not set by user
String moduleTargetPath;
if (moduleTargetDirectory != null) {
moduleTargetPath = moduleTargetDirectory.getAbsolutePath();
} else {
moduleTargetPath = mavenProject.getBuild().getDirectory();
}
// Setting the mkdocs config file path if not set by user
if (mkdocsConfigFile == null) {
mkdocsConfigFile = new File(rootMavenProject.getBasedir() + File.separator + Constants.MKDOCS_CONFIG_FILE_NAME + Constants.YAML_FILE_EXTENSION);
}
// Setting the documentation output directory if not set by user
String docGenBasePath;
if (docGenBaseDirectory != null) {
docGenBasePath = docGenBaseDirectory.getAbsolutePath();
} else {
docGenBasePath = rootMavenProject.getBasedir() + File.separator + Constants.DOCS_DIRECTORY;
}
// Setting the home page file name if not set by user
File homePageFile;
if (homePageFileName == null) {
homePageFile = new File(docGenBasePath + File.separator + Constants.HOMEPAGE_FILE_NAME + Constants.MARKDOWN_FILE_EXTENSION);
} else {
homePageFile = new File(docGenBasePath + File.separator + homePageFileName);
}
// Setting the readme file name if not set by user
if (readmeFile == null) {
readmeFile = new File(rootMavenProject.getBasedir() + File.separator + Constants.README_FILE_NAME + Constants.MARKDOWN_FILE_EXTENSION);
}
// Setting the home page template file path if not set by user
if (homePageTemplateFile == null) {
homePageTemplateFile = new File(rootMavenProject.getBasedir() + File.separator + Constants.README_FILE_NAME + Constants.MARKDOWN_FILE_EXTENSION);
}
// Retrieving metadata
List<NamespaceMetaData> namespaceMetaDataList;
try {
namespaceMetaDataList = DocumentationUtils.getExtensionMetaData(moduleTargetPath, mavenProject.getRuntimeClasspathElements(), getLog());
} catch (DependencyResolutionRequiredException e) {
throw new MojoFailureException("Unable to resolve dependencies of the project", e);
}
// Generating the documentation
if (namespaceMetaDataList.size() > 0) {
DocumentationUtils.generateDocumentation(namespaceMetaDataList, docGenBasePath, mavenProject.getVersion(), getLog());
DocumentationUtils.updateHeadingsInMarkdownFile(homePageTemplateFile, homePageFile, rootMavenProject.getArtifactId(), mavenProject.getVersion(), namespaceMetaDataList);
DocumentationUtils.updateHeadingsInMarkdownFile(readmeFile, readmeFile, rootMavenProject.getArtifactId(), mavenProject.getVersion(), namespaceMetaDataList);
}
// Delete snapshot files
DocumentationUtils.removeSnapshotAPIDocs(mkdocsConfigFile, docGenBasePath, getLog());
// Updating the links in the home page to the mkdocs config
try {
updateAPIPagesInMkdocsConfig(mkdocsConfigFile, docGenBasePath);
} catch (FileNotFoundException e) {
getLog().warn("Unable to find mkdocs configuration file: " + mkdocsConfigFile.getAbsolutePath() + ". Mkdocs configuration file not updated.");
}
// Deploying the documentation
if (DocumentationUtils.generateMkdocsSite(mkdocsConfigFile, getLog())) {
// Creating the credential provider fot Git
String scmUsername = System.getenv(Constants.SYSTEM_PROPERTY_SCM_USERNAME_KEY);
String scmPassword = System.getenv(Constants.SYSTEM_PROPERTY_SCM_PASSWORD_KEY);
if (scmUsername == null && scmPassword == null) {
getLog().info("SCM_USERNAME and SCM_PASSWORD not defined!");
}
String url = null;
Scm scm = rootMavenProject.getScm();
if (scm != null) {
url = scm.getUrl();
}
// Deploying documentation
DocumentationUtils.updateDocumentationOnGitHub(docGenBasePath, mkdocsConfigFile, readmeFile, mavenProject.getVersion(), getLog());
DocumentationUtils.deployMkdocsOnGitHubPages(mavenProject.getVersion(), rootMavenProject.getBasedir(), url, scmUsername, scmPassword, getLog());
} else {
getLog().warn("Unable to generate documentation. Skipping documentation deployment.");
}
}
use of org.wso2.carbon.apimgt.api.model.Provider in project carbon-apimgt by wso2.
the class ApiDAOImpl method constructAPISummaryList.
private List<API> constructAPISummaryList(Connection connection, PreparedStatement statement) throws SQLException {
List<API> apiList = new ArrayList<>();
try (ResultSet rs = statement.executeQuery()) {
while (rs.next()) {
String apiPrimaryKey = rs.getString("UUID");
API apiSummary = new API.APIBuilder(rs.getString("PROVIDER"), rs.getString("NAME"), rs.getString("VERSION")).id(apiPrimaryKey).context(rs.getString("CONTEXT")).description(rs.getString("DESCRIPTION")).lifeCycleStatus(rs.getString("CURRENT_LC_STATUS")).lifecycleInstanceId(rs.getString("LIFECYCLE_INSTANCE_ID")).workflowStatus(rs.getString("LC_WORKFLOW_STATUS")).securityScheme(rs.getInt("SECURITY_SCHEME")).threatProtectionPolicies(getThreatProtectionPolicies(connection, apiPrimaryKey)).build();
apiList.add(apiSummary);
}
}
return apiList;
}
use of org.wso2.carbon.apimgt.api.model.Provider in project carbon-apimgt by wso2.
the class ApiDAOImpl method getCompositeAPIs.
@Override
@SuppressFBWarnings("SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING")
public List<CompositeAPI> getCompositeAPIs(Set<String> roles, String user, int offset, int limit) throws APIMgtDAOException {
// TODO: 6/5/17 Implement pagination support when implementing pagination support for
// other list operations.
final String query = COMPOSITE_API_SUMMARY_SELECT + " WHERE API_TYPE_ID = " + "(SELECT TYPE_ID FROM AM_API_TYPES WHERE TYPE_NAME = ?) AND PROVIDER = ?";
try (Connection connection = DAOUtil.getConnection();
PreparedStatement statement = connection.prepareStatement(query)) {
statement.setString(1, ApiType.COMPOSITE.toString());
statement.setString(2, user);
return getCompositeAPISummaryList(connection, statement);
} catch (SQLException e) {
throw new APIMgtDAOException(DAOUtil.DAO_ERROR_PREFIX + "getting Composite APIs", e);
}
}
use of org.wso2.carbon.apimgt.api.model.Provider in project carbon-apimgt by wso2.
the class ApiDAOImpl method getAPIsByStatus.
@Override
@SuppressFBWarnings("SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING")
public List<API> getAPIsByStatus(List<String> gatewayLabels, String status) throws APIMgtDAOException {
final String query = "SELECT DISTINCT UUID, PROVIDER, A.NAME, CONTEXT, VERSION, DESCRIPTION, CURRENT_LC_STATUS," + " LIFECYCLE_INSTANCE_ID, LC_WORKFLOW_STATUS, SECURITY_SCHEME FROM AM_API A INNER JOIN " + " AM_API_LABEL_MAPPING M ON A.UUID" + " = M.API_ID INNER JOIN AM_LABELS L ON L.LABEL_ID = M.LABEL_ID WHERE L.TYPE_NAME='GATEWAY' " + "AND L.NAME" + " " + "IN" + " " + "(" + DAOUtil.getParameterString(gatewayLabels.size()) + ") AND A" + ".CURRENT_LC_STATUS=?";
try (Connection connection = DAOUtil.getConnection();
PreparedStatement statement = connection.prepareStatement(query)) {
int i = 0;
for (String label : gatewayLabels) {
statement.setString(++i, label);
}
statement.setString(++i, status);
return constructAPISummaryList(connection, statement);
} catch (SQLException e) {
String msg = "getting APIs for given gateway labels: " + gatewayLabels.toString() + " with status: " + status;
throw new APIMgtDAOException(DAOUtil.DAO_ERROR_PREFIX + msg, e);
}
}
use of org.wso2.carbon.apimgt.api.model.Provider in project carbon-apimgt by wso2.
the class ApiDAOImpl method isAPINameExists.
/**
* @see ApiDAO#isAPINameExists(String, String)
*/
@Override
public boolean isAPINameExists(String apiName, String providerName) throws APIMgtDAOException {
final String apiExistsQuery = "SELECT 1 FROM AM_API WHERE LOWER(NAME) = ? AND PROVIDER = ? AND " + "API_TYPE_ID = (SELECT TYPE_ID FROM AM_API_TYPES WHERE TYPE_NAME = ?)";
try (Connection connection = DAOUtil.getConnection();
PreparedStatement statement = connection.prepareStatement(apiExistsQuery)) {
statement.setString(1, apiName.toLowerCase(Locale.ENGLISH));
statement.setString(2, providerName);
statement.setString(3, ApiType.STANDARD.toString());
try (ResultSet rs = statement.executeQuery()) {
if (rs.next()) {
return true;
}
}
} catch (SQLException e) {
throw new APIMgtDAOException(DAOUtil.DAO_ERROR_PREFIX + "checking if API: " + apiName + "exists for provider " + providerName, e);
}
return false;
}
Aggregations