org.apache.wicket.RestartResponseException Java Examples

The following examples show how to use org.apache.wicket.RestartResponseException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NewVersionsAdditionalEmailHtmlNotificationDemoPage.java    From artifact-listener with Apache License 2.0 6 votes vote down vote up
public NewVersionsAdditionalEmailHtmlNotificationDemoPage(PageParameters parameters) {
	super(parameters);
	
	User user = userService.getByUserName(ConsoleNotificationIndexPage.DEFAULT_USERNAME);
	if (user == null) {
		LOGGER.error("There is no user available");
		Session.get().error(getString("console.notifications.noDataAvailable"));
		
		throw new RestartResponseException(ConsoleNotificationIndexPage.class);
	}
	
	Collection<EmailAddress> emailAddresses = user.getAdditionalEmails();
	if (emailAddresses == null || emailAddresses.isEmpty()) {
		LOGGER.error("There is no additional email address available");
		Session.get().error(getString("console.notifications.noDataAvailable"));
		
		throw new RestartResponseException(ConsoleNotificationIndexPage.class);
	}
	EmailAddress additionalEmail = Iterables.get(emailAddresses, 0);
	
	List<ArtifactVersionNotification> notifications = userService.listRecentNotifications(user);
	
	IModel<List<ArtifactVersionNotification>> notificationsModel = new ListModel<ArtifactVersionNotification>(notifications);
	add(new NewVersionsHtmlNotificationPanel("htmlPanel", notificationsModel,
			new GenericEntityModel<Long, EmailAddress>(additionalEmail)));
}
 
Example #2
Source File: BasePage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Performs role checks for instructor-only pages and redirects users to appropriate pages based on their role.
 * No role -> AccessDeniedPage. Student -> StudentPage. TA -> GradebookPage (if ta does not have the gradebook.editAssignments permission)
 */
protected final void defaultRoleChecksForInstructorOnlyPage()
{
	switch (role)
	{
		case NONE:
			sendToAccessDeniedPage(getString("error.role"));
			break;
		case STUDENT:
			throw new RestartResponseException(StudentPage.class);
		case TA:
			if(businessService.isUserAbleToEditAssessments()) {
				break;
			}
			throw new RestartResponseException(GradebookPage.class);
		default:
			break;
	}
}
 
Example #3
Source File: RedirectMessageDialog.java    From openmeetings with Apache License 2.0 6 votes vote down vote up
private void startTimer(IPartialPageRequestHandler handler) {
	getLabel().add(new OmTimerBehavior(DELAY, labelId) {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onFinish(AjaxRequestTarget target) {
			if (Strings.isEmpty(url)) {
				throw new RestartResponseException(Application.get().getHomePage());
			} else {
				throw new RedirectToUrlException(url);
			}
		}
	}).setOutputMarkupId(true);
	if (handler != null) {
		handler.add(getLabel());
	}
}
 
Example #4
Source File: LoginPage.java    From webanno with Apache License 2.0 6 votes vote down vote up
private void redirectIfAlreadyLoggedIn()
{
    // If we are already logged in, redirect to the welcome page. This tries to a void a
    // situation where the user tries to access the login page directly and thus the
    // application would redirect the user to the login page after a successful login
    if (!(SecurityContextHolder.getContext()
            .getAuthentication() instanceof AnonymousAuthenticationToken)) {
        log.debug("Already logged in, forwarding to home page");
        throw new RestartResponseException(getApplication().getHomePage());
    }
    
    String redirectUrl = getRedirectUrl();
    if (redirectUrl == null) {
        log.debug("Authentication required");
    }
    else {
        log.debug("Authentication required (original URL: [{}])", redirectUrl);
    }
}
 
Example #5
Source File: MyWallPanel.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Creates a new instance of <code>MyWallPanel</code>.
 * 
 * This method is used when a super user is viewing the profile of another
 * user.
 */
