{
cid=getChannelId(subscribe_id);
can_subscribe=_securityPolicy.canSubscribe(client,subscribe_id,message);
}
Message reply=newMessage(message);
reply.put(CHANNEL_FIELD,META_SUBSCRIBE);
reply.put(SUBSCRIPTION_FIELD,subscribe_id);
if (can_subscribe)
{
if (cid != null)
{
ChannelImpl channel=getChannel(cid);
if (channel == null && _securityPolicy.canCreate(client,subscribe_id,message))
channel=(ChannelImpl)getChannel(subscribe_id,true);
if (channel != null)
{
// Reduces the window of time where a server-side expiration
// or a concurrent disconnect causes the invalid client to be
// registered as subscriber and hence being kept alive by the
// fact that the channel references it.
if (isClientUnknown(client))
{
unknownClient(transport, META_SUBSCRIBE);
return;
}
else
{
channel.subscribe(client);
}
}
else
{
can_subscribe=false;
}
}
if (can_subscribe)
{
reply.put(SUCCESSFUL_FIELD,Boolean.TRUE);
}
else
{
reply.put(SUCCESSFUL_FIELD,Boolean.FALSE);
reply.put(ERROR_FIELD,"403::cannot create");
}
}
else
{
reply.put(SUCCESSFUL_FIELD,Boolean.FALSE);
reply.put(ERROR_FIELD,"403::cannot subscribe");
}
String id=message.getId();
if (id != null)
reply.put(ID_FIELD,id);
sendMetaReply(client,reply,transport);
}