public ACLMessage handleCfpWithFeedback(ACLMessage newCFP) {
      // receives the content object (a counter proposal)
      ProposalEvaluation feedback = null;
      // extract proposal from the aclmessage
      try {
        ContentElement ce = myAgent.getContentManager().extractContent(newCFP);
        if (ce instanceof ProposalEvaluation) {
          feedback = (ProposalEvaluation) ce;
        }
      } catch (Codec.CodecException cex) {
        cex.printStackTrace();
      } catch (OntologyException oe) {
        oe.printStackTrace();
      }

      if (itemMapping != null) { // using a mapped item - translate proposal into own ontology
        feedback = ((EnterpriseAgent) myAgent).translateToOwnItemOntology(feedback, itemMapping);
      }
      // prepares response
      ACLMessage response = newCFP.createReply();

      Proposal newProposal;
      if (!((EnterpriseAgent) myAgent).isUseQNegotiationStrategy()) {
        newProposal = createCounterProposal(feedback, need, competence);
      } else {
        newProposal =
            qNegotiationStrategies
                .get(competence.getType())
                .createCounterProposal(getNegotiationId(), feedback, need, competence);
      }

      if (newProposal != null) {
        if (itemMapping
            != null) { // using a mapped item - translate proposal back to the foreign ontology
          newProposal =
              ((EnterpriseAgent) myAgent).translateToForeignItemOntology(newProposal, itemMapping);
        }

        response.setPerformative(ACLMessage.PROPOSE);
        try {
          myAgent.getContentManager().fillContent(response, newProposal);
        } catch (OntologyException oe) {
          oe.printStackTrace();
        } catch (Codec.CodecException cex) {
          cex.printStackTrace();
        }
      } else {
        response.setPerformative(ACLMessage.REFUSE);
      }

      return response;
    }
  /** Subscriber register */
  public boolean register(Subscription sub) throws RefuseException, NotUnderstoodException {
    Date date = null;
    SubscriptionMessageType type = null;
    //
    try {
      // Unpack message
      ContentElement ce = buildingcs.getContentManager().extractContent(sub.getMessage());
      if (ce instanceof SendSubscriptionMessage) {
        SendSubscriptionMessage smsg = (SendSubscriptionMessage) ce;
        type = smsg.getMessage().getType(); // Subscription type
        date = smsg.getMessage().getSendDate(); // Last message date
      }
    } catch (UngroundedException e) {
      e.printStackTrace();
    } catch (OntologyException e) {
      e.printStackTrace();
    } catch (jade.content.lang.Codec.CodecException e) {
      e.printStackTrace();
    }

    if (type != null) {
      subscribers.add(new Subscriber(sub, type, date));
      this.confirm(sub);
      System.out.println(
          "Agent "
              + buildingcs.getAID().getName()
              + " registered the agent "
              + sub.getMessage().getSender().getName());
      //
      if (subscribers.size() == 1) {
        buildingcs.addBehaviour(tick_behavior); // At first subscriber add tick behavior
      }
    }

    return true;
  }
    /**
     * Handles a CFP message. This method is invoked when the first CFP is received. In this
     * implementation, the need is checked against the competence actually provided by this agent.
     * If it is there, <code>createStartingProposal</code> is used to generate a proposal.
     *
     * @param cfp The CFP message received
     */
    public ACLMessage handleFirstCfp(ACLMessage cfp) {
      ACLMessage response = cfp.createReply();
      try {
        ContentElement ce = myAgent.getContentManager().extractContent(cfp);
        CompetenceCall competenceCall = (CompetenceCall) ce;
        AID requesterAgent = competenceCall.getRequester();

        if (((EnterpriseAgent) myAgent).getNumberOfActiveContracts()
            > ((EnterpriseAgent) myAgent).MAX_NUMBER_OF_ACTIVE_CONTRACTS) {
          response.setPerformative(ACLMessage.REFUSE);
          response.setContent("refused...");
        } else {
          need = competenceCall.getNeed();
          competence = ((EnterpriseAgent) myAgent).findCompetence(need, requesterAgent);

          itemMapping = ((EnterpriseAgent) myAgent).getItemMapping(need, requesterAgent);
          if (itemMapping != null) { // using a mapped item - translate need into own ontology
            need =
                ((EnterpriseAgent) myAgent)
                    .translateToOwnItemOntology(need, requesterAgent, itemMapping);
          }

          if (competence != null) {
            if (((EnterpriseAgent) myAgent)
                .decideOnEnteringNegotiation(competenceCall, competence)) {
              // lets go for it!

              // create the starting proposal
              Proposal proposal = createStartingProposal(need, competence);

              if (itemMapping
                  != null) { // using a mapped item - translate proposal into foreign ontology
                proposal =
                    ((EnterpriseAgent) myAgent)
                        .translateToForeignItemOntology(proposal, itemMapping);
              }

              myAgent.getContentManager().fillContent(response, proposal);

              response.setPerformative(ACLMessage.PROPOSE);

              if (((EnterpriseAgent) myAgent).isUseQNegotiationStrategy()) {
                if (!qNegotiationStrategies.containsKey(competence.getType())) {
                  qNegotiationStrategies.put(competence.getType(), new QNegotiationStrategy());
                }
              }
            } else {
              // not negotiating
              response.setPerformative(ACLMessage.REFUSE);
            }
          } else {
            response.setPerformative(ACLMessage.REFUSE);
          }
        }
      } catch (OntologyException oe) {
        oe.printStackTrace();
        response.setPerformative(ACLMessage.REFUSE);
      } catch (Codec.CodecException ce) {
        ce.printStackTrace();
        response.setPerformative(ACLMessage.REFUSE);
      }

      return response;
    }