public String doDefault() {
    // When starting the wizard make sure we are not using any old sessions
    resetSelectedSchemeIds();
    ActionContext.getSession().remove(AbstractGroupToRoleAction.GROUP_TO_ROLE_MAP_SESSION_KEY);
    ActionContext.getSession().remove(AbstractGroupToRoleAction.TRANSFORM_RESULTS_KEY);

    return super.doDefault();
  }
 public ConfigurePortalPages(
     final PortalPageService portalPageService,
     final JiraAuthenticationContext authenticationContext,
     final EmailFormatter emailFormatter,
     final GroupPermissionChecker groupPermissionChecker,
     final FavouritesService favouritesService,
     final PermissionManager permissionManager,
     final ShareTypeFactory shareTypeFactory,
     final UserFormatManager userFormatManager,
     final WebResourceManager webResourceManager,
     final UserHistoryManager userHistoryManager) {
   this.portalPageService = portalPageService;
   this.authenticationContext = authenticationContext;
   this.emailFormatter = emailFormatter;
   this.groupPermissionChecker = groupPermissionChecker;
   this.favouritesService = favouritesService;
   this.permissionManager = permissionManager;
   this.shareTypeFactory = shareTypeFactory;
   this.userFormatManager = userFormatManager;
   this.webResourceManager = webResourceManager;
   this.portalPageRetriever =
       new PortalPageRetriever(portalPageService, userHistoryManager, authenticationContext);
   this.portalPageViewHelper =
       new PortalPageViewHelper(
           this.shareTypeFactory,
           this.authenticationContext,
           ActionContext.getRequest().getContextPath(),
           "ConfigurePortalPages!default.jspa",
           portalPageService);
 }
 /**
  * Starts the workflow specified in the request parameter "workflowName" with the initial action
  * identified by the request parameter "actionId" and redirects to the view page for the desired
  * initial action. If no actionId is passed in the request, we assume that the ID of the initial
  * action is zero.
  *
  * @return Action.NONE if the desired initial action has a view, otherwise the effect is the same
  *     as calling doExecute()
  * @throws SystemException
  * @see #doExecute
  */
 public String doStartWorkflow() throws SystemException {
   workflow =
       controller.initializeWorkflow(
           getInfoGluePrincipal(),
           getWorkflowName(),
           actionId,
           WorkflowController.createWorkflowParameters(ActionContext.getRequest()));
   return redirectToView();
 }
 private void initTabsWithErrors() {
   tabsWithErrors = new TreeSet<FieldScreenRenderTab>();
   selectedTab =
       new ScreenTabErrorHelper()
           .initialiseTabsWithErrors(
               tabsWithErrors,
               getErrors(),
               getFieldScreenRenderer(),
               ActionContext.getParameters());
 }
 @Override
 public String render(Long id, String name) {
   return "<a href=\""
       + ActionContext.getRequest().getContextPath()
       + "/secure/Dashboard.jspa?selectPageId="
       + id
       + "\">"
       + TextUtils.htmlEncode(name)
       + "</a>";
 }
  protected void tearDown() throws Exception {
    user = null;
    secondaryUser = null;
    sr = null;

    ActionContext.getSession().clear();
    ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(null);
    PermissionManager pm = ManagerFactory.getPermissionManager();
    pm.removeGroupPermissions("jira-user");
    ImportUtils.setSubvertSecurityScheme(false);
    super.tearDown();
  }
  @Override
  public String execute() throws Exception {

    HttpServletRequest req = ActionContext.getRequest();
    String productId = req.getParameter("productId");
    String parentId = req.getParameter("parentID");
    String pkey = req.getParameter("projectKey");
    Product product;

    if (!StringUtils.isEmpty(req.getParameter("name"))
        && !StringUtils.isEmpty(req.getParameter("version"))
        && !StringUtils.isEmpty(req.getParameter("description"))) {

      // edit
      if (Integer.parseInt(productId) > 0) {

        product = productService.getProductById(Integer.parseInt(productId));
        product.setName(req.getParameter("name"));
        product.setVersion(req.getParameter("version"));
        product.setDescription(req.getParameter("description"));
        product.save();

        // create a leaf/branch node
      } else if (Integer.parseInt(productId) == 0 && !StringUtils.isEmpty(parentId)) {

        productService.add(
            req.getParameter("name"),
            req.getParameter("version"),
            req.getParameter("description"),
            Integer.parseInt(parentId));
      }
    } else {

      // remove case
      productService.delete(Integer.parseInt(productId));
    }

    return getRedirect(
        "/browse/"
            + pkey
            + "/?selectedTab=com.transcendmanagement.jira.plugin.jira-project-templates-plugin:my.project.product.tabpanel",
        true);
  }
 public String getDashboardHtml() {
   final DashboardState state =
       dashboardService.get(DashboardId.valueOf(defaultPortalPageId.toString()), getUsername());
   final GadgetRequestContext requestContext =
       gadgetRequestContextFactory.get(ActionContext.getRequest());
   final ViewComponent view =
       dashboardTabViewFactory.createDashboardView(
           Collections.<DashboardTab>emptyList(),
           state,
           getUsername(),
           DashboardUtil.getMaxGadgets(applicationProperties),
           requestContext);
   final StringWriter out = new StringWriter();
   try {
     view.writeTo(out);
     return out.toString();
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
 private void afterExecutionImpl(final String sqlString) {
   if (JiraSystemProperties.getInstance().isXsrfDiagnostics()) {
     final String requestURL = MDC.get("jira.request.url");
     if (isMutatingSQL(sqlString)) {
       HttpServletRequest request = ActionContext.getRequest();
       if (request != null
           && request.getAttribute(XSRF_VULNERABILITY_DETECTION_SQLINTERCEPTOR_DONE) == null) {
         // setting this into the request will make things a lot faster
         request.setAttribute(XSRF_VULNERABILITY_DETECTION_SQLINTERCEPTOR_DONE, "true");
         CallStack callStack = new CallStack();
         if (callStack.hasMethodsWeAreInterestedIn() && !callStack.isProtectedAction()) {
           log.error("XSRF VULNERABILITY DETECTED");
           log.error("requestURL: " + requestURL);
           log.error("sql: " + sqlString);
           log.error("CallStack:", callStack);
         }
       }
     }
   }
 }
  /**
   * Invokes an action in a workflow based on the values of the actionId and workflowId request
   * parameters and redirects to the action's view if one has been defined. If there is no action
   * view, the user will be taken to ViewMyDesktopToolStartPage.action, i.e., the effect is the same
   * as calling doExecute(). <b>NOTE:</b> Assumes there will be one current action with a view; we
   * iterate over the available actions until we find one with a view, then redirect to that view.
   * If there are other actions with different views, they will be ignored.
   *
   * @return NONE if there is an available action with a view and we redirect to the action's view
   *     page, otherwise performs the same operations as doExecute().
   * @throws SystemException if an error occurs invoking the action or URL-encoding the action view
   * @see #doExecute
   */
  public String doInvoke() throws SystemException {
    logger.info("****************************************");
    logger.info("workflowId:" + getWorkflowId());
    logger.info("actionId:" + actionId);
    logger.info("****************************************");

    try {
      if (this.finalReturnAddress != null && !this.finalReturnAddress.equals("")) {
        logger.info("Final return address get's set to " + this.finalReturnAddress);
        controller
            .getPropertySet(getInfoGluePrincipal(), getWorkflowId())
            .setString("finalReturnAddress", this.finalReturnAddress);
      } else {
        String finalReturnAddressCandidate =
            controller
                .getPropertySet(getInfoGluePrincipal(), getWorkflowId())
                .getString("finalReturnAddress");
        logger.info("finalReturnAddressCandidate " + finalReturnAddressCandidate);
        if (finalReturnAddressCandidate != null && !finalReturnAddressCandidate.equals("")) {
          this.finalReturnAddress = finalReturnAddressCandidate;
          logger.info(
              "Setting Final return address get's set to "
                  + this.finalReturnAddress
                  + " from properties..");
        }
      }

      workflow =
          controller.invokeAction(
              getInfoGluePrincipal(),
              getWorkflowId(),
              actionId,
              WorkflowController.createWorkflowParameters(ActionContext.getRequest()));
      return redirectToView();
    } catch (InvalidActionException e) {
      logger.error("An error occurred when invoking an action:" + e.getMessage(), e);
      return INVALID_ACTION;
    } catch (WorkflowException e) {
      throw new SystemException(e);
    }
  }
  protected void doValidation() {
    try {
      // just checking that the issue exists and that the user has permission to see it.
      getIssue();
    } catch (IssuePermissionException ipe) {
      return;
    } catch (IssueNotFoundException infe) {
      return;
    }

    final IssueInputParameters issueInputParameters =
        new IssueInputParametersImpl(ActionContext.getParameters());
    issueInputParameters.setRetainExistingValuesWhenParameterNotProvided(false);
    transitionResult =
        issueService.validateTransition(
            getRemoteUser(), getIssueObject().getId(), action, issueInputParameters);
    setFieldValuesHolder(transitionResult.getFieldValuesHolder());
    if (!transitionResult.isValid()) {
      addErrorCollection(transitionResult.getErrorCollection());
    }
  }
Exemplo n.º 12
0
 @SuppressWarnings("unchecked")
 public static void storeToSession(final BulkEditBean bulkEditBean) {
   ActionContext.getSession().put(SessionKeys.BULKEDITBEAN, bulkEditBean);
 }
Exemplo n.º 13
0
  public String doExecute() // throws Exception
      {
    try {
      MultiPartRequestWrapper mpr = ActionContext.getMultiPartRequest();
      if (mpr == null) {
        return "input";
      }

      log.debug("Handling upload...");
      Enumeration names = mpr.getFileNames();
      if (names.hasMoreElements()) {
        String name = (String) names.nextElement();
        log.debug("name:" + name);
        File uploadedFile = mpr.getFile(name);
        if (uploadedFile == null || uploadedFile.length() == 0) {
          log.error("No file found in multipart request");
          return "input";
        }

        String contentType = mpr.getContentType(name);
        String fileName = mpr.getFilesystemName(name);
        String filePath = CmsPropertyHandler.getDigitalAssetPath();
        log.debug("fileName:" + fileName);

        // Pluto prepare portlet-war
        String appName = fileName;
        int dot = appName.lastIndexOf(".");
        if (dot > 0) {
          appName = appName.substring(0, dot);
        }

        log.info("appName:" + appName);

        // Create file where Deployer will write updated
        // (pluto-prepared) .war
        File file = new File(uploadedFile.getParentFile(), "tmp" + System.currentTimeMillis());
        log.info("file:" + file.getAbsolutePath());
        PortletApplicationDefinition pad = Deploy.prepareArchive(uploadedFile, file, appName);

        // Extract portlet application information to be added to
        // portlet entity registry
        log.info("Adding portlet application to registry: " + appName);
        PortletApplicationEntityImpl pae = new PortletApplicationEntityImpl();
        pae.setId(appName);

        PortletDefinitionList pdl = pad.getPortletDefinitionList();
        for (Iterator it = pdl.iterator(); it.hasNext(); ) {
          PortletDefinition pd = (PortletDefinition) it.next();
          log.debug("Adding portlet: " + pd.getName());
          PortletEntityImpl pe = new PortletEntityImpl();
          pe.setId(pd.getName());

          // Copy preferences
          ArrayList destPrefs = new ArrayList();
          PreferenceSet prefSet = pd.getPreferenceSet();
          for (Iterator prefs = prefSet.iterator(); prefs.hasNext(); ) {
            Preference src = (Preference) prefs.next();
            ArrayList destValues = new ArrayList();
            for (Iterator values = src.getValues(); values.hasNext(); ) {
              destValues.add(values.next());
            }
            destPrefs.add(new PreferenceImpl(src.getName(), destValues));
          }
          pe.setPreferenceSet(new PreferenceSetImpl(destPrefs));
          pae.addPortletEntity(pe);
        }

        // Create Digital Asset
        log.debug("Creating Digital Asset...");
        DigitalAssetVO newAsset = new DigitalAssetVO();
        newAsset.setAssetContentType(contentType);
        newAsset.setAssetKey(fileName);
        newAsset.setAssetFileName(fileName);
        newAsset.setAssetFilePath(filePath);
        newAsset.setAssetFileSize(new Integer(new Long(file.length()).intValue()));

        // Check existance of portlet and remove old ones
        List assets = PortletAssetController.getDigitalAssetByName(fileName);
        if (assets != null && assets.size() > 0) {
          log.info("Removing old instance of " + fileName);
          for (Iterator it = assets.iterator(); it.hasNext(); ) {
            DigitalAsset oldAsset = (DigitalAsset) it.next();
            PortletAssetController.delete(oldAsset.getId());
          }
        }

        log.info("Storing Digital Asset (portlet) " + fileName);
        InputStream is = new FileInputStream(file);
        digitalAsset = PortletAssetController.create(newAsset, is);
        is.close();
        log.debug("Digital Asset stored as id=" + digitalAsset.getId());

        // Cleanup
        uploadedFile.delete();
        file.delete();

        // Add the new application to portlet registry
        // Update persisted portlet registry
        // TODO check existance first?
        PortletApplicationEntityList pael = PortletEntityRegistry.getPortletApplicationEntityList();
        if (pael instanceof PortletApplicationEntityListImpl) {
          ((PortletApplicationEntityListImpl) pael).add(pae);
          log.debug("Portlet application successfully added to registry");
        } else {
          log.error(
              "Unknown implementation of PortletApplicationEntityList, "
                  + "cannot add portlet application!");
          return "error";
        }
        PortletEntityRegistry.store();

        // Refresh deliver-engines
        updateDeliverEngines(digitalAsset.getId());
      } else {
        throw new SystemException("No file was uploaded...");
      }
    } catch (Throwable e) {
      log.error("ERROR", e);
      return "error";
    }

    return "success";
  }
Exemplo n.º 14
0
 public static void removeFromSession() {
   ActionContext.getSession().remove(SessionKeys.BULKEDITBEAN);
 }
Exemplo n.º 15
0
 // This is taken out as a protected method such that it can be overridden, and the doValidation()
 // method reused by subclass actions
 protected void populateFromParams(OrderableField orderableField) {
   orderableField.populateFromParams(
       getBulkEditBean().getFieldValuesHolder(), ActionContext.getParameters());
 }
 // JRADEV-2637 Make sure the Delete Dashboard gets redirected to /secure/Dashboard.jspa
 public String getTargetUrl() {
   return ActionContext.getRequest().getContextPath() + "/secure/Dashboard.jspa";
 }
 private String getTabFromSession() {
   return (String) ActionContext.getSession().get(SessionKeys.CONFIGURE_PORTAL_PAGES_TAB);
 }
 private void storeTabInSession(final String view) {
   //noinspection unchecked
   ActionContext.getSession().put(SessionKeys.CONFIGURE_PORTAL_PAGES_TAB, view);
 }
Exemplo n.º 19
0
 public static BulkEditBean getFromSession() {
   return (BulkEditBean) ActionContext.getSession().get(SessionKeys.BULKEDITBEAN);
 }
 public boolean isSearchRequested() {
   return ActionContext.getParameters().get("Search") != null;
 }