public MyWallPanel(String panelId, String userUuid) {

	super(panelId);

	// double check for super user
	if (false == sakaiProxy.isSuperUser()) {
		log.error("MyWallPanel: user " + sakaiProxy.getCurrentUserId()
				+ " attempted to access MyWallPanel for " + userUuid
				+ ". Redirecting...");

		throw new RestartResponseException(new MyProfile());
	}
	
	renderWallPanel(userUuid);
}
 
Example #6
Source File: MessageView.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Constructor for an incoming link with a threadId as part of the PageParameters
 * @param parameters
 */
public MessageView(final String id, PageParameters parameters) {
	super(id);
	log.debug("MyMessageView(" + parameters.toString() +")");

	MessageThread thread = messagingLogic.getMessageThread(parameters.get("thread").toString());
	
	//check user is a thread participant
	String currentUserUuid = sakaiProxy.getCurrentUserId();
	if(!messagingLogic.isThreadParticipant(thread.getId(), currentUserUuid)) {
		//this would only ever happen if the user has access to the other user's workspace because the link is a direct link to their site
		//so they won't even reach this part if they don't have access - so it would need to be a very special case.
		log.error("MyMessageView: user " + currentUserUuid + " attempted to access restricted thread: " + thread.getId());
		throw new RestartResponseException(new MyMessages());
	}
	
	renderMyMessagesView(sakaiProxy.getCurrentUserId(), thread.getId(), thread.getSubject());
}
 
Example #7
Source File: ServerInitPage.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(new Label("title", initStage.getMessage()));
	
	if (!initStage.getManualConfigs().isEmpty()) {
		List<ManualConfigStep> configSteps = new ArrayList<ManualConfigStep>();
		for (ManualConfig each: initStage.getManualConfigs())
			configSteps.add(new ManualConfigStep(each));
		add(new Wizard("wizard", configSteps) {

			@Override
			protected void finished() {
				WebSession.get().logout();
				User root = OneDev.getInstance(UserManager.class).getRoot();
				SecurityUtils.getSubject().runAs(root.getPrincipals());
				throw new RestartResponseException(ProjectListPage.class);
			}
			
		});
	} else {
		add(new WebMarkupContainer("wizard").setVisible(false));
	}
}
 
Example #8
Source File: UserPage.java    From onedev with MIT License 6 votes vote down vote up
public UserPage(PageParameters params) {
	super(params);
	
	String userIdString = params.get(PARAM_USER).toString();
	if (StringUtils.isBlank(userIdString))
		throw new RestartResponseException(UserListPage.class);
	
	Long userId = Long.valueOf(userIdString);
	if (userId == User.SYSTEM_ID)
		throw new OneException("System user is not accessible");
	
	userModel = new LoadableDetachableModel<User>() {

		@Override
		protected User load() {
			return OneDev.getInstance(UserManager.class).load(userId);
		}
		
	};
}
 
Example #9
Source File: GroupPage.java    From onedev with MIT License 6 votes vote down vote up
public GroupPage(PageParameters params) {
	super(params);
	
	String groupIdString = params.get(PARAM_GROUP).toString();
	if (StringUtils.isBlank(groupIdString))
		throw new RestartResponseException(GroupListPage.class);
	
	Long groupId = Long.valueOf(groupIdString);
	
	groupModel = new LoadableDetachableModel<Group>() {

		@Override
		protected Group load() {
			return OneDev.getInstance(GroupManager.class).load(groupId);
		}
		
	};
}
 
Example #10
Source File: RoleDetailPage.java    From onedev with MIT License 6 votes vote down vote up
public RoleDetailPage(PageParameters params) {
	super(params);
	
	String roleIdString = params.get(PARAM_ROLE).toString();
	if (StringUtils.isBlank(roleIdString))
		throw new RestartResponseException(RoleListPage.class);
	
	roleModel = new LoadableDetachableModel<Role>() {

		@Override
		protected Role load() {
			return OneDev.getInstance(RoleManager.class).load(Long.valueOf(roleIdString));
		}
		
	};
}
 
