Identifier ident = APILocator.getIdentifierAPI().find( versionable );
if ( ident.getAssetType().equals( "contentlet" ) ) {
Contentlet cont = (Contentlet) versionable;
ContentletVersionInfo info = vfac.getContentletVersionInfo( cont.getIdentifier(), cont.getLanguageId() );
if ( info == null || !UtilMethods.isSet( info.getIdentifier() ) ) {
throw new DotStateException( "No version info. Call setWorking first" );
}
//Get the structure for this contentlet
Structure structure = StructureCache.getStructureByInode( cont.getStructureInode() );
if ( UtilMethods.isSet( structure.getPublishDateVar() ) ) {//Verify if the structure have a Publish Date Field set
if ( UtilMethods.isSet( ident.getSysPublishDate() ) && ident.getSysPublishDate().after( new Date() ) ) {
throw new PublishStateException( "message.contentlet.publish.future.date" );
}
}
if ( UtilMethods.isSet( structure.getExpireDateVar() ) ) {//Verify if the structure have a Expire Date Field set
if ( UtilMethods.isSet( ident.getSysExpireDate() ) && ident.getSysExpireDate().before( new Date() ) ) {
throw new PublishStateException( "message.contentlet.expired" );
}
}
info.setLiveInode( versionable.getInode() );
vfac.saveContentletVersionInfo( info, true );
} else {
VersionInfo info = vfac.getVersionInfo( versionable.getVersionId() );
if ( !UtilMethods.isSet( info.getIdentifier() ) ) {
throw new DotStateException( "No version info. Call setWorking first" );
}
info.setLiveInode( versionable.getInode() );
vfac.saveVersionInfo( info, true );
}
}