public Channel createSubChannel(Channel parentChannel, String channelName)
throws AuthorizationException, ApplicationException,
ValidationException {
// Create a new channel
Channel channel = new Channel();
// Configure the channel as requested
ChannelData channelData = channel.getData();
channelData.setParentChannelRef(new ChannelRef(parentChannel));
channelData.setName(channelName);
// Save the channel
channel.commit();
// Return the channel
return channel;
}
==============================
System.out.println("Creating SubChannel " + name + "...");
//Create sub channels for Home Channel
Channel homeChannel = newSite.getHomeChannel();
ChannelRef parent = new ChannelRef( mHomeChannel );
ChannelData subChannelData = new ChannelData();
subChannelData.setName("mysubchannel");
subChannelData.setDescription("This is a subchannel of the Home Channel");
subChannelData.setOrderAsSibling(sibOrder);
subChannelData.setParentChannelRef(parent);
Channel subChannel = new Channel();
subChannel.setData(subData);
//Approve the channel
subChannel.setStatus("approved");
subChannel.commit();
System.out.println("Created SubChannel " + name);
//Associate the content instance to the mysubchannel
ChannelContentAssociationData ciTestAssocData = new
ChannelContentAssociationData();
ci = (ContentInstance)ContentInstance.findByContentManagementId( mgmtId );
ciTestAssocData.setContentRef(ci.getContentManagementId());
subChannelData.addContentAssociations(ciTestAssocData);
subChannel.commit();
No comments:
Post a Comment