Example #11
Source File: JasperRuntimePanel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public JasperRuntimePanel(String id, final Report report, ReportRuntimeModel runtimeModel) {
    super(id);        
    typeList = reportService.getSupportedOutputs(report);

    this.report = report;
    this.runtimeModel = runtimeModel;

    if (runtimeModel.getExportType() == null) {
        runtimeModel.setExportType(ReportConstants.HTML_FORMAT);
    }

    try {
        paramMap = reportService.getReportUserParameters(report, new ArrayList<ExternalParameter>());
        convertMap = convert(report.getDataSource(), paramMap);
        convertList = new LinkedList<QueryParameter>(convertMap.values());
        paramComponentsMap = new HashMap<QueryParameter, Component>();
    } catch (Exception e) {
        //@todo alert
        e.printStackTrace();
        getSession().error(e.getMessage());
        throw new RestartResponseException(new MessageErrorPage(e.getMessage() + " : Verify the parameters sources."));

    }
    
    addComponents();
}
 
Example #12
Source File: MessageView.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Constructor for an incoming link with a threadId as part of the PageParameters
 * @param parameters
 */
public MessageView(final String id, PageParameters parameters) {
	super(id);
	log.debug("MyMessageView(" + parameters.toString() +")");

	MessageThread thread = messagingLogic.getMessageThread(parameters.get("thread").toString());
	
	//check user is a thread participant
	String currentUserUuid = sakaiProxy.getCurrentUserId();
	if(!messagingLogic.isThreadParticipant(thread.getId(), currentUserUuid)) {
		//this would only ever happen if the user has access to the other user's workspace because the link is a direct link to their site
		//so they won't even reach this part if they don't have access - so it would need to be a very special case.
		log.error("MyMessageView: user " + currentUserUuid + " attempted to access restricted thread: " + thread.getId());
		throw new RestartResponseException(new MyMessages());
	}
	
	renderMyMessagesView(sakaiProxy.getCurrentUserId(), thread.getId(), thread.getSubject());
}
 
Example #13
Source File: DeleteEmailHtmlNotificationDemoPage.java    From artifact-listener with Apache License 2.0 6 votes vote down vote up
public DeleteEmailHtmlNotificationDemoPage(PageParameters parameters) {
	super(parameters);
	
	User user = userService.getByUserName(ConsoleNotificationIndexPage.DEFAULT_USERNAME);
	EmailAddress emailAddress = null;
	if (user != null) {
		emailAddress = Iterables.getFirst(user.getAdditionalEmails(), null);
	}
	if (user == null || emailAddress == null) {
		LOGGER.error("There is no user or email address available");
		Session.get().error(getString("console.notifications.noDataAvailable"));
		
		throw new RestartResponseException(ConsoleNotificationIndexPage.class);
	}

	if (emailAddress.getEmailHash() == null) {
		emailAddress.setEmailHash(userService.getHash(user, emailAddress.getEmail()));
	}
	
	add(new DeleteEmailHtmlNotificationPanel("htmlPanel", Model.of(emailAddress)));
}
 
Example #14
Source File: BuildDetailPage.java    From onedev with MIT License 6 votes vote down vote up
public BuildDetailPage(PageParameters params) {
	super(params);
	
	String buildNumberString = params.get(PARAM_BUILD).toString();
	if (StringUtils.isBlank(buildNumberString))
		throw new RestartResponseException(ProjectBuildsPage.class, ProjectBuildsPage.paramsOf(getProject(), null, 0));
		
	buildModel = new LoadableDetachableModel<Build>() {

		@Override
		protected Build load() {
			Long buildNumber = params.get(PARAM_BUILD).toLong();
			Build build = OneDev.getInstance(BuildManager.class).find(getProject(), buildNumber);
			if (build == null)
				throw new EntityNotFoundException("Unable to find build #" + buildNumber + " in project " + getProject());
			else if (!build.getProject().equals(getProject()))
				throw new RestartResponseException(getPageClass(), paramsOf(build));
			else
				return build;
		}

	};

	if (!getBuild().isValid())
		throw new RestartResponseException(InvalidBuildPage.class, InvalidBuildPage.paramsOf(getBuild()));
}
 
