Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAK-50402 Portal publish now button visible if user has permission to publish the site #12813

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 14 additions & 28 deletions portal/portal-impl/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.sakaiproject.pasystem</groupId>
<artifactId>pasystem-api</artifactId>
Expand All @@ -87,7 +91,6 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- required for unit tests -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
Expand All @@ -100,11 +103,6 @@
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>jtidy</groupId>
<artifactId>jtidy</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
Expand All @@ -128,21 +126,6 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
Expand All @@ -155,9 +138,18 @@
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
</dependencies>

<build>
<sourceDirectory>src/java</sourceDirectory>
<resources>
<resource>
<directory>${basedir}/src/bundle</directory>
Expand All @@ -176,14 +168,8 @@
<testSourceDirectory>src/test/java</testSourceDirectory>
<testResources>
<testResource>
<directory>${basedir}/src/test/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
<filtering>false</filtering>
<directory>src/test/resources</directory>
</testResource>
<!--includes: **/*Test -->
</testResources>
<sourceDirectory>src/java</sourceDirectory>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@
import org.sakaiproject.portal.api.PortalService;
import org.sakaiproject.portal.util.PortalUtils;
import org.sakaiproject.site.api.Site;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.time.api.TimeService;
import org.sakaiproject.time.api.UserTimeService;
import org.sakaiproject.tool.api.Session;
import org.sakaiproject.util.ResourceLoader;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;


/**
Expand All @@ -54,15 +56,8 @@
*
*/
@Slf4j
public abstract class BasePortalHandler implements PortalHandler
{
public BasePortalHandler()
{
urlFragment = "none";
timeService = ComponentManager.get(TimeService.class);
}

private TimeService timeService;
public abstract class BasePortalHandler implements PortalHandler {
@Autowired UserTimeService timeService;

protected PortalService portalService;

Expand All @@ -72,6 +67,11 @@ public BasePortalHandler()

protected ServletContext servletContext;

public BasePortalHandler() {
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
urlFragment = "none";
}

public abstract int doGet(String[] parts, HttpServletRequest req,
HttpServletResponse res, Session session) throws PortalHandlerException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
import org.sakaiproject.tool.cover.ActiveToolManager;
import org.sakaiproject.tool.cover.SessionManager;
import org.sakaiproject.util.Web;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.component.api.ServerConfigurationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

/**
* Handler to process directtool urls including storing destination state
Expand All @@ -57,12 +58,12 @@
@Slf4j
public class DirectToolHandler extends BasePortalHandler
{
private static ServerConfigurationService serverConfigurationService = (ServerConfigurationService)ComponentManager.get(ServerConfigurationService.class);
@Autowired private ServerConfigurationService serverConfigurationService;

public static final String URL_FRAGMENT = "directtool";

public DirectToolHandler()
{
public DirectToolHandler() {
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
setUrlFragment(DirectToolHandler.URL_FRAGMENT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.sakaiproject.authz.api.AuthzGroupService;
import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.exception.IdUnusedException;
import org.sakaiproject.exception.PermissionException;
import org.sakaiproject.portal.api.Portal;
import org.sakaiproject.portal.api.PortalHandlerException;
import org.sakaiproject.portal.api.PortalRenderContext;
import org.sakaiproject.portal.charon.site.PortalSiteHelperImpl;
import org.sakaiproject.site.api.Site;
import org.sakaiproject.site.cover.SiteService;
import org.sakaiproject.site.api.SiteService;
import org.sakaiproject.tool.api.Session;
import org.sakaiproject.tool.api.ToolException;
import org.sakaiproject.portal.util.URLUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

/**
* Handler for managing the joining of a user to a site.
Expand All @@ -47,8 +49,11 @@ public class JoinHandler extends BasePortalHandler

private static final String URL_FRAGMENT = "join";

public JoinHandler()
{
@Autowired private AuthzGroupService authzGroupService;
@Autowired private SiteService siteService;

public JoinHandler() {
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
setUrlFragment(URL_FRAGMENT);
}

Expand Down Expand Up @@ -98,7 +103,7 @@ protected void doJoin(String[] parts, HttpServletRequest req,
if (site == null) {
throw new IdUnusedException(siteId);
}
SiteService.getInstance().join(site.getId());
siteService.join(site.getId());
sendToSite(res, site);
} else {
// The user didn't opt to join
Expand Down Expand Up @@ -145,7 +150,7 @@ protected void showJoin(String[] parts, HttpServletRequest req,
throw new IdUnusedException(siteId);
}
// Check that the current user can access the site before we redirect.
if (site.getUserRole(session.getUserId()) != null && SiteService.allowAccessSite(site.getId()))
if (site.getUserRole(session.getUserId()) != null && siteService.allowAccessSite(site.getId()))
{
sendToSite(res, site);
return;
Expand All @@ -156,15 +161,15 @@ protected void showJoin(String[] parts, HttpServletRequest req,
String serviceName = ServerConfigurationService.getString("ui.service", "Sakai");

// SAK-29138
List<String> siteProviders = (List<String>) PortalSiteHelperImpl.getProviderIDsForSite(site);
List<String> siteProviders = (List<String>) authzGroupService.getProviderIds(site.getReference());
String title = serviceName + " : " + portal.getSiteHelper().getUserSpecificSiteTitle(site, true, false, siteProviders);

String skin = site.getSkin();
PortalRenderContext context = portal.startPageContext(siteType, title, skin, req, site);
context.put("currentSite", portal.getSiteHelper().convertSiteToMap(req, site, null, site.getId(), null, false, false, false, false, null, true, siteProviders));
context.put("uiService", serviceName);

boolean restrictedByAccountType = !SiteService.getInstance().isAllowedToJoin(site.getId());
boolean restrictedByAccountType = !siteService.isAllowedToJoin(site.getId());
context.put("restrictedByAccountType", restrictedByAccountType);

portal.sendResponse(context, res, "join", "text/html");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.apache.commons.lang3.StringUtils;

import org.sakaiproject.authz.api.SecurityService;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.exception.IdUnusedException;
import org.sakaiproject.exception.PermissionException;
Expand All @@ -54,6 +53,8 @@
import org.sakaiproject.tool.api.Session;
import org.sakaiproject.tool.api.ToolException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

/**
* @author ieb
Expand All @@ -67,11 +68,10 @@ public class PageHandler extends BasePortalHandler

private static final String URL_FRAGMENT = "page";

private SecurityService securityService = null;
@Autowired private SecurityService securityService = null;

public PageHandler()
{
securityService = (SecurityService) ComponentManager.get("org.sakaiproject.authz.api.SecurityService");
public PageHandler() {
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
setUrlFragment(PageHandler.URL_FRAGMENT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import javax.servlet.http.HttpServletResponse;

import org.sakaiproject.authz.api.SecurityService;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.event.api.EventTrackingService;
import org.sakaiproject.event.api.NotificationService;
Expand All @@ -31,21 +30,20 @@
import org.sakaiproject.site.api.SiteService;
import org.sakaiproject.tool.api.Session;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;

@Slf4j
public class RoleSwitchOutHandler extends BasePortalHandler
{
private static final String URL_FRAGMENT = "role-switch-out";

final EventTrackingService eventTrackingService;
final SecurityService securityService;
final SiteService siteService;
@Autowired private EventTrackingService eventTrackingService;
@Autowired private SecurityService securityService;
@Autowired private SiteService siteService;

public RoleSwitchOutHandler()
{
eventTrackingService = ComponentManager.get(EventTrackingService.class);
securityService = ComponentManager.get(SecurityService.class);
siteService = ComponentManager.get(SiteService.class);
public RoleSwitchOutHandler() {
SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
setUrlFragment(RoleSwitchOutHandler.URL_FRAGMENT);
}

Expand Down
Loading
Loading