Index: kernel-impl/src/main/java/org/sakaiproject/site/impl/SiteServiceSql.java =================================================================== --- kernel-impl/src/main/java/org/sakaiproject/site/impl/SiteServiceSql.java (revision 71608) +++ kernel-impl/src/main/java/org/sakaiproject/site/impl/SiteServiceSql.java (revision 72448) @@ -358,22 +358,9 @@ String getSitesWhereSoftlyDeletedOnlySql(); /** - * returns the sql statement which is part of the order clause to retrieve sites ordered by softly deleted status + * returns the sql statement which is part of the qhere clause to only retrieve sites that are NOT softly deleted + * @return */ - String getSitesOrderSoftlyDeletedAscSql(); + String getSitesWhereNotSoftlyDeletedSql(); - /** - * returns the sql statement which is part of the order clause to retrieve sites ordered by not being softly deleted - */ - String getSitesOrderSoftlyDeletedDescSql(); - - /** - * returns the sql statement which is part of the order clause to retrieve sites ordered by softly deleted date asc - */ - String getSitesOrderSoftlyDeletedDateAscSql(); - - /** - * returns the sql statement which is part of the order clause to retrieve sites ordered by softly deleted date desc - */ - String getSitesOrderSoftlyDeletedDateDescSql(); } Index: kernel-impl/src/main/java/org/sakaiproject/site/impl/SiteServiceSqlDefault.java =================================================================== --- kernel-impl/src/main/java/org/sakaiproject/site/impl/SiteServiceSqlDefault.java (revision 71608) +++ kernel-impl/src/main/java/org/sakaiproject/site/impl/SiteServiceSqlDefault.java (revision 72448) @@ -564,34 +564,12 @@ } /** - * returns the sql statement which is part of the order clause to retrieve sites ordered by softly deleted status + * returns the sql statement which is part of the where clause to only retrieve sites that are NOT softly deleted + * @return */ - public String getSitesOrderSoftlyDeletedAscSql() + public String getSitesWhereNotSoftlyDeletedSql() { - return "SAKAI_SITE.IS_SOFTLY_DELETED ASC"; + return "SAKAI_SITE.IS_SOFTLY_DELETED = '0' and "; } - /** - * returns the sql statement which is part of the order clause to retrieve sites ordered by not being softly deleted - */ - public String getSitesOrderSoftlyDeletedDescSql() - { - return "SAKAI_SITE.IS_SOFTLY_DELETED DESC"; - } - - /** - * returns the sql statement which is part of the order clause to retrieve sites ordered by softly deleted date asc - */ - public String getSitesOrderSoftlyDeletedDateAscSql() - { - return "SAKAI_SITE.SOFTLY_DELETED_DATE ASC"; - } - - /** - * returns the sql statement which is part of the order clause to retrieve sites ordered by softly deleted date desc - */ - public String getSitesOrderSoftlyDeletedDateDescSql() - { - return "SAKAI_SITE.SOFTLY_DELETED_DATE DESC"; - } } Index: kernel-impl/src/main/java/org/sakaiproject/site/impl/BaseSiteService.java =================================================================== --- kernel-impl/src/main/java/org/sakaiproject/site/impl/BaseSiteService.java (revision 71608) +++ kernel-impl/src/main/java/org/sakaiproject/site/impl/BaseSiteService.java (revision 72448) @@ -475,6 +475,7 @@ functionManager().registerFunction(SECURE_UPDATE_GROUP_MEMBERSHIP); functionManager().registerFunction(SECURE_ADD_COURSE_SITE); functionManager().registerFunction(SITE_VISIT_SOFTLY_DELETED); + functionManager().registerFunction(SECURE_REMOVE_SOFTLY_DELETED_SITE); } catch (Exception t) @@ -1200,11 +1201,24 @@ /** * @inheritDoc */ - public void removeSite(Site site) throws PermissionException + public void removeSite(Site site) throws PermissionException, IdUnusedException { // check security (throws if not permitted) unlock(SECURE_REMOVE_SITE, site.getReference()); + // if soft site deletes are active + if(serverConfigurationService().getBoolean("site.soft.deletion", false)) { + // if site is not already softly deleted, softly delete it + // if already marked for deletion, check permission to hard delete, if ok, let continue. + if(!site.isSoftlyDeleted()) { + site.setSoftlyDeleted(true); + save(site); + return; + } else { + unlock(SECURE_REMOVE_SOFTLY_DELETED_SITE, site.getReference()); + } + } + // complete the edit m_storage.remove(site); Index: kernel-impl/src/main/java/org/sakaiproject/site/impl/DbSiteService.java =================================================================== --- kernel-impl/src/main/java/org/sakaiproject/site/impl/DbSiteService.java (revision 71608) +++ kernel-impl/src/main/java/org/sakaiproject/site/impl/DbSiteService.java (revision 72448) @@ -512,6 +512,10 @@ if (type.isIgnoreSpecial()) where.append(siteServiceSql.getSitesWhere3Sql()); // reject unpublished sites if (type.isIgnoreUnpublished()) where.append(siteServiceSql.getSitesWhere4Sql()); + // reject softly deleted sites + if (type.isIgnoreSoftlyDeleted()) { + where.append(siteServiceSql.getSitesWhereNotSoftlyDeletedSql()); + } if (ofType != null) { @@ -659,14 +663,6 @@ { order = siteServiceSql.getSitesOrder16Sql(); } - else if (sort == SortType.SOFTLY_DELETED_ASC) - { - order = siteServiceSql.getSitesOrderSoftlyDeletedAscSql(); - } - else if (sort == SortType.SOFTLY_DELETED_DESC) - { - order = siteServiceSql.getSitesOrderSoftlyDeletedDescSql(); - } return order; } @@ -971,6 +967,9 @@ if (type == SelectionType.ACCESS) where.append(siteServiceSql.getSitesWhere11Sql()); // joinable requires NOT access permission if (type == SelectionType.JOINABLE) where.append(siteServiceSql.getSitesWhere12Sql()); + + // always reject softly deleted sites + where.append(siteServiceSql.getSitesWhereNotSoftlyDeletedSql()); // do we need a join? String join = null; Index: api/src/main/java/org/sakaiproject/site/api/SiteService.java =================================================================== --- api/src/main/java/org/sakaiproject/site/api/SiteService.java (revision 71608) +++ api/src/main/java/org/sakaiproject/site/api/SiteService.java (revision 72448) @@ -83,8 +83,8 @@ /** Name for the event of removing a site. */ static final String SECURE_REMOVE_SITE = "site.del"; - /** Name for the event of removing a site softly. */ - static final String SECURE_REMOVE_SITE_SOFTLY = "site.del.soft"; + /** Name for the event of removing a site that has already been softly deleted */ + static final String SECURE_REMOVE_SOFTLY_DELETED_SITE = "site.del.softly.deleted"; /** Name for the event of visiting a softly deleted site. */ static final String SITE_VISIT_SOFTLY_DELETED = "site.visit.softly.deleted"; @@ -136,13 +136,17 @@ private final boolean m_ignoreUser; private final boolean m_ignoreUnpublished; + + //always true, we always ignore unpublished sites + private final boolean m_ignoreSoftlyDeleted; - private SelectionType(String id, boolean ignoreSpecial, boolean ignoreUser, boolean ignoreUnpublished) + private SelectionType(String id, boolean ignoreSpecial, boolean ignoreUser, boolean ignoreUnpublished, boolean ignoreSoftlyDeleted) { m_id = id; m_ignoreSpecial = ignoreSpecial; m_ignoreUser = ignoreUser; m_ignoreUnpublished = ignoreUnpublished; + m_ignoreSoftlyDeleted = ignoreSoftlyDeleted; } public String toString() @@ -164,24 +168,29 @@ { return m_ignoreUnpublished; } + + public boolean isIgnoreSoftlyDeleted() + { + return m_ignoreSoftlyDeleted; + } /** Get sites that the current user has read access to (non-myWorkspace, non-special). */ - public static final SelectionType ACCESS = new SelectionType("access", true, true, false); + public static final SelectionType ACCESS = new SelectionType("access", true, true, false, true); /** Get sites that the current user has write access to (non-myWorkspace, non-special). */ - public static final SelectionType UPDATE = new SelectionType("update", true, true, false); + public static final SelectionType UPDATE = new SelectionType("update", true, true, false, true); /** Get sites that the current user does not have read access to but are joinable (non-myWorkspace, non-special). */ - public static final SelectionType JOINABLE = new SelectionType("joinable", true, true, true); + public static final SelectionType JOINABLE = new SelectionType("joinable", true, true, true, true); /** Get sites that are marked for view (non-myWorkspace, non-special). */ - public static final SelectionType PUBVIEW = new SelectionType("pubView", true, true, true); + public static final SelectionType PUBVIEW = new SelectionType("pubView", true, true, true, true); /** Get any sites. */ - public static final SelectionType ANY = new SelectionType("any", false, false, false); + public static final SelectionType ANY = new SelectionType("any", false, false, true, true); /** Get any non-user sites. */ - public static final SelectionType NON_USER = new SelectionType("nonUser", false, true, false); + public static final SelectionType NON_USER = new SelectionType("nonUser", false, true, true, true); } /** @@ -464,12 +473,19 @@ /** * Remove this site's information. * + *

If site.soft.deletion=true, the site will be softly deleted and user access will be removed. + * The site will be hard deleted after either the grace period has expired. + * The site may also be hard deleted by issuing another removeSite request by a user that has permission + * to remove softly deleted sites. + * * @param site * The site id. * @exception PermissionException * if the current user does not have permission to remove this site. + * @exception IdUnusedException + * if site does not exist */ - void removeSite(Site site) throws PermissionException; + void removeSite(Site site) throws PermissionException, IdUnusedException; /** * Access the internal reference which can be used to access the site from within the system. Index: api/src/main/java/org/sakaiproject/site/cover/SiteService.java =================================================================== --- api/src/main/java/org/sakaiproject/site/cover/SiteService.java (revision 71608) +++ api/src/main/java/org/sakaiproject/site/cover/SiteService.java (revision 72448) @@ -72,7 +72,7 @@ public static java.lang.String SECURE_REMOVE_SITE = org.sakaiproject.site.api.SiteService.SECURE_REMOVE_SITE; - public static java.lang.String SECURE_REMOVE_SITE_SOFTLY = org.sakaiproject.site.api.SiteService.SECURE_REMOVE_SITE_SOFTLY; + public static java.lang.String SECURE_REMOVE_SOFTLY_DELETED_SITE = org.sakaiproject.site.api.SiteService.SECURE_REMOVE_SOFTLY_DELETED_SITE; public static java.lang.String SITE_VISIT_SOFTLY_DELETED = org.sakaiproject.site.api.SiteService.SITE_VISIT_SOFTLY_DELETED; @@ -243,7 +243,7 @@ return service.allowRemoveSite(param0); } - public static void removeSite(org.sakaiproject.site.api.Site param0) throws org.sakaiproject.exception.PermissionException + public static void removeSite(org.sakaiproject.site.api.Site param0) throws org.sakaiproject.exception.PermissionException, org.sakaiproject.exception.IdUnusedException { org.sakaiproject.site.api.SiteService service = getInstance(); if (service == null) return;