Package org.apache.wicket

Examples of org.apache.wicket.RestartResponseException


                    }
                }
               
                // shouldn't return null given that we're in a session ...
                PageProvider errorPageProvider = errorPageProviderFor(ex);
                throw new RestartResponseException(errorPageProvider, RedirectPolicy.ALWAYS_REDIRECT);
            }
        }
    }
View Full Code Here


      {
        // we haven't done the redirect yet; record that we will be
        // doing that now and redirect
        session.setMetaData(BROWSER_WAS_POLLED_KEY, Boolean.TRUE);
        String url = "/" + getRequest().getURL();
        throw new RestartResponseException(newBrowserInfoPage(url));
      }
      // if we get here, the redirect already has been done; clear
      // the meta data entry; we don't need it any longer is the client
      // info object will be cached too
      session.setMetaData(BROWSER_WAS_POLLED_KEY, (Boolean)null);
View Full Code Here

    super(params);

    RepositoryModel model = getRepositoryModel();
    if (!app().tickets().isAcceptingTicketUpdates(model)) {
      // ticket service is read-only
      throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
    }

    UserModel currentUser = GitBlitWebSession.get().getUser();
    if (currentUser == null) {
      currentUser = UserModel.ANONYMOUS;
    }

    if (!currentUser.isAuthenticated || !currentUser.canAdmin(model)) {
      // administration prohibited
      throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
    }

    setStatelessHint(false);
    setOutputMarkupId(true);
View Full Code Here

    long ticketId = Long.parseLong(id);
    ticket = app().tickets().getTicket(repository, ticketId);

    if (ticket == null) {
      // ticket not found
      throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName));
    }

    final List<Change> revisions = new ArrayList<Change>();
    List<Change> comments = new ArrayList<Change>();
    List<Change> statusChanges = new ArrayList<Change>();
View Full Code Here

    super(params);

    RepositoryModel model = getRepositoryModel();
    if (!app().tickets().isAcceptingTicketUpdates(model)) {
      // ticket service is read-only
      throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
    }

    UserModel currentUser = GitBlitWebSession.get().getUser();
    if (currentUser == null) {
      currentUser = UserModel.ANONYMOUS;
    }

    if (!currentUser.isAuthenticated || !currentUser.canAdmin(model)) {
      // administration prohibited
      throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
    }

    oldName = WicketUtils.getObject(params);
    if (StringUtils.isEmpty(oldName)) {
      // milestone not specified
      throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
    }

    TicketMilestone tm = app().tickets().getMilestone(getRepositoryModel(), oldName);
    if (tm == null) {
      // milestone does not exist
      throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName));
    }

    setStatelessHint(false);
    setOutputMarkupId(true);
View Full Code Here

    if (StringUtils.isEmpty(repositoryName)) {
      error(MessageFormat.format(getString("gb.repositoryNotSpecifiedFor"), getPageName()), true);
    }

    if (!getRepositoryModel().hasCommits && getClass() != EmptyRepositoryPage.class) {
      throw new RestartResponseException(EmptyRepositoryPage.class, params);
    }

    if (getRepositoryModel().isCollectingGarbage) {
      error(MessageFormat.format(getString("gb.busyCollectingGarbage"), getRepositoryModel().name), true);
    }
View Full Code Here

  @Override
  public void onUnauthorizedInstantiation(Component component) {

    if (component instanceof BasePage) {
      throw new RestartResponseException(homepageClass);
    }
  }
