public static PublicationVO unPublish(Integer publicationId, InfoGluePrincipal infoGluePrincipal) throws SystemException
{
logger.info("Starting unpublishing operation...");
Database db = CastorDatabaseService.getDatabase();
Publication publication = null;
beginTransaction(db);
try
{
publication = getPublicationWithId(publicationId, db);
Collection publicationDetails = publication.getPublicationDetails();
Iterator i = publicationDetails.iterator();
while (i.hasNext())
{
PublicationDetail publicationDetail = (PublicationDetail)i.next();
logger.info("publicationDetail:" + publicationDetail.getId() + ":" + publicationDetail.getTypeId());
//We unpublish them as long as they are not unpublish-requests.
if(publicationDetail.getTypeId().intValue() != PublicationDetailVO.UNPUBLISH_LATEST.intValue())
{
unpublishEntity(publicationDetail, infoGluePrincipal, db);
}
else
{
republishEntity(publicationDetail, infoGluePrincipal, db);
}
}
db.remove(publication);
commitTransaction(db);
logger.info("Done unpublishing operation...");
}
catch(Exception e)
{
logger.error("An error occurred so we should not completes the transaction:" + e, e);
rollbackTransaction(db);
throw new SystemException(e.getMessage());
}
try
{
logger.info("Starting replication operation...");
ReplicationMySqlController.updateSlaveServer();
logger.info("Done replication operation...");
}
catch (Exception e)
{
logger.error("An error occurred when we tried to replicate the data:" + e.getMessage(), e);
}
//Update live site!!!
try
{
logger.info("Notifying the entire system about an unpublishing...");
NotificationMessage notificationMessage = new NotificationMessage("PublicationController.unPublish():", PublicationImpl.class.getName(), infoGluePrincipal.getName(), NotificationMessage.UNPUBLISHING, publication.getId(), publication.getName());
ChangeNotificationController.getInstance().addNotificationMessage(notificationMessage);
RemoteCacheUpdater.pushAndClearSystemNotificationMessages(infoGluePrincipal);
//RemoteCacheUpdater.clearSystemNotificationMessages();
logger.info("Finished Notifying...");
}
catch (Exception e)
{
logger.error("An error occurred when we tried to replicate the data:" + e.getMessage(), e);
}
return publication.getValueObject();
}