@Override
  /** {@Inheritdoc} */
  public void storeWSDLEndpoint(WSDLEndpoint endpoint) {
    this.init();
    CoreInternalEndpointServiceImpl.LOG.debug(
        "Storing WSDL Endpoint with CSARID: \""
            + endpoint.getCSARId()
            + "\", portType: \""
            + endpoint.getPortType()
            + "\", IAName: \""
            + endpoint.getIaName()
            + "\", NodeTypeImplementation: \""
            + endpoint.getNodeTypeImplementation()
            + "\", URI: \""
            + endpoint.getURI().toString()
            + "\"");

    // TODO this check is a hack because of the problem with deploying of
    // multiple deployment artifacts
    if (!this.existsWSDLEndpoint(endpoint)) {
      this.em.getTransaction().begin();
      CoreInternalEndpointServiceImpl.LOG.debug(
          "The endpoint for \"{}\" is not stored. Thus store it.", endpoint.getPortType());
      this.em.persist(endpoint);
      this.em.getTransaction().commit();
    } else {
      CoreInternalEndpointServiceImpl.LOG.debug(
          "The endpoint for \"{}\" is stored already.", endpoint.getPortType());
    }
  }
  @Override
  public void printPlanEndpoints() {
    this.init();
    this.em.getTransaction().begin();
    List<WSDLEndpoint> endpoints = null;
    Query queryWSDLEndpoint = this.em.createQuery("SELECT e FROM WSDLEndpoint e");

    endpoints = queryWSDLEndpoint.getResultList();
    this.em.getTransaction().commit();

    StringBuilder builder = new StringBuilder();
    String ls = System.getProperty("line.separator");
    builder.append(
        "debug output for stored endpoints of management plans, flags: csarid, planid, ianame, porttype "
            + ls);
    for (WSDLEndpoint endpoint : endpoints) {
      builder.append(
          "endpoint: "
              + endpoint.getCSARId()
              + " "
              + endpoint.getPlanId()
              + " "
              + endpoint.getIaName()
              + " "
              + endpoint.getPortType()
              + ls);
    }
    CoreInternalEndpointServiceImpl.LOG.debug(builder.toString());
  }
 @Override
 /** {@Inheritdoc} */
 public void storeRESTEndpoint(RESTEndpoint endpoint) {
   this.init();
   CoreInternalEndpointServiceImpl.LOG.debug(
       "Storing REST Endpoint with Path : \"{}\", STID: \"{}\"",
       endpoint.getPath(),
       endpoint.getCSARId().getFileName());
   this.em.getTransaction().begin();
   this.em.persist(endpoint);
   this.em.getTransaction().commit();
 }
  @Override
  public WSDLEndpoint getWSDLEndpointForIa(CSARID csarId, QName nodeTypeImpl, String iaName) {
    this.init();
    this.em.getTransaction().begin();
    WSDLEndpoint endpoint = null;
    Query queryWSDLEndpoint =
        this.em.createQuery(
            "SELECT e FROM WSDLEndpoint e where e.csarId= :csarId and e.IaName = :IaName and e.NodeTypeImplementation = :nodeTypeImpl");
    queryWSDLEndpoint.setParameter("csarId", csarId);
    queryWSDLEndpoint.setParameter("IaName", iaName);
    queryWSDLEndpoint.setParameter("nodeTypeImpl", nodeTypeImpl);
    try {
      endpoint = (WSDLEndpoint) queryWSDLEndpoint.getSingleResult();

    } catch (NoResultException e) {
      CoreInternalEndpointServiceImpl.LOG.info("No endpoint stored for requested IA.");
    } finally {
      this.em.getTransaction().commit();
    }
    return endpoint;
  }