View Full Code Here

  public ChangePasswordPage() {
    super();

    if (!GitBlitWebSession.get().isLoggedIn()) {
      // Change password requires a login
      throw new RestartResponseException(getApplication().getHomePage());
    }

    if (!app().settings().getBoolean(Keys.web.authenticateAdminPages, true)
        && !app().settings().getBoolean(Keys.web.authenticateViewPages, false)) {
      // no authentication enabled
      throw new RestartResponseException(getApplication().getHomePage());
    }

    UserModel user = GitBlitWebSession.get().getUser();
    if (!app().authentication().supportsCredentialChanges(user)) {
      error(MessageFormat.format(getString("gb.userServiceDoesNotPermitPasswordChanges"),
View Full Code Here

        logger.info("Client ["+ getClientIpAddress() +"] requesting history");
        pasteService.appendIpAddress(getClientIpAddress());

        if(referrer==null) {
            logger.info("History page requested without referer [" + getClientIpAddress() + "]");
            throw new RestartResponseException(HelpPage.class);
        }

        add(new Alert("newFeatureAlert", Model.of("Check out our <a href=\"/help\"><strong>New Features</strong></a> like <code>image upload</code> via clipboard or drag and drop, <code>keyboard shortcuts</code>, and more!")) {
            protected Component createMessage(final String markupId, final IModel<String> message) {
                return new Label(markupId, message).setEscapeModelStrings(false);
View Full Code Here

        for (Cookie cookie : cookies) {
            System.out.println(cookie.getName() + ":" + cookie.getValue());
        }

        if (params.get("0").isNull()) {
            throw new RestartResponseException(PasteNotFound.class);
        }

        String highlightLines = null;
        if (!params.get(0).isEmpty()) {
            String[] lineNumbers = params.get(0).toString().split(",");

            List<String> numbers = new ArrayList<String>();
            for (String lineNumber : lineNumbers) {

                if (lineNumber.matches(justNumberPattern)) {
                    numbers.add(lineNumber);
                } else if (lineNumber.matches(numbersWithRange)) {
                    String[] numberRange = lineNumber.split("-");
                    int startRange = Integer.parseInt(numberRange[0].trim());
                    int endRange = Integer.parseInt(numberRange[1].trim());
                    if (startRange < endRange) {
                        for (int i = startRange; i <= endRange; i++) {
                            numbers.add("" + i);
                        }
                    }
                }
            }

            StringBuilder sb = new StringBuilder();
            for (String number : numbers) {
                sb.append(number).append(",");
            }

            if (sb.length() > 0)
                highlightLines = sb.substring(0, sb.length() - 1);
        }

        // User must have copied just the funny private string rather than the whole bit
        if (params.get("0").isNull() && isPublic()) {
            PageParameters pp = new PageParameters();
            pp.add("0", params.get("0").toString());
            throw new RestartResponseException(ViewPrivatePage.class, pp);
        }

        pasteModel = getPasteModel(params.get("0").toString());
        if (pasteModel.getObject() == null || (pasteModel.getObject().isPrivate() && params.get("0").isNull())) {
            throw new RestartResponseException(PasteNotFound.class);
        }
        if (pasteModel.getObject().getAbuseCount() > 2) {
            throw new RestartResponseException(PasteSpam.class);
        }
        if (pasteModel.getObject().getContent() == null) {
            pasteModel.getObject().setContent("");
        }

        int viewCount = pasteService.incViewCount(pasteModel.getObject());

        this.setDefaultModel(new CompoundPropertyModel<PasteItem>(pasteModel));

        add(new Label("type"));

        WebMarkupContainer spamAlert = new WebMarkupContainer("spamAlert") {
            @Override
            public boolean isVisible() {
                return pasteModel.getObject().getAbuseCount() > 0;
            }
        };
        add(spamAlert);

        WebMarkupContainer hasImage = new WebMarkupContainer("hasImage") {
            @Override
            public boolean isVisible() {
                return pasteModel.getObject().hasImage();

            }
        };
        ExternalLink imageLocationLink = new ExternalLink("imageLocation", new PropertyModel<String>(pasteModel, "imageLocation"));
        hasImage.add(imageLocationLink);
        add(hasImage);

        WebMarkupContainer diffView = new WebMarkupContainer("diffView") {
            @Override
            public boolean isVisible() {
                return pasteModel.getObject().getParent() != null;
            }
        };

        if (pasteModel.getObject().getParent() != null) {
            PasteItem parentPaste = pasteService.getItem(pasteModel.getObject().getParent());
            PageParameters pp = new PageParameters();
            pp.add("0", parentPaste.getItemId());
            diffView.add(new BookmarkablePageLink<Void>("originalPasteLink", (parentPaste.isPrivate() ? ViewPrivatePage.class : ViewPublicPage.class), pp));


            Object[] diffOutput = PasteItem.diffPastes(parentPaste.getContent(), pasteModel.getObject().getContent());

            List<Integer> changedLines = (List<Integer>) diffOutput[0];       // TODO horrible horrible hackish thing, where do you get these things
            String diffText = (String) diffOutput[1];

            diffView.add(new HighlighterPanel("highlightedContent",
                    new Model<String>(diffText),
                    parentPaste.getType(),
                    false,
                    highlightLines,
                    changedLines));
        }
        add(diffView);

        final List<PasteItem> pasteChildren = pasteService.hasChildren(pasteModel.getObject());

//        final List<PasteItem> pasteChildren = new ArrayList<PasteItem>();
        WebMarkupContainer hasChildPastes = new WebMarkupContainer("hasChildPastes") {
            @Override
            public boolean isVisible() {
                return pasteChildren != null && pasteChildren.size() > 0;
            }
        };
        add(hasChildPastes);

        hasChildPastes.add(new ListView<PasteItem>("childPastes", pasteChildren) {

            @Override
            protected void populateItem(ListItem<PasteItem> item) {
                PasteItem pasteItem = item.getModelObject();

                PageParameters pp = new PageParameters();
                pp.add("0", pasteItem.getItemId());
                BookmarkablePageLink<Void> viewPaste = new BookmarkablePageLink<Void>("viewChildPaste", (pasteItem.isPrivate() ? ViewPrivatePage.class : ViewPublicPage.class), pp);

                viewPaste.add(new Label("pasteId", new PropertyModel<String>(item.getModel(), "itemId")));

                item.add(viewPaste);

                item.add(new Label("posted", PasteItem.getElapsedTimeSincePost(pasteItem)));
            }
        });

        String language = pasteModel.getObject().getType();
        add(new HighlighterPanel("highlightedContent",
                new PropertyModel<String>(pasteModel, "content"),
                language, false,
                highlightLines));

        add(createRawLink("rawLink", params));
        add(createDownloadLink("downloadLink", params));

        PageParameters repasteParams = new PageParameters();
        repasteParams.add("0", pasteModel.getObject().getItemId());
        add(new BookmarkablePageLink<Void>("repasteLink", ReplyPastePage.class, repasteParams));

        final Label markAbuseLabel = new Label("markAbuseLabel", "Report Abuse");
        markAbuseLabel.setOutputMarkupId(true);
        StatelessLink markAbuseLink = new StatelessLink("markAbuseLink") {

            public void onClick() {
                PasteItem pasteItem = pasteModel.getObject();

                pasteService.increaseAbuseCount(pasteItem);

                markAbuseLabel.setDefaultModel(new Model<String>("Marked As Spam"));
                markAbuseLabel.add(new AttributeModifier("style", "color: red; font-weight: bold;"));
            }
        };
//        add(markAbuseLink);
        markAbuseLink.add(markAbuseLabel);

        WebMarkupContainer viewCountContainer = new WebMarkupContainer("viewCountContainer") {
            @Override
            public boolean isVisible() {
                return pasteModel.getObject().getViewCount() > 0;
            }
        };
        viewCountContainer.add(new Label("viewCount", new PropertyModel<Integer>(pasteModel, "viewCount")));
        add(viewCountContainer);


        final AbstractDefaultAjaxBehavior repasteKeyBehavior = new AbstractDefaultAjaxBehavior() {
            @Override
            protected void respond(AjaxRequestTarget target) {
                PageParameters repasteParams = new PageParameters();
                repasteParams.add("0", pasteModel.getObject().getItemId());
                throw new RestartResponseException(ReplyPastePage.class, repasteParams);
            }
        };
        add(repasteKeyBehavior);

        mousetrap().addBind(new KeyBinding().addKeyCombo("r").addKeyCombo("R"),
View Full Code Here

TOP

Related Classes of org.apache.wicket.RestartResponseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.