public static boolean archiveAsset(WebAsset currWebAsset, String userId) throws DotDataException, DotStateException, DotSecurityException {
// gets the identifier for this asset
Identifier identifier = APILocator.getIdentifierAPI().find(currWebAsset);
WebAsset workingwebasset = null;
// gets the current working asset
workingwebasset = (WebAsset) APILocator.getVersionableAPI().findWorkingVersion(identifier, APILocator.getUserAPI().getSystemUser(), false);
WebAsset live = (WebAsset) APILocator.getVersionableAPI().findLiveVersion(identifier, APILocator.getUserAPI().getSystemUser(), false);
//Delete the HTML Page from the Structure Detail
if(currWebAsset instanceof HTMLPage)
{
List<Structure> structures = (List<Structure>) StructureFactory.getStructures();
for(Structure structure : structures)
{
if(structure.getDetailPage() == identifier.getInode())
{
structure.setDetailPage("");
StructureFactory.saveStructure(structure);
}
}
}
else if (currWebAsset instanceof File)
{
RefreshMenus.deleteMenu(currWebAsset);
Identifier ident=APILocator.getIdentifierAPI().find(currWebAsset);
CacheLocator.getNavToolCache().removeNavByPath(ident.getHostId(), ident.getParentPath());
}
User userMod = null;
try{
userMod = APILocator.getUserAPI().loadUserById(workingwebasset.getModUser(),APILocator.getUserAPI().getSystemUser(),false);
}catch(Exception ex){
if(ex instanceof NoSuchUserException){
try {
userMod = APILocator.getUserAPI().getSystemUser();
} catch (DotDataException e) {
Logger.error(WebAssetFactory.class,e.getMessage(),e);
}
}
}
if(userMod!=null){
workingwebasset.setModUser(userMod.getUserId());
}
if (userId == null || !workingwebasset.isLocked() || workingwebasset.getModUser().equals(userId)) {
if (live!=null && InodeUtils.isSet(live.getInode())) {
APILocator.getVersionableAPI().removeLive(live.getIdentifier());
}
//Reset the mod date
workingwebasset.setModDate(new Date ());
// sets deleted to true