code: private void deleteResource(CmsResource resource) throws CmsException {
  
          String path = null;
          CmsObject cms = getCmsObject();
          try {
              path = cms.getSitePath(resource);
              cms.lockResource(path);
              cms.deleteResource(path, CmsResource.DELETE_PRESERVE_SIBLINGS);
              // check if any detail container page resources exist to this resource
              List<CmsResource> detailContainers = CmsDetailOnlyContainerUtil.getDetailOnlyResources(cms, resource);
              for (CmsResource detailContainer : detailContainers) {
                  deleteResource(detailContainer);
              }
          } finally {
              try {
                  if (path != null) {
                      getCmsObject().unlockResource(path);
                  }
              } catch (Exception e) {
                  // should really never happen
                  LOG.debug(e.getLocalizedMessage(), e);
              }
          }
      }
docs: Internal method to delete the given resource.<p>
  
  @param resource the resource to delete
  
  @throws CmsException if something goes wrong