use of org.wso2.carbon.apimgt.api.doc.model.Parameter in project carbon-business-process by wso2.
the class UserSubstitutionService method getSubstitute.
/**
* Return the substitute info for the given user in path parameter
* @param user
* @return SubstituteInfoResponse
* @throws URISyntaxException
*/
@GET
@Path("/{user}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getSubstitute(@PathParam("user") String user) throws UserStoreException {
if (!subsFeatureEnabled) {
return Response.status(405).build();
}
user = getTenantAwareUser(user);
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
String loggedInUser = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
if (!loggedInUser.equals(user) && !isUserAuthorizedForSubstitute(loggedInUser)) {
throw new BPMNForbiddenException("Not allowed to view others substitution details. No sufficient permission");
}
SubstitutesDataModel model = UserSubstitutionUtils.getSubstituteOfUser(user, tenantId);
if (model != null) {
SubstituteInfoResponse response = new SubstituteInfoResponse();
response.setSubstitute(model.getSubstitute());
response.setAssignee(model.getUser());
response.setEnabled(model.isEnabled());
response.setStartTime(model.getSubstitutionStart());
response.setEndTime(model.getSubstitutionEnd());
return Response.ok(response).build();
} else {
return Response.status(404).build();
}
}
use of org.wso2.carbon.apimgt.api.doc.model.Parameter in project carbon-business-process by wso2.
the class UserSubstitutionUtils method getPaginatedModelFromRequest.
/**
* Prepare the paginated data model for a substitution query
* @param propertiesMap
* @param tenantId
* @return PaginatedSubstitutesDataModel
*/
private static PaginatedSubstitutesDataModel getPaginatedModelFromRequest(Map<String, String> propertiesMap, int tenantId) {
PaginatedSubstitutesDataModel model = new PaginatedSubstitutesDataModel();
if (propertiesMap.get(SubstitutionQueryProperties.SUBSTITUTE) != null) {
model.setSubstitute(propertiesMap.get(SubstitutionQueryProperties.SUBSTITUTE));
}
if (propertiesMap.get(SubstitutionQueryProperties.USER) != null) {
model.setUser(propertiesMap.get(SubstitutionQueryProperties.USER));
}
String enabled = propertiesMap.get(SubstitutionQueryProperties.ENABLED);
if (enabled != null) {
if (enabled.equalsIgnoreCase("true")) {
model.setEnabled(true);
} else if (enabled.equalsIgnoreCase("false")) {
model.setEnabled(false);
} else {
throw new ActivitiIllegalArgumentException("Invalid parameter " + enabled + " for enabled property.");
}
}
model.setTenantId(tenantId);
int start = Integer.parseInt(propertiesMap.get(SubstitutionQueryProperties.START));
int size = Integer.parseInt(propertiesMap.get(SubstitutionQueryProperties.SIZE));
model.setStart(start);
model.setSize(size);
model.setOrder(propertiesMap.get(SubstitutionQueryProperties.ORDER));
model.setSort(propertiesMap.get(SubstitutionQueryProperties.SORT));
return model;
}
use of org.wso2.carbon.apimgt.api.doc.model.Parameter in project carbon-business-process by wso2.
the class ActivitiDAO method querySubstituteInfoWithoutEnabled.
/**
* Return the list of substitute info based on query parameters except enabled property.
* @param model data model with only required query parameter values. Leave others as null.
* @return List<PaginatedSubstitutesDataModel> Result set of substitute info
*/
public List<SubstitutesDataModel> querySubstituteInfoWithoutEnabled(final PaginatedSubstitutesDataModel model) {
final RowBounds rw = new RowBounds(model.getStart(), model.getSize());
CustomSqlExecution<SubstitutesMapper, List<SubstitutesDataModel>> customSqlExecution = new AbstractCustomSqlExecution<SubstitutesMapper, List<SubstitutesDataModel>>(SubstitutesMapper.class) {
public List<SubstitutesDataModel> execute(SubstitutesMapper substitutesMapper) {
return substitutesMapper.querySubstitutesWithoutEnabled(rw, model);
}
};
return managementService.executeCustomSql(customSqlExecution);
}
use of org.wso2.carbon.apimgt.api.doc.model.Parameter in project carbon-business-process by wso2.
the class HumanTaskServer method initTransactionManager.
// initialize the external transaction manager.
private void initTransactionManager() throws HumanTaskServerException {
String transactionFactoryName = serverConfig.getTransactionFactoryClass();
if (log.isDebugEnabled()) {
log.debug("Initializing transaction manager using " + transactionFactoryName);
}
try {
Class txFactoryClass = this.getClass().getClassLoader().loadClass(transactionFactoryName);
Object txFactory = txFactoryClass.newInstance();
tnxManager = (TransactionManager) txFactoryClass.getMethod("getTransactionManager", (Class[]) null).invoke(txFactory);
// Didn't use Debug Transaction manager which used in ODE.
// TODO: Look for the place we use this axis parameter.
// axisConfiguration.addParameter("ode.transaction.manager", transactionManager);
} catch (Exception e) {
log.fatal("Couldn't initialize a transaction manager with factory: " + transactionFactoryName, e);
throw new HumanTaskServerException("Couldn't initialize a transaction manager with factory: " + transactionFactoryName, e);
}
}
use of org.wso2.carbon.apimgt.api.doc.model.Parameter in project carbon-apimgt by wso2.
the class GraphQLResponseProcessor method handleResponse.
/**
* Handle inbound websocket responses of GraphQL subscriptions and perform authentication, authorization
* and throttling. This identifies operation from the subscription responses using the unique message id parameter.
*
* @param msgSize Message size of graphQL subscription response payload
* @param msgText The GraphQL subscription response payload text
* @param inboundMessageContext InboundMessageContext
* @return InboundProcessorResponseDTO
*/
@Override
public InboundProcessorResponseDTO handleResponse(int msgSize, String msgText, InboundMessageContext inboundMessageContext) {
InboundProcessorResponseDTO responseDTO = InboundWebsocketProcessorUtil.authenticateToken(inboundMessageContext);
JSONObject graphQLMsg = new JSONObject(msgText);
if (!responseDTO.isError() && checkIfSubscribeMessageResponse(graphQLMsg)) {
if (graphQLMsg.has(GraphQLConstants.SubscriptionConstants.PAYLOAD_FIELD_NAME_ID) && graphQLMsg.getString(GraphQLConstants.SubscriptionConstants.PAYLOAD_FIELD_NAME_ID) != null) {
String operationId = graphQLMsg.getString(GraphQLConstants.SubscriptionConstants.PAYLOAD_FIELD_NAME_ID);
GraphQLOperationDTO graphQLOperationDTO = inboundMessageContext.getVerbInfoForGraphQLMsgId(graphQLMsg.getString(GraphQLConstants.SubscriptionConstants.PAYLOAD_FIELD_NAME_ID));
// validate scopes based on subscription payload when security is enabled
String authType = graphQLOperationDTO.getVerbInfoDTO().getAuthType();
if (!StringUtils.capitalize(APIConstants.AUTH_TYPE_NONE.toLowerCase()).equals(authType)) {
responseDTO = InboundWebsocketProcessorUtil.validateScopes(inboundMessageContext, graphQLOperationDTO.getOperation(), operationId);
}
if (!responseDTO.isError()) {
// throttle for matching resource
return InboundWebsocketProcessorUtil.doThrottleForGraphQL(msgSize, graphQLOperationDTO.getVerbInfoDTO(), inboundMessageContext, operationId);
}
} else {
responseDTO = InboundWebsocketProcessorUtil.getBadRequestFrameErrorDTO("Missing mandatory id field in the message");
}
}
return responseDTO;
}
Aggregations