Package org.entando.entando.aps.system.services.api.model

Examples of org.entando.entando.aps.system.services.api.model.ApiException


        JAXBMessageType jaxbMessageType = null;
        try {
            String typeCode = properties.getProperty("typeCode");
            IApsEntity masterMessageType = this.getMessageManager().getEntityPrototype(typeCode);
            if (null == masterMessageType) {
                throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
            "Message type with code '" + typeCode + "' does not exist", Response.Status.CONFLICT);
            }
            jaxbMessageType = new JAXBMessageType(masterMessageType);
        } catch (ApiException ae) {
            throw ae;
View Full Code Here


        StringApiResponse response = new StringApiResponse();
        try {
            String typeCode = jaxbMessageType.getTypeCode();
            IApsEntity masterMessageType = this.getMessageManager().getEntityPrototype(typeCode);
            if (null != masterMessageType) {
                throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
            "Message type with code '" + typeCode + "' already exists", Response.Status.CONFLICT);
            }
            if (typeCode == null || typeCode.length() != 3) {
                throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
            "Invalid type code - '" + typeCode + "'", Response.Status.CONFLICT);
            }
            Map<String, AttributeInterface> attributes = this.getMessageManager().getEntityAttributePrototypes();
            IApsEntity messageType = jaxbMessageType.buildEntityType(this.getMessageManager().getEntityClass(), attributes);
            ((IEntityTypesConfigurer) this.getMessageManager()).addEntityPrototype(messageType);
View Full Code Here

        StringApiResponse response = new StringApiResponse();
        try {
            String typeCode = jaxbMessageType.getTypeCode();
            IApsEntity masterMessageType = this.getMessageManager().getEntityPrototype(typeCode);
            if (null == masterMessageType) {
                throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
            "Message type with code '" + typeCode + "' doesn't exist", Response.Status.CONFLICT);
            }
            Map<String, AttributeInterface> attributes = this.getMessageManager().getEntityAttributePrototypes();
            IApsEntity messageType = jaxbMessageType.buildEntityType(this.getMessageManager().getEntityClass(), attributes);
            ((IEntityTypesConfigurer) this.getMessageManager()).updateEntityPrototype(messageType);
View Full Code Here

    public void deleteMessageType(Properties properties) throws ApiException, Throwable {
        try {
            String typeCode = properties.getProperty("typeCode");
            IApsEntity masterMessageType = this.getMessageManager().getEntityPrototype(typeCode);
            if (null == masterMessageType) {
                throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
            "Message type with code '" + typeCode + "' doesn't exist", Response.Status.CONFLICT);
            }
            EntitySearchFilter filter = new EntitySearchFilter(IEntityManager.ENTITY_TYPE_CODE_FILTER_KEY, false, typeCode, false);
            List<String> messageIds = this.getMessageManager().searchId(new EntitySearchFilter[]{filter});
            if (null != messageIds && !messageIds.isEmpty()) {
                throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
            "Message type '" + typeCode + "' are used into " + messageIds.size() + " messages", Response.Status.CONFLICT);
            }
            ((IEntityTypesConfigurer) this.getMessageManager()).removeEntityPrototype(typeCode);
        } catch (ApiException ae) {
            throw ae;
View Full Code Here

        List<String> usernames = null;
        try {
            String userMessageType = properties.getProperty("typeCode");
            Message prototype = (Message) this.getMessageManager().getEntityPrototype(userMessageType);
            if (null == prototype) {
                throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR,
            "Message Type '" + userMessageType + "' does not exist", Response.Status.CONFLICT);
            }
            String langCode = properties.getProperty(SystemConstants.API_LANG_CODE_PARAMETER);
            String filtersParam = properties.getProperty("filters");
            BaseFilterUtils filterUtils = new BaseFilterUtils();
View Full Code Here

        JAXBMessage jaxbMessage = null;
        try {
            String id = properties.getProperty("id");
            Message userMessage = this.getMessageManager().getMessage(id);
            if (null == userMessage) {
                throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR,
            "Message '" + id + "' does not exist", Response.Status.CONFLICT);
            }
            jaxbMessage = new JAXBMessage(userMessage, null);
      List<Answer> answers = this.getMessageManager().getAnswers(id);
      if (null != answers && !answers.isEmpty()) {
View Full Code Here

    public StringApiResponse addMessage(JAXBMessage jaxbMessage) throws Throwable {
        StringApiResponse response = new StringApiResponse();
        try {
            String username = jaxbMessage.getId();
            if (null != this.getMessageManager().getMessage(username)) {
                throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR,
            "Message of user '" + username + "' already exist", Response.Status.CONFLICT);
            }
            IApsEntity profilePrototype = this.getMessageManager().getEntityPrototype(jaxbMessage.getTypeCode());
            if (null == profilePrototype) {
                throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR,
            "User Message type with code '" + jaxbMessage.getTypeCode() + "' does not exist", Response.Status.CONFLICT);
            }
            Message message = (Message) jaxbMessage.buildEntity(profilePrototype, null);
            List<ApiError> errors = this.validate(message);
            if (errors.size() > 0) {
View Full Code Here

        StringApiResponse response = new StringApiResponse();
        try {
            String id = properties.getProperty("id");
            Message message = this.getMessageManager().getMessage(id);
            if (null == message) {
                throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR,
            "Message '" + id + "' does not exist", Response.Status.CONFLICT);
            }
      this.getMessageManager().deleteMessage(id);
            response.setResult(IResponseBuilder.SUCCESS, null);
        } catch (ApiException ae) {
View Full Code Here

            String username = tokenizerManager.getUser(entandoApiToken);
            user = authenticationProvider.getUser(username);
            if (null != user) {
                properties.put(SystemConstants.API_USER_PARAMETER, user);
            } else if (apiMethod.getRequiredAuth()) {
        throw new ApiException(IApiErrorCodes.API_AUTHENTICATION_REQUIRED, "Invalid or missing user for token '" + entandoApiToken + "'", Response.Status.UNAUTHORIZED);
      }
        } catch (Exception e) {
            if (apiMethod.getRequiredAuth()) {
                throw new ApiException(IApiErrorCodes.API_AUTHENTICATION_REQUIRED, "Authentication Required", Response.Status.UNAUTHORIZED);
            }
        }
        if (null == user && (apiMethod.getRequiredAuth() || null != apiMethod.getRequiredPermission())) {
            throw new ApiException(IApiErrorCodes.API_AUTHENTICATION_REQUIRED, "Authentication Required", Response.Status.UNAUTHORIZED);
        } else if (null != user && null != apiMethod.getRequiredPermission()
                && !authorizationManager.isAuthOnPermission(user, apiMethod.getRequiredPermission())) {
            throw new ApiException(IApiErrorCodes.API_AUTHORIZATION_REQUIRED, "Authorization Required", Response.Status.UNAUTHORIZED);
        }
  }
View Full Code Here

TOP

Related Classes of org.entando.entando.aps.system.services.api.model.ApiException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.