当前位置: 首页>>代码示例>>Java>>正文


Java PrivilegedCarbonContext.getTenantId方法代码示例

本文整理汇总了Java中org.wso2.carbon.context.PrivilegedCarbonContext.getTenantId方法的典型用法代码示例。如果您正苦于以下问题:Java PrivilegedCarbonContext.getTenantId方法的具体用法?Java PrivilegedCarbonContext.getTenantId怎么用?Java PrivilegedCarbonContext.getTenantId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.wso2.carbon.context.PrivilegedCarbonContext的用法示例。


在下文中一共展示了PrivilegedCarbonContext.getTenantId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getModel

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
@GET
@Path("/{modelName}")
@Produces("application/json")
public Response getModel(@PathParam("modelName") String modelName) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {
        MLModelData model = mlModelHandler.getModel(tenantId, userName, modelName);
        if (model == null) {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
        return Response.ok(model).build();
    } catch (MLModelHandlerException e) {
        String msg = MLUtils.getErrorMsg(String.format(
                "Error occurred while retrieving a model [name] %s of tenant [id] %s and [user] %s .", modelName,
                tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:23,代码来源:ModelApiV10.java

示例2: getSummarizedFeatures

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Get summarized features of an analysis.
 * @param analysisId Unique id of the analysis
 * @param limit Number of features need to retrieve, from the starting index
 * @param offset Starting index
 * @return JSON array of {@link FeatureSummary} objects
 */
@GET
@Path("/{analysisId}/summarizedFeatures")
@Produces("application/json")
@Consumes("application/json")
public Response getSummarizedFeatures(@PathParam("analysisId") long analysisId, @QueryParam("limit") int limit,
        @QueryParam("offset") int offset) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {

        List<FeatureSummary> features = mlAnalysisHandler.getSummarizedFeatures(tenantId, userName, analysisId,
                limit, offset);
        return Response.ok(features).build();
    } catch (MLAnalysisHandlerException e) {
        String msg = MLUtils
                .getErrorMsg(
                        String.format(
                                "Error occurred while retrieving summarized features for the analysis [id] %s of tenant [id] %s and [user] %s .",
                                analysisId, tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:33,代码来源:AnalysisApiV11.java

示例3: deleteModel

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Delete a model
 * @param modelId Unique id of the model
 */
@DELETE
@Path("/{modelId}")
@Produces("application/json")
public Response deleteModel(@PathParam("modelId") long modelId) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {
        mlModelHandler.deleteModel(tenantId, userName, modelId);
        auditLog.info(String.format("User [name] %s of tenant [id] %s deleted a model [id] %s ", userName,
                tenantId, modelId));
        return Response.ok().build();
    } catch (MLModelHandlerException e) {
        String msg = MLUtils.getErrorMsg(String.format(
                "Error occurred while deleting a model [id] %s of tenant [id] %s and [user] %s .", modelId,
                tenantId, userName), e);
        logger.error(msg, e);
        auditLog.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:27,代码来源:ModelApiV10.java

示例4: getHyperParameters

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Get hyper-parameter of an analysis.
 * @param analysisId Unique id of the analysis
 * @param algorithmName Algorithm name
 * @return JSON array of {@link org.wso2.carbon.ml.commons.domain.MLHyperParameter} objects
 */
@GET
@Path("/{analysisId}/hyperParameters")
@Produces("application/json")
@Consumes("application/json")
public Response getHyperParameters(@PathParam("analysisId") long analysisId,
                                   @QueryParam("algorithmName") String algorithmName) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {
        List<MLHyperParameter> hyperParameters = mlAnalysisHandler.getHyperParameters(analysisId, algorithmName);
        return Response.ok(hyperParameters).build();
    } catch (MLAnalysisHandlerException e) {
        String msg = MLUtils
                .getErrorMsg(
                        String.format(
                                "Error occurred while retrieving hyper parameters of algorithm [name] %s for the analysis [id] %s of tenant [id] %s and [user] %s .",
                                algorithmName, analysisId, tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                       .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:30,代码来源:AnalysisApiV10.java

示例5: getNormalization

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Get the normalization option of an analysis.
 * @param analysisId Unique id of the analysis
 * @return Normalization option
 */
@GET
@Path("/{analysisId}/normalization")
@Produces("application/json")
@Consumes("application/json")
public Response getNormalization(@PathParam("analysisId") long analysisId) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {
        String normalLabels = mlAnalysisHandler.getNormalization(analysisId);
        return Response.ok(normalLabels).build();
    } catch (MLAnalysisHandlerException e) {
        String msg = MLUtils
                .getErrorMsg(
                        String.format(
                                "Error occurred while retrieving data normalization selection for the analysis [id] %s of tenant [id] %s and [user] %s .",
                                analysisId, tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:28,代码来源:AnalysisApiV11.java

示例6: getAlgorithmType

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Get the algorithm type of an analysis.
 * @param analysisId Unique id of the analysis
 * @return Algorithm type
 */
@GET
@Path("/{analysisId}/algorithmType")
@Produces("application/json")
@Consumes("application/json")
public Response getAlgorithmType(@PathParam("analysisId") long analysisId) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {
        String responseVariable = mlAnalysisHandler.getAlgorithmType(analysisId);
        return Response.ok(responseVariable).build();
    } catch (MLAnalysisHandlerException e) {
        String msg = MLUtils
                .getErrorMsg(
                        String.format(
                                "Error occurred while retrieving algorithm type for the analysis [id] %s of tenant [id] %s and [user] %s .",
                                analysisId, tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                       .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:28,代码来源:AnalysisApiV10.java

示例7: deleteModel

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Delete a model
 *
 * @param modelId Unique id of the model
 */
@DELETE
@Path("/{modelId}")
@Produces("application/json")
public Response deleteModel(@PathParam("modelId") long modelId) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {
        mlModelHandler.deleteModel(tenantId, userName, modelId);
        auditLog.info(String.format("User [name] %s of tenant [id] %s deleted a model [id] %s ", userName,
                tenantId, modelId));
        return Response.ok().build();
    } catch (MLModelHandlerException e) {
        String msg = MLUtils.getErrorMsg(String.format(
                "Error occurred while deleting a model [id] %s of tenant [id] %s and [user] %s .", modelId,
                tenantId, userName), e);
        logger.error(msg, e);
        auditLog.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:28,代码来源:ModelApiV11.java

示例8: getModelSummary

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Get the model summary
 *
 * @param modelId Unique id of the model
 * @return JSON of {@link ModelSummary} object
 */
@GET
@Path("/{modelId}/summary")
@Produces("application/json")
@Consumes("application/json")
public Response getModelSummary(@PathParam("modelId") long modelId) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {
        ModelSummary modelSummary = mlModelHandler.getModelSummary(modelId);
        return Response.ok(modelSummary).build();
    } catch (MLModelHandlerException e) {
        String msg = MLUtils.getErrorMsg(String.format(
                "Error occurred while retrieving summary of the model [id] %s of tenant [id] %s and [user] %s .",
                modelId, tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:27,代码来源:ModelApiV11.java

示例9: predict

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Make predictions using a model
 * @param modelId Unique id of the model
 * @param data List of string arrays containing the feature values used for predictions
 * @return JSON array of predicted values
 */
@POST
@Path("/{modelId}/predict")
@Produces("application/json")
@Consumes("application/json")
public Response predict(@PathParam("modelId") long modelId, List<String[]> data) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {
        long t1 = System.currentTimeMillis();
        List<?> predictions = mlModelHandler.predict(tenantId, userName, modelId, data);
        logger.info(String.format("Prediction from model [id] %s finished in %s seconds.", modelId,
                (System.currentTimeMillis() - t1) / 1000.0));
        return Response.ok(predictions).build();
    } catch (MLModelHandlerException e) {
        String msg = MLUtils.getErrorMsg(String.format(
                "Error occurred while predicting from model [id] %s of tenant [id] %s and [user] %s.", modelId,
                tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:30,代码来源:ModelApiV10.java

示例10: getNewAnomalyLabel

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Get the new anomaly labels of an analysis.
 * @param analysisId Unique id of the analysis
 * @return New Anomaly Label
 */
@GET
@Path("/{analysisId}/newAnomalyLabel")
@Produces("application/json")
@Consumes("application/json")
public Response getNewAnomalyLabel(@PathParam("analysisId") long analysisId) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {
        String normalLabels = mlAnalysisHandler.getNewAnomalyLabel(analysisId);
        return Response.ok(normalLabels).build();
    } catch (MLAnalysisHandlerException e) {
        String msg = MLUtils
                .getErrorMsg(
                        String.format(
                                "Error occurred while retrieving new anomaly label for the analysis [id] %s of tenant [id] %s and [user] %s .",
                                analysisId, tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:28,代码来源:AnalysisApiV11.java

示例11: getResponseVariable

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Get the response variable of an analysis.
 * @param analysisId Unique id of the analysis
 * @return Response variable name
 */
@GET
@Path("/{analysisId}/responseVariables")
@Produces("application/json")
@Consumes("application/json")
public Response getResponseVariable(@PathParam("analysisId") long analysisId) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {
        String responseVariable = mlAnalysisHandler.getResponseVariable(analysisId);
        return Response.ok(responseVariable).build();
    } catch (MLAnalysisHandlerException e) {
        String msg = MLUtils
                .getErrorMsg(
                        String.format(
                                "Error occurred while retrieving response variable for the analysis [id] %s of tenant [id] %s and [user] %s .",
                                analysisId, tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                       .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:28,代码来源:AnalysisApiV10.java

示例12: getfilteredFeatures

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Get filtered feature names of an analysis.
 * @param analysisId Unique id of the analysis
 * @param featureType Feature type need to retrieve (Categorical or Numerical)
 * @return JSON array of feature names
 */
@GET
@Path("/{analysisId}/filteredFeatures")
@Produces("application/json")
public Response getfilteredFeatures(@PathParam("analysisId") String analysisId,
                                    @QueryParam("featureType") String featureType) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {

        List<String> features = mlAnalysisHandler.getFeatureNames(analysisId, featureType);
        return Response.ok(features).build();
    } catch (MLAnalysisHandlerException e) {
        String msg = MLUtils
                .getErrorMsg(
                        String.format(
                                "Error occurred while retrieving filtered feature names for the analysis [id] %s of tenant [id] %s and [user] %s .",
                                analysisId, tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                       .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:30,代码来源:AnalysisApiV10.java

示例13: getAlgorithmName

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Get the algorithm name of an analysis.
 * @param analysisId Unique id of the analysis
 * @return Algorithm name
 */
@GET
@Path("/{analysisId}/algorithmName")
@Produces("application/json")
@Consumes("application/json")
public Response getAlgorithmName(@PathParam("analysisId") long analysisId) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {
        String algorithmName = mlAnalysisHandler.getAlgorithmName(analysisId);
        return Response.ok(algorithmName).build();
    } catch (MLAnalysisHandlerException e) {
        String msg = MLUtils
                .getErrorMsg(
                        String.format(
                                "Error occurred while retrieving algorithm name for the analysis [id] %s of tenant [id] %s and [user] %s .",
                                analysisId, tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:28,代码来源:AnalysisApiV11.java

示例14: getNewNormalLabel

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Get the new normal label of an analysis.
 * @param analysisId Unique id of the analysis
 * @return New Normal Label
 */
@GET
@Path("/{analysisId}/newNormalLabel")
@Produces("application/json")
@Consumes("application/json")
public Response getNewNormalLabel(@PathParam("analysisId") long analysisId) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {
        String normalLabels = mlAnalysisHandler.getNewNormalLabel(analysisId);
        return Response.ok(normalLabels).build();
    } catch (MLAnalysisHandlerException e) {
        String msg = MLUtils
                .getErrorMsg(
                        String.format(
                                "Error occurred while retrieving data new normal label for the analysis [id] %s of tenant [id] %s and [user] %s .",
                                analysisId, tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:28,代码来源:AnalysisApiV11.java

示例15: getfilteredFeatures

import org.wso2.carbon.context.PrivilegedCarbonContext; //导入方法依赖的package包/类
/**
 * Get filtered feature names of an analysis.
 * @param analysisId Unique id of the analysis
 * @param featureType Feature type need to retrieve (Categorical or Numerical)
 * @return JSON array of feature names
 */
@GET
@Path("/{analysisId}/filteredFeatures")
@Produces("application/json")
public Response getfilteredFeatures(@PathParam("analysisId") String analysisId,
        @QueryParam("featureType") String featureType) {
    PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    int tenantId = carbonContext.getTenantId();
    String userName = carbonContext.getUsername();
    try {

        List<String> features = mlAnalysisHandler.getFeatureNames(analysisId, featureType);
        return Response.ok(features).build();
    } catch (MLAnalysisHandlerException e) {
        String msg = MLUtils
                .getErrorMsg(
                        String.format(
                                "Error occurred while retrieving filtered feature names for the analysis [id] %s of tenant [id] %s and [user] %s .",
                                analysisId, tenantId, userName), e);
        logger.error(msg, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(new MLErrorBean(e.getMessage()))
                .build();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-ml,代码行数:30,代码来源:AnalysisApiV11.java


注:本文中的org.wso2.carbon.context.PrivilegedCarbonContext.getTenantId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。