Example #15
Source File: MyWallPanel.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Creates a new instance of <code>MyWallPanel</code>.
 * 
 * This method is used when a super user is viewing the profile of another
 * user.
 */
public MyWallPanel(String panelId, String userUuid) {

	super(panelId);

	// double check for super user
	if (false == sakaiProxy.isSuperUser()) {
		log.error("MyWallPanel: user " + sakaiProxy.getCurrentUserId()
				+ " attempted to access MyWallPanel for " + userUuid
				+ ". Redirecting...");

		throw new RestartResponseException(new MyProfile());
	}
	
	renderWallPanel(userUuid);
}
 
Example #16
Source File: IssueDetailPage.java    From onedev with MIT License 6 votes vote down vote up
public IssueDetailPage(PageParameters params) {
	super(params);
	
	String issueNumberString = params.get(PARAM_ISSUE).toString();
	if (StringUtils.isBlank(issueNumberString))
		throw new RestartResponseException(ProjectIssueListPage.class, ProjectIssueListPage.paramsOf(getProject(), null, 0));
	
	issueModel = new LoadableDetachableModel<Issue>() {

		@Override
		protected Issue load() {
			Long issueNumber = Long.valueOf(issueNumberString);
			Issue issue = OneDev.getInstance(IssueManager.class).find(getProject(), issueNumber);
			if (issue == null)
				throw new EntityNotFoundException("Unable to find issue #" + issueNumber + " in project " + getProject());
			else if (!issue.getProject().equals(getProject()))
				throw new RestartResponseException(getPageClass(), paramsOf(issue));
			else
				return issue;
		}

	};
}
 
Example #17
Source File: MilestoneDetailPage.java    From onedev with MIT License 6 votes vote down vote up
public MilestoneDetailPage(PageParameters params) {
	super(params);
	
	String idString = params.get(PARAM_MILESTONE).toString();
	if (StringUtils.isBlank(idString))
		throw new RestartResponseException(MilestoneListPage.class, MilestoneListPage.paramsOf(getProject(), false, null));
	
	Long milestoneId = Long.valueOf(idString);
	milestoneModel = new LoadableDetachableModel<Milestone>() {

		@Override
		protected Milestone load() {
			return OneDev.getInstance(MilestoneManager.class).load(milestoneId);
		}
		
	};
	
	query = params.get(PARAM_QUERY).toString();
}
 
Example #18
Source File: ConfirmEmailHtmlNotificationDemoPage.java    From artifact-listener with Apache License 2.0 6 votes vote down vote up
public ConfirmEmailHtmlNotificationDemoPage(PageParameters parameters) {
	super(parameters);
	
	User user = userService.getByUserName(ConsoleNotificationIndexPage.DEFAULT_USERNAME);
	EmailAddress emailAddress = null;
	if (user != null) {
		emailAddress = Iterables.getFirst(user.getAdditionalEmails(), null);
	}
	if (user == null || emailAddress == null) {
		LOGGER.error("There is no user or email address available");
		Session.get().error(getString("console.notifications.noDataAvailable"));
		
		throw new RestartResponseException(ConsoleNotificationIndexPage.class);
	}

	if (emailAddress.getEmailHash() == null) {
		emailAddress.setEmailHash(userService.getHash(user, emailAddress.getEmail()));
	}
	
	add(new ConfirmEmailHtmlNotificationPanel("htmlPanel", Model.of(emailAddress)));
}
 
Example #19
Source File: BasePage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Performs role checks for instructor-only pages and redirects users to appropriate pages based on their role.
 * No role -> AccessDeniedPage. Student -> StudentPage. TA -> GradebookPage (if ta does not have the gradebook.editAssignments permission)
 */
