private Peer constructPeerPojo(final PeerData peerData) throws PeerException {
  Preconditions.checkNotNull(peerData,"Peer info could not be null.");
  try {
    PeerInfo peerInfo=fromJson(peerData.getInfo(),PeerInfo.class);
    if (localPeerId.equals(peerData.getId())) {
      localPeer.setPeerInfo(peerInfo);
      return localPeer;
    }
    RemotePeerImpl remotePeer=new RemotePeerImpl(localPeerId,securityManager,peerInfo,messenger,commandResponseListener,messageResponseListener,provider,this);
    RelationInfoMeta relationInfoMeta=new RelationInfoMeta();
    Map<String,String> traits=relationInfoMeta.getRelationTraits();
    traits.put("receiveHeartbeats","allow");
    traits.put("sendHeartbeats","allow");
    traits.put("hostTemplates","allow");
    User peerOwner=identityManager.getUserByKeyId(identityManager.getPeerOwnerId());
    RelationMeta relationMeta=new RelationMeta(peerOwner,localPeer,remotePeer,localPeer.getKeyId());
    Relation relation=relationManager.buildRelation(relationInfoMeta,relationMeta);
    relation.setRelationStatus(RelationStatus.VERIFIED);
    relationManager.saveRelation(relation);
    return remotePeer;
  }
 catch (  Exception e) {
    throw new PeerException("Could not create peer instance.",e);
  }
}

private Peer constructPeerPojo ( final PeerData peerData ) throws PeerException { Preconditions . checkNotNull ( peerData , "Peer info could not be null." ) ; try { PeerInfo peerInfo = fromJson ( peerData . getInfo ( ) , PeerInfo . class ) ; if ( localPeerId . equals ( peerData . getId ( ) ) ) { localPeer . setPeerInfo ( peerInfo ) ; return localPeer ; } RemotePeerImpl remotePeer = new RemotePeerImpl ( localPeerId , securityManager , peerInfo , messenger , commandResponseListener , messageResponseListener , provider , this ) ; RelationInfoMeta relationInfoMeta = new RelationInfoMeta ( ) ; Map < String , String > traits = relationInfoMeta . getRelationTraits ( ) ; traits . put ( "receiveHeartbeats" , "allow" ) ; traits . put ( "sendHeartbeats" , "allow" ) ; traits . put ( "hostTemplates" , "allow" ) ; User peerOwner = identityManager . getUserByKeyId ( identityManager . getPeerOwnerId ( ) ) ; RelationMeta relationMeta = new RelationMeta ( peerOwner , localPeer , remotePeer , localPeer . getKeyId ( ) ) ; Relation relation = relationManager . buildRelation ( relationInfoMeta , relationMeta ) ; relation . setRelationStatus ( RelationStatus . VERIFIED ) ; relationManager . saveRelation ( relation ) ; return remotePeer ; } catch ( Exception e ) { throw new PeerException ( "Could not create peer instance." , e ) ; } }
creates the peer instance by provided peer data
