bda-controller/src/main/java/gr/ntua/ece/cslab/selis/bda/controller/resources/MessageResource.java
@POST
    @Path("{slug}")
    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response insert(@PathParam("slug") String slug,
                           MessageType m) {
        String details;
        try {
            if (m.getExternalConnectorId()!=null){
                Connector conn = Connector.getConnectorInfoById(m.getExternalConnectorId());
                if (!conn.isExternal())
                    return Response.serverError().entity(
                            new RequestResponse("ERROR", "Could not insert new Message Type. Connector is not external.")
                    ).build();
                if (!conn.getMetadata().getDatasources().contains(m.getExternalDatasource())){
                    return Response.serverError().entity(
                            new RequestResponse("ERROR", "Could not insert new Message Type. Invalid datasource specified for connector.")
                    ).build();
                }
            }
            m.save(slug);
            details = Integer.toString(m.getId());
        } catch (Exception e) {
            e.printStackTrace();

            return Response.serverError().entity(
                    new RequestResponse("ERROR", "Could not insert new Message Type.")
            ).build();
        }

        boolean externalConnector = !(m.getExternalConnectorId() == null);
        PubSubConnector.getInstance().reloadSubscriptions(slug, externalConnector);

        return Response.ok(
                new RequestResponse("OK", details)
        ).build();
    }
/**
     * Message description insert method
     * @param m the message description to insert
     */
Message description insert method
@param m the message description to insert
Message description insert method @param m the message description to insert
@POST
    @Path("{slug}")
    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response insert(@PathParam("slug") String slug,
                           MessageType m) {
        String details;
        try {
            if (m.getExternalConnectorId()!=null){
                Connector conn = Connector.getConnectorInfoById(m.getExternalConnectorId());
                if (!conn.isExternal())
                    return Response.serverError().entity(
                            new RequestResponse("ERROR", "Could not insert new Message Type. Connector is not external.")
                    ).build();
                if (!conn.getMetadata().getDatasources().contains(m.getExternalDatasource())){
                    return Response.serverError().entity(
                            new RequestResponse("ERROR", "Could not insert new Message Type. Invalid datasource specified for connector.")
                    ).build();
                }
            }
            m.save(slug);
            details = Integer.toString(m.getId());
        } catch (Exception e) {
            e.printStackTrace();
            return Response.serverError().entity(
                    new RequestResponse("ERROR", "Could not insert new Message Type.")
            ).build();
        }
        boolean externalConnector = !(m.getExternalConnectorId() == null);
        PubSubConnector.getInstance().reloadSubscriptions(slug, externalConnector);
        return Response.ok(
                new RequestResponse("OK", details)
        ).build();
    }
@ POST @ Path ( "{slug}" ) @ Consumes ( { MediaType . APPLICATION_JSON , MediaType . APPLICATION_XML } ) @ Produces ( { MediaType . APPLICATION_JSON , MediaType . APPLICATION_XML } ) public Response insert ( @ PathParam ( "slug" ) String slug , MessageType m ) { String details ; try { if ( m . getExternalConnectorId ( ) != null ) { Connector conn = Connector . getConnectorInfoById ( m . getExternalConnectorId ( ) ) ; if ( ! conn . isExternal ( ) ) return Response . serverError ( ) . entity ( new RequestResponse ( "ERROR" , "Could not insert new Message Type. Connector is not external." ) ) . build ( ) ; if ( ! conn . getMetadata ( ) . getDatasources ( ) . contains ( m . getExternalDatasource ( ) ) ) { return Response . serverError ( ) . entity ( new RequestResponse ( "ERROR" , "Could not insert new Message Type. Invalid datasource specified for connector." ) ) . build ( ) ; } } m . save ( slug ) ; details = Integer . toString ( m . getId ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return Response . serverError ( ) . entity ( new RequestResponse ( "ERROR" , "Could not insert new Message Type." ) ) . build ( ) ; } boolean externalConnector = ! ( m . getExternalConnectorId ( ) == null ) ; PubSubConnector . getInstance ( ) . reloadSubscriptions ( slug , externalConnector ) ; return Response . ok ( new RequestResponse ( "OK" , details ) ) . build ( ) ; }
Message description insert method
 @param m the message description to insert
Message description insert method @param m the message description to insert