protected final void defaultRoleChecksForInstructorOnlyPage()
{
	switch (role)
	{
		case NONE:
			sendToAccessDeniedPage(getString("error.role"));
			break;
		case STUDENT:
			throw new RestartResponseException(StudentPage.class);
		case TA:
			if(businessService.isUserAbleToEditAssessments()) {
				break;
			}
			throw new RestartResponseException(GradebookPage.class);
		default:
			break;
	}
}
 
Example #20
Source File: NewVersionsHtmlNotificationDemoPage.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
public NewVersionsHtmlNotificationDemoPage(PageParameters parameters) {
	super(parameters);
	
	User user = userService.getByUserName(ConsoleNotificationIndexPage.DEFAULT_USERNAME);
	if (user == null) {
		LOGGER.error("There is no user or email address available");
		Session.get().error(getString("console.notifications.noDataAvailable"));
		
		throw new RestartResponseException(ConsoleNotificationIndexPage.class);
	}
	List<ArtifactVersionNotification> notifications = userService.listRecentNotifications(user);
	
	IModel<List<ArtifactVersionNotification>> notificationsModel = new ListModel<ArtifactVersionNotification>(notifications);
	add(new NewVersionsHtmlNotificationPanel("htmlPanel", notificationsModel));
}
 
Example #21
Source File: ChangeProfilePictureUpload.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * This constructor only called if we were a superuser editing someone else's picture.
 * An additional catch is also in place.
 * @param id		component id 
 * @param userUuid	uuid of other user
 */
public ChangeProfilePictureUpload(String id, String userUuid)   {
	super(id);
	log.debug("ChangeProfilePictureUpload(" + userUuid +")");
	
	//double check only super users
	if(!sakaiProxy.isSuperUser()) {
		log.error("ChangeProfilePictureUpload: user " + sakaiProxy.getCurrentUserId() + " attempted to access ChangeProfilePictureUpload for " + userUuid + ". Redirecting...");
		throw new RestartResponseException(new MyProfile());
	}
	//render for given user
	renderChangeProfilePictureUpload(userUuid);
}
 
Example #22
Source File: PageExpiredPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public PageExpiredPage(final PageParameters params)
{
  super(params);
  if (getMySession().isMobileUserAgent() == true) {
    throw new RestartResponseException(MenuMobilePage.class);
  }
  setMessage(getString("message.wicket.pageExpired"));
}
 
Example #23
Source File: LinkUtils.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
public static EmailAddress extractEmailFromHashPageParameter(IEmailAddressService emailAddressService, PageParameters parameters,
		Class<? extends Page> redirectPageClass) {
	String hash = parameters.get(LinkUtils.HASH_PARAMETER).toString();
	EmailAddress emailAddress = emailAddressService.getByHash(hash);

	if (emailAddress == null) {
		LOGGER.error("Unable to get email address from hash");
		MavenArtifactNotifierSession.get().error(
				Application.get().getResourceSettings().getLocalizer().getString("common.error.noItem", null));

		throw new RestartResponseException(redirectPageClass);
	}
	return emailAddress;
}
 
Example #24
Source File: LinkUtils.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
public static User extractUserFromHashPageParameter(IUserService userService, PageParameters parameters,
		Class<? extends Page> redirectPageClass) {
	String hash = parameters.get(LinkUtils.HASH_PARAMETER).toString();
	User user = userService.getByNotificationHash(hash);

	if (user == null) {
		LOGGER.error("Unable to get user from hash");
		MavenArtifactNotifierSession.get().error(
				Application.get().getResourceSettings().getLocalizer().getString("common.error.noItem", null));

		throw new RestartResponseException(redirectPageClass);
	}
	return user;
}
 
Example #25
Source File: ConfirmRegistrationHtmlNotificationDemoPage.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
public ConfirmRegistrationHtmlNotificationDemoPage(PageParameters parameters) {
	super(parameters);

	User user = userService.getByUserName(ConsoleNotificationIndexPage.DEFAULT_USERNAME);
	if (user == null) {
		LOGGER.error("There is no user available");
		Session.get().error(getString("console.notifications.noDataAvailable"));
		
		throw new RestartResponseException(ConsoleNotificationIndexPage.class);
	}
	user.setNotificationHash(userService.getHash(user, user.getUserName()));
	
	add(new ConfirmRegistrationHtmlNotificationPanel("htmlPanel", Model.of(user)));
	user.setNotificationHash(null);
}
 
Example #26
Source File: CheckoutPage.java    From AppStash with Apache License 2.0 5 votes vote down vote up
protected void validateCheckoutPage() {
    try {
        if (checkout.getOrderItemInfos().isEmpty()) {
            getSession().error(getString("checkout.validation.failed"));
            LOGGER.debug("Basket is empty and CheckoutPage could not be created");
            throw new RestartResponseException(Application.get().getHomePage());
        }
    } catch (Exception e) {
        getSession().error("Cart is not available yet, please try again later.");
        LOGGER.error("A backend error seems to be occurred: ", e);
        throw new RestartResponseException(Application.get().getHomePage());
    }
}
 
Example #27
Source File: ChangeProfilePictureUrl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * This constructor is only called if we were a superuser editing someone else's picture.
 * An additional catch is also in place.
 * @param id		component id 
 * @param userUuid	uuid of other user
 */
public ChangeProfilePictureUrl(String id, String userUuid)   {
	super(id);
	log.debug("ChangeProfilePictureUpload(" + userUuid +")");
	
	//double check only super users
	if(!sakaiProxy.isSuperUser()) {
		log.error("ChangeProfilePictureUrl: user " + sakaiProxy.getCurrentUserId() + " attempted to access ChangeProfilePictureUrl for " + userUuid + ". Redirecting...");
		throw new RestartResponseException(new MyProfile());
	}
	//render for given user
	renderChangeProfilePictureUrl(userUuid);
}
 
Example #28
Source File: BasePage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Send a user to the access denied page with a message
 * 
 * @param message the message
 */
public final void sendToAccessDeniedPage(final String message) {
	final PageParameters params = new PageParameters();
	params.add("message", message);
	log.debug("Redirecting to AccessDeniedPage: " + message);
	throw new RestartResponseException(AccessDeniedPage.class, params);
}
 
Example #29
Source File: MyProfile.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * This constructor is called if we are viewing someone elses but in edit mode.
 * This will only be called if we were a superuser editing someone else's profile.
 * An additional catch is also in place.
 * @param userUuid		uuid of other user 
 */
public MyProfile(final String userUuid)   {
	log.debug("MyProfile(" + userUuid +")");
	
	//double check only super users
	if(!sakaiProxy.isSuperUser()) {
		log.error("MyProfile: user " + sakaiProxy.getCurrentUserId() + " attempted to access MyProfile for " + userUuid + ". Redirecting...");
		throw new RestartResponseException(new MyProfile());
	}
	//render for given user
	renderMyProfile(userUuid);
}
 
Example #30
Source File: ChangeProfilePictureUrl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * This constructor is only called if we were a superuser editing someone else's picture.
 * An additional catch is also in place.
 * @param id		component id 
 * @param userUuid	uuid of other user
 */
public ChangeProfilePictureUrl(String id, String userUuid)   {
	super(id);
	log.debug("ChangeProfilePictureUpload(" + userUuid +")");
	
	//double check only super users
	if(!sakaiProxy.isSuperUser()) {
		log.error("ChangeProfilePictureUrl: user " + sakaiProxy.getCurrentUserId() + " attempted to access ChangeProfilePictureUrl for " + userUuid + ". Redirecting...");
		throw new RestartResponseException(new MyProfile());
	}
	//render for given user
	renderChangeProfilePictureUrl(userUuid);
}