protected void redirectUpdateAccount(
      HttpServletRequest request, HttpServletResponse response, User user) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    PortletURL portletURL =
        PortletURLFactoryUtil.create(
            request, PortletKeys.LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

    portletURL.setParameter("saveLastPath", Boolean.FALSE.toString());
    portletURL.setParameter("struts_action", "/login/update_account");

    PortletURL redirectURL =
        PortletURLFactoryUtil.create(
            request, PortletKeys.FAST_LOGIN, themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

    redirectURL.setParameter("struts_action", "/login/login_redirect");
    redirectURL.setParameter("emailAddress", user.getEmailAddress());
    redirectURL.setParameter("anonymousUser", Boolean.FALSE.toString());
    redirectURL.setPortletMode(PortletMode.VIEW);
    redirectURL.setWindowState(LiferayWindowState.POP_UP);

    portletURL.setParameter("redirect", redirectURL.toString());
    portletURL.setParameter("userId", String.valueOf(user.getUserId()));
    portletURL.setParameter("emailAddress", user.getEmailAddress());
    portletURL.setParameter("firstName", user.getFirstName());
    portletURL.setParameter("lastName", user.getLastName());
    portletURL.setPortletMode(PortletMode.VIEW);
    portletURL.setWindowState(LiferayWindowState.POP_UP);

    response.sendRedirect(portletURL.toString());
  }
Example #2
0
  /**
   * 根据角色获取 权限字符串 如sys:admin
   *
   * @param user
   * @return
   */
  public Set<String> findStringPermissions(User user) {
    Set<String> permissions = Sets.newHashSet();

    Set<Role> roles = ((UserAuthService) AopContext.currentProxy()).findRoles(user);
    for (Role role : roles) {
      for (RoleResourcePermission rrp : role.getResourcePermissions()) {
        Resource resource = resourceService.findOne(rrp.getResourceId());

        String actualResourceIdentity = resourceService.findActualResourceIdentity(resource);

        // 不可用 即没查到 或者标识字符串不存在
        if (resource == null
            || StringUtils.isEmpty(actualResourceIdentity)
            || Boolean.FALSE.equals(resource.getShow())) {
          continue;
        }

        for (Long permissionId : rrp.getPermissionIds()) {
          Permission permission = permissionService.findOne(permissionId);

          // 不可用
          if (permission == null || Boolean.FALSE.equals(permission.getShow())) {
            continue;
          }
          permissions.add(actualResourceIdentity + ":" + permission.getPermission());
        }
      }
    }

    return permissions;
  }
  @Override
  public void updatePortletPreferences(
      PortletPreferences portletPreferences,
      String portletId,
      String className,
      long classPK,
      ThemeDisplay themeDisplay)
      throws Exception {

    portletPreferences.setValue("displayStyle", "full-content");
    portletPreferences.setValue("emailAssetEntryAddedEnabled", Boolean.FALSE.toString());
    portletPreferences.setValue("selectionStyle", "manual");
    portletPreferences.setValue("showAddContentButton", Boolean.FALSE.toString());
    portletPreferences.setValue("showAssetTitle", Boolean.FALSE.toString());
    portletPreferences.setValue("showExtraInfo", Boolean.FALSE.toString());

    AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(className, classPK);

    AssetPublisherUtil.addSelection(
        themeDisplay,
        portletPreferences,
        portletId,
        assetEntry.getEntryId(),
        -1,
        assetEntry.getClassName());
  }
  protected void addDueDateReference(Form form, String formSet, boolean writable) {
    String fieldName = null;
    if (form.isStartForm()) {
      fieldName = AlfrescoConversionConstants.PROPERTY_WORKFLOW_DUE_DATE;
    } else {
      fieldName = AlfrescoConversionConstants.PROPERTY_DUE_DATE;
    }

    form.getFormFieldVisibility().addShowFieldElement(fieldName);

    FormField formField =
        form.getFormAppearance()
            .addFormField(
                fieldName, AlfrescoConversionConstants.FORM_WORKFLOW_DUE_DATE_LABEL, formSet);
    if (form.isStartForm() || writable) {
      formField.setControl(new FormFieldControl(AlfrescoConversionConstants.FORM_DATE_TEMPLATE));
      formField
          .getControl()
          .getControlParameters()
          .add(
              new FormFieldControlParameter(
                  AlfrescoConversionConstants.FORM_DATE_PARAM_SHOW_TIME, Boolean.FALSE.toString()));
      formField
          .getControl()
          .getControlParameters()
          .add(
              new FormFieldControlParameter(
                  AlfrescoConversionConstants.FORM_DATE_PARAM_SUBMIT_TIME,
                  Boolean.FALSE.toString()));
    } else {
      formField.setControl(
          new FormFieldControl(AlfrescoConversionConstants.FORM_READONLY_TEMPLATE));
    }
    form.getFormAppearance().addFormAppearanceElement(formField);
  }
Example #5
0
 @Override
 public String getFirst(Map flags, String... keys) {
   for (String k : keys) {
     if (k != null && containsKey(k)) return (String) get(k);
   }
   if (flags.get("warnIfNone") != null && !Boolean.FALSE.equals(flags.get("warnIfNone"))) {
     if (Boolean.TRUE.equals(flags.get("warnIfNone")))
       LOG.warn("Unable to find Brooklyn property " + keys);
     else LOG.warn("" + flags.get("warnIfNone"));
   }
   if (flags.get("failIfNone") != null && !Boolean.FALSE.equals(flags.get("failIfNone"))) {
     Object f = flags.get("failIfNone");
     if (f instanceof Closure) ((Closure) f).call((Object[]) keys);
     if (Boolean.TRUE.equals(f))
       throw new NoSuchElementException(
           "Brooklyn unable to find mandatory property "
               + keys[0]
               + (keys.length > 1
                   ? " (or "
                       + (keys.length - 1)
                       + " other possible names, full list is "
                       + Arrays.asList(keys)
                       + ")"
                   : ""));
     else throw new NoSuchElementException("" + f);
   }
   if (flags.get("defaultIfNone") != null) {
     return (String) flags.get("defaultIfNone");
   }
   return null;
 }
  public static Document getDocument(final IEmailConfiguration emailConfiguration) {
    final Document document = DocumentHelper.createDocument();
    document.addElement(ROOT_ELEMENT);
    setValue(document, SMTP_HOST_XPATH, ObjectUtils.toString(emailConfiguration.getSmtpHost()));
    setValue(document, SMTP_PORT_XPATH, ObjectUtils.toString(emailConfiguration.getSmtpPort()));
    setValue(
        document, SMTP_PROTOCOL_XPATH, ObjectUtils.toString(emailConfiguration.getSmtpProtocol()));
    setValue(
        document,
        USE_START_TLS_XPATH,
        ObjectUtils.toString(emailConfiguration.isUseStartTls(), Boolean.FALSE.toString()));
    setValue(
        document,
        AUTHENTICATE_XPATH,
        ObjectUtils.toString(emailConfiguration.isAuthenticate(), Boolean.FALSE.toString()));
    setValue(
        document,
        USE_SSL_XPATH,
        ObjectUtils.toString(emailConfiguration.isUseSsl(), Boolean.FALSE.toString()));
    setValue(
        document,
        DEBUG_XPATH,
        ObjectUtils.toString(emailConfiguration.isDebug(), Boolean.FALSE.toString()));
    setValue(
        document,
        SMTP_QUIT_WAIT_XPATH,
        ObjectUtils.toString(emailConfiguration.isSmtpQuitWait(), Boolean.FALSE.toString()));

    setValue(
        document, DEFAULT_FROM_XPATH, ObjectUtils.toString(emailConfiguration.getDefaultFrom()));
    setValue(document, FROM_NAME_XPATH, ObjectUtils.toString(emailConfiguration.getFromName()));
    setValue(document, USER_ID_XPATH, ObjectUtils.toString(emailConfiguration.getUserId()));
    setValue(document, PASSWORD_XPATH, ObjectUtils.toString(emailConfiguration.getPassword()));
    return document;
  }
  /**
   * Queries the defined tag-descriptions whether the given tag and namespace is defined to allow
   * character-data.
   *
   * @param namespace the namespace.
   * @param tagname the xml-tagname.
   * @return true, if the element may contain character data, false otherwise.
   */
  public boolean hasCData(String namespace, final String tagname) {
    if (tagname == null) {
      throw new NullPointerException();
    }

    if (namespace == null) {
      namespace = defaultNamespace;
    }

    if (tagData.isEmpty() == false) {
      lookupKey.update(namespace, tagname);
      final Object tagVal = tagData.get(lookupKey);
      if (tagVal != null) {
        return Boolean.FALSE.equals(tagVal) == false;
      }
    }

    if (defaultDefinitions.isEmpty()) {
      return true;
    }

    final Object obj = defaultDefinitions.get(namespace);
    if (obj != null) {
      return Boolean.FALSE.equals(obj) == false;
    }

    final Object defaultValue = defaultDefinitions.get(null);
    return Boolean.FALSE.equals(defaultValue) == false;
  }
  /** {@inheritDoc} */
  public TreeNode wrap(final Group theObjectSource) throws ESCOWrapperException {

    TreeNode treeGroup = new TreeNode();
    Attributes attributes = new Attributes();

    attributes.setId(theObjectSource.getIdGroup());
    attributes.setName(theObjectSource.getName());
    attributes.setDisplayName(theObjectSource.getDisplayName());
    attributes.setType(TreeGroupWrapper.GROUP);
    attributes.setRight(theObjectSource.getUserRight().getName());
    if (theObjectSource.isCanOptin()) {
      attributes.setOptin(Boolean.TRUE.toString());
    } else {
      attributes.setOptin(Boolean.FALSE.toString());
    }
    if (theObjectSource.isCanOptout()) {
      attributes.setOptout(Boolean.TRUE.toString());
    } else {
      attributes.setOptout(Boolean.FALSE.toString());
    }

    treeGroup.setAttributes(attributes);
    treeGroup.setData(this.getViewDataFormatted(theObjectSource));
    treeGroup.setState("");

    return treeGroup;
  }
Example #9
0
 private void makeArr() {
   arr = new String[MAX_ELEM];
   for (int i = 0; i < arr.length; ++i) {
     arr[i] = "";
   }
   arr[DOWNLOAD_ZURUECKGESTELLT_NR] = Boolean.FALSE.toString();
   arr[DOWNLOAD_UNTERBROCHEN_NR] = Boolean.FALSE.toString();
 }
  public void testExecuteRefresh() throws Exception {

    addRequestParameter(RhnAction.SUBMITTED, Boolean.FALSE.toString());
    addRequestParameter(RestartAction.RESTART, Boolean.FALSE.toString());
    addRequestParameter(RestartAction.RESTARTED, Boolean.TRUE.toString());
    actionPerform();
    verifyActionMessages(new String[] {"restart.config.restarted"});
  }
  public void testExecuteSubmitFalse() throws Exception {

    addRequestParameter(RhnAction.SUBMITTED, Boolean.TRUE.toString());
    addRequestParameter(RestartAction.RESTART, Boolean.FALSE.toString());
    actionPerform();
    verifyActionMessages(new String[] {"restart.config.norestart"});
    assertTrue((request.getParameter(RestartAction.RESTART).equals(Boolean.FALSE.toString())));
  }
Example #12
0
  @Override
  public PortletURL getViewContentURL(HttpServletRequest request, String className, long classPK)
      throws PortalException {

    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    if (!themeDisplay.isSignedIn()
        || !isTrashEnabled(themeDisplay.getScopeGroupId())
        || !PortletPermissionUtil.hasControlPanelAccessPermission(
            themeDisplay.getPermissionChecker(),
            themeDisplay.getScopeGroupId(),
            PortletKeys.TRASH)) {

      return null;
    }

    TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);

    if (trashHandler.isInTrashContainer(classPK)) {
      TrashEntry trashEntry = trashHandler.getTrashEntry(classPK);

      className = trashEntry.getClassName();
      classPK = trashEntry.getClassPK();

      trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);
    }

    TrashRenderer trashRenderer = trashHandler.getTrashRenderer(classPK);

    if (trashRenderer == null) {
      return null;
    }

    Layout layout = themeDisplay.getLayout();

    PortletURL portletURL =
        PortalUtil.getControlPanelPortletURL(
            request, PortletKeys.TRASH, layout.getLayoutId(), PortletRequest.RENDER_PHASE);

    portletURL.setParameter("struts_action", "/trash/view_content");
    portletURL.setParameter("redirect", themeDisplay.getURLCurrent());

    TrashEntry trashEntry = TrashEntryLocalServiceUtil.getEntry(className, classPK);

    if (trashEntry.getRootEntry() != null) {
      portletURL.setParameter("className", className);
      portletURL.setParameter("classPK", String.valueOf(classPK));
    } else {
      portletURL.setParameter("trashEntryId", String.valueOf(trashEntry.getEntryId()));
    }

    portletURL.setParameter("type", trashRenderer.getType());
    portletURL.setParameter("showActions", Boolean.FALSE.toString());
    portletURL.setParameter("showAssetMetadata", Boolean.TRUE.toString());
    portletURL.setParameter("showEditURL", Boolean.FALSE.toString());

    return portletURL;
  }
Example #13
0
 public MemoryProfile() {
   setParameter(Profile.IMTP, MemoryIMTPManager.class.getName());
   setParameter(Profile.NO_MTP, Boolean.TRUE.toString());
   setParameter(Profile.DETECT_MAIN, Boolean.FALSE.toString());
   setParameter(Profile.LOCAL_SERVICE_MANAGER, Boolean.FALSE.toString());
   setParameter(Profile.NO_DISPLAY, Boolean.TRUE.toString());
   setSpecifiers(Profile.MTPS, new ArrayList(0));
   setParameter(Profile.MTPS, null);
 }
Example #14
0
 @ResponseBody
 @RequiresPermissions("role:edit")
 @RequestMapping(value = "validate")
 public String checkLoginName(String name) {
   if (StringUtils.isNotBlank(name)) {
     Role role = roleServcie.findRoleByName(name);
     return role == null ? Boolean.TRUE.toString() : Boolean.FALSE.toString();
   }
   return Boolean.FALSE.toString();
 }
Example #15
0
  public String getViewContentURL(String className, long classPK, ThemeDisplay themeDisplay)
      throws PortalException, SystemException {

    if (!themeDisplay.isSignedIn()
        || !isTrashEnabled(themeDisplay.getScopeGroupId())
        || !PortletPermissionUtil.hasControlPanelAccessPermission(
            themeDisplay.getPermissionChecker(),
            themeDisplay.getScopeGroupId(),
            PortletKeys.TRASH)) {

      return null;
    }

    TrashHandler trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);

    if (trashHandler.isInTrashContainer(classPK)) {
      ContainerModel containerModel = trashHandler.getTrashContainer(classPK);

      className = containerModel.getModelClassName();
      classPK = containerModel.getContainerModelId();

      trashHandler = TrashHandlerRegistryUtil.getTrashHandler(className);
    }

    TrashRenderer trashRenderer = trashHandler.getTrashRenderer(classPK);

    if (trashRenderer == null) {
      return null;
    }

    String namespace = PortalUtil.getPortletNamespace(PortletKeys.TRASH);

    Map<String, String[]> params = new HashMap<String, String[]>();

    params.put(namespace + "struts_action", new String[] {"/trash/view_content"});
    params.put(namespace + "redirect", new String[] {themeDisplay.getURLCurrent()});

    TrashEntry trashEntry = TrashEntryLocalServiceUtil.getEntry(className, classPK);

    if (trashEntry.getRootEntry() != null) {
      params.put(namespace + "className", new String[] {className});
      params.put(namespace + "classPK", new String[] {String.valueOf(classPK)});
    } else {
      params.put(
          namespace + "trashEntryId", new String[] {String.valueOf(trashEntry.getEntryId())});
    }

    params.put(namespace + "type", new String[] {trashRenderer.getType()});
    params.put(namespace + "showActions", new String[] {Boolean.FALSE.toString()});
    params.put(namespace + "showAssetMetadata", new String[] {Boolean.TRUE.toString()});
    params.put(namespace + "showEditURL", new String[] {Boolean.FALSE.toString()});

    return PortalUtil.getControlPanelFullURL(
        themeDisplay.getScopeGroupId(), PortletKeys.TRASH, params);
  }
  @Override
  public HashMap<String, String> getInitValues() {

    final HashMap<String, String> map = new HashMap<String, String>();
    map.put(RESULTS_FOLDER, System.getProperty("user.home"));
    map.put(MODIFY_NAMES, Boolean.FALSE.toString());
    map.put(USE_INTERNAL_NAMES, Boolean.FALSE.toString());
    map.put(DEFAULT_NO_DATA_VALUE, "-99999");

    return map;
  }
Example #17
0
  /**
   * Delete.
   *
   * @param urlString the url string
   * @param user the user
   * @param pass the pass
   * @param isResultString
   * @return true, if successful
   * @throws IOException
   */
  private static String delete(
      String urlString, String user, String pass, boolean robustMode, boolean isResultString) {
    HttpURLConnection uc = null;
    try {
      uc =
          (HttpURLConnection) openConnection(urlString, user, pass, DELETE, null, null, robustMode);
      if (uc == null) return Boolean.FALSE.toString();
    } catch (MalformedURLException e) {
      e.printStackTrace();
      return Boolean.FALSE.toString();
    } catch (IOException e) {
      e.printStackTrace();
      return Boolean.FALSE.toString();
    }

    //
    //
    //        System.err.println("content enc: " + uc.getContentEncoding());
    //        System.err.println("con type: " + uc.getContentType());
    //        System.err.println("con length: " + uc.getContentLength());
    //
    //        System.err.println("req method: " + uc.getRequestMethod());
    //        System.err.println("head fileds: " + uc.getHeaderFields());
    //        System.err.println("do input: " + uc.getDoInput());
    //        System.err.println("do output: " + uc.getDoOutput());
    //        try {
    //            System.err.println("content: " + uc.getContent());
    //
    //        } catch (IOException e1) {
    //            // TODO Auto-generated method stub
    //            e1.printStackTrace();
    //
    //        }
    //        try {
    //            System.err.println("resp message: " + uc.getResponseMessage());
    //        } catch (IOException e1) {
    //            // TODO Auto-generated method stub
    //            e1.printStackTrace();
    //
    //        }
    //
    //

    if (isResultString) {
      try {
        return convertStreamToString(uc.getInputStream());
      } catch (IOException e) {
        LOGGER.error("The convert from InputStream to String failed: " + e.getMessage());
        return Boolean.FALSE.toString();
      }
    } else {
      return Boolean.TRUE.toString();
    }
  }
Example #18
0
 /**
  * Call this to transform a system setting to a more appropriate value. Importantly, this
  * (de)obfuscates the password fields as they go from and to the DB. We use the @{link
  * PicketBoxObfuscator} so that people are able encode their passwords in the system settings
  * export files using the "rhq-encode-password.sh" script.
  */
 private String transformSystemConfigurationPropertyFromDb(
     SystemSetting prop, String value, boolean unobfuscate) {
   // to support Oracle (whose booleans may be 1 or 0) transform the boolean settings properly
   switch (prop) {
     case LDAP_BASED_JAAS_PROVIDER:
       if (RHQConstants.JDBCJAASProvider.equals(value)) {
         return Boolean.toString(false);
       } else if (RHQConstants.LDAPJAASProvider.equals(value)) {
         return Boolean.toString(true);
       } else {
         return value == null ? "" : value;
       }
     case USE_SSL_FOR_LDAP:
       if (RHQConstants.LDAP_PROTOCOL_SECURED.equals(value)) {
         return Boolean.toString(true);
       } else {
         return Boolean.toString(false);
       }
     default:
       switch (prop.getType()) {
         case BOOLEAN:
           if ("0".equals(value)) {
             return Boolean.FALSE.toString();
           } else if ("1".equals(value)) {
             return Boolean.TRUE.toString();
           } else {
             return value == null ? Boolean.FALSE.toString() : value;
           }
         case PASSWORD:
           if (unobfuscate && value != null && value.trim().length() > 0) {
             return PicketBoxObfuscator.decode(value);
           } else {
             return value == null ? "" : value;
           }
         default:
           if (value == null) {
             switch (prop.getType()) {
               case DOUBLE:
               case FLOAT:
               case INTEGER:
               case LONG:
                 value = "0";
                 break;
               default:
                 value = "";
             }
           }
           return value;
       }
   }
 }
  protected void doTestPortletPreferencesPropagation(boolean linkEnabled, boolean globalScope)
      throws Exception {

    setLinkEnabled(linkEnabled);

    PortletPreferences layoutSetPrototypePortletPreferences =
        LayoutTestUtil.getPortletPreferences(prototypeLayout, journalContentPortletId);

    MergeLayoutPrototypesThreadLocal.clearMergeComplete();

    layoutSetPrototypePortletPreferences.setValue("articleId", StringPool.BLANK);

    layoutSetPrototypePortletPreferences.setValue("showAvailableLocales", Boolean.FALSE.toString());

    if (globalScope) {
      layoutSetPrototypePortletPreferences.setValue("groupId", String.valueOf(globalGroupId));
      layoutSetPrototypePortletPreferences.setValue("lfrScopeType", "company");
    }

    layoutSetPrototypePortletPreferences.store();

    layout = propagateChanges(layout);

    PortletPreferences portletPreferences =
        LayoutTestUtil.getPortletPreferences(layout, journalContentPortletId);

    if (linkEnabled) {
      if (globalScope) {
        Assert.assertEquals(
            StringPool.BLANK, portletPreferences.getValue("articleId", StringPool.BLANK));
      } else {

        // Changes in preferences of local ids are not propagated

        Assert.assertEquals(
            journalArticle.getArticleId(),
            portletPreferences.getValue("articleId", StringPool.BLANK));
      }

      Assert.assertEquals(
          Boolean.FALSE.toString(),
          portletPreferences.getValue("showAvailableLocales", StringPool.BLANK));
    } else {
      Assert.assertEquals(
          journalArticle.getArticleId(),
          portletPreferences.getValue("articleId", StringPool.BLANK));
    }
  }
 /**
  * Update the SLO policy Name for VMAX3 volumes.
  *
  * @param poolSupportedSLONames - Pool Supported SLO Names
  * @param unManagedVolumeInformation - UnManaged Volume Information
  * @param unManagedVolumeCharacteristics - UnManaged Volume characteristics.
  * @param sgSLOName - Volume supported SLO Name.
  */
 private void updateSLOPolicies(
     Set<String> poolSupportedSLONames,
     Map<String, StringSet> unManagedVolumeInformation,
     Map<String, String> unManagedVolumeCharacteristics,
     String sgSLOName) {
   if (null != poolSupportedSLONames && !poolSupportedSLONames.isEmpty()) {
     StringSet sloNamesSet = new StringSet();
     for (String poolSLOName : poolSupportedSLONames) {
       if (null != sgSLOName && poolSLOName.contains(sgSLOName)) {
         // This condition will filter out the pool SLO's which
         // contains Workload when sgSLOName contains
         // just SLO.
         if (!sgSLOName.contains(Constants.WORKLOAD) && poolSLOName.contains(Constants.WORKLOAD)) {
           continue;
         }
         sloNamesSet.add(poolSLOName);
         _logger.info("found a matching slo: {}", poolSLOName);
         break;
       }
     }
     if (!sloNamesSet.isEmpty()) {
       unManagedVolumeInformation.put(
           SupportedVolumeInformation.AUTO_TIERING_POLICIES.toString(), sloNamesSet);
       unManagedVolumeCharacteristics.put(
           SupportedVolumeCharacterstics.IS_AUTO_TIERING_ENABLED.toString(),
           Boolean.TRUE.toString());
     } else {
       _logger.warn("StorageGroup SLOName is not found in Pool settings.");
       unManagedVolumeCharacteristics.put(
           SupportedVolumeCharacterstics.IS_AUTO_TIERING_ENABLED.toString(),
           Boolean.FALSE.toString());
     }
   }
 }
  private void setSelectedDevice(Boolean refreshRequired) {
    final Device device =
        commonPreferences.getDevices().get(specificPreferences.getSelectedDeviceId());
    if (device == null) {
      skin.getShell().close();
    } else {
      Class<? extends BrowserSimSkin> newSkinClass =
          BrowserSimUtil.getSkinClass(device, specificPreferences.getUseSkins());
      String oldSkinUrl = null;
      if (newSkinClass != skin.getClass()) {
        oldSkinUrl = skin.getBrowser().getUrl();
        Point currentLocation = skin.getShell().getLocation();
        skin.getBrowser().removeProgressListener(progressListener);
        skin.getBrowser().getShell().dispose();
        initSkin(newSkinClass, currentLocation);
        fireSkinChangeEvent();
      }
      setOrientation(specificPreferences.getOrientationAngle(), device);

      skin.getBrowser().setDefaultUserAgent(device.getUserAgent());

      if (oldSkinUrl != null) {
        skin.getBrowser().setUrl(oldSkinUrl); // skin (and browser instance) is changed
      } else if (!Boolean.FALSE.equals(refreshRequired)) {
        getBrowser()
            .refresh(); // only user agent and size of the browser is changed and orientation is not
                        // changed
      }

      skin.getShell().open();
    }
  }
Example #22
0
 private String getValueFromEditor() {
   if (jcbEditor != null) {
     if (parameter.getParameterClass() == boolean.class
         || parameter.getParameterClass() == Boolean.class) {
       switch (jcbEditor.getSelectedIndex()) {
         case 1:
           return Boolean.TRUE.toString();
         case 2:
           return Boolean.FALSE.toString();
         default:
           return null;
       }
     } else {
       int index = jcbEditor.getSelectedIndex();
       if (index == 0) {
         return null;
       } else {
         return parameter.getFixedValueList()[index - 1].toString();
       }
     }
   } else {
     String result = jtfEditor.getText();
     return "".equals(result) ? null : result;
   }
 }
  @AdviseWith(adviceClasses = {PropsUtilAdvice.class})
  @Test
  public void testPrepareRequest() throws Exception {
    PropsUtilAdvice.setProps(
        PropsKeys.INTRABAND_MAILBOX_REAPER_THREAD_ENABLED, Boolean.FALSE.toString());
    PropsUtilAdvice.setProps(
        PropsKeys.INTRABAND_MAILBOX_STORAGE_LIFE, String.valueOf(Long.MAX_VALUE));

    Serializer serializer = new Serializer();

    serializer.writeString(_SERVLET_CONTEXT_NAME);
    serializer.writeObject(new SPIAgentRequest(_mockHttpServletRequest));

    Method depositMailMethod =
        ReflectionUtil.getDeclaredMethod(MailboxUtil.class, "depositMail", ByteBuffer.class);

    long receipt = (Long) depositMailMethod.invoke(null, serializer.toByteBuffer());

    byte[] data = new byte[8];

    BigEndianCodec.putLong(data, 0, receipt);

    HttpClientSPIAgent httpClientSPIAgent =
        new HttpClientSPIAgent(
            _spiConfiguration, new MockRegistrationReference(new MockIntraband()));

    MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest();

    mockHttpServletRequest.setContent(data);

    HttpServletRequest httpServletRequest =
        httpClientSPIAgent.prepareRequest(mockHttpServletRequest);

    Assert.assertNotNull(httpServletRequest.getAttribute(WebKeys.SPI_AGENT_REQUEST));
  }
Example #24
0
  /** Tests that in DEPLOYMENT mode the API is NOT exposed. */
  @Test
  public void apiCallInDeploymentMode() throws Exception {
    final Properties props = new Properties();
    // init WroConfig properties
    props.setProperty(ConfigConstants.debug.name(), Boolean.FALSE.toString());
    final WroFilter theFilter =
        new WroFilter() {
          @Override
          protected ObjectFactory<WroConfiguration> newWroConfigurationFactory() {
            final PropertyWroConfigurationFactory factory = new PropertyWroConfigurationFactory();
            factory.setProperties(props);
            return factory;
          }
        };
    initFilterWithValidConfig(theFilter);
    final HttpServletRequest request =
        Mockito.mock(HttpServletRequest.class, Mockito.RETURNS_DEEP_STUBS);
    Mockito.when(request.getRequestURI()).thenReturn(WroFilter.API_RELOAD_CACHE);

    final HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
    Mockito.when(response.getWriter()).thenReturn(new PrintWriter(System.out));
    final FilterChain chain = Mockito.mock(FilterChain.class);
    // by default configuration is development
    theFilter.init(config);

    theFilter.doFilter(request, response, chain);
    // No api method exposed -> proceed with chain
    verifyChainIsCalled(chain);
  }
Example #25
0
 private static Object parseValue(CharacterIterator it) {
   switch (it.current()) {
     case '{':
       return parseObject(it);
     case '[':
       return parseArray(it);
     case '"':
       return parseString(it);
     case '-':
     case '0':
     case '1':
     case '2':
     case '3':
     case '4':
     case '5':
     case '6':
     case '7':
     case '8':
     case '9':
       return parseNumber(it);
     case 't':
       parseText(Boolean.TRUE.toString(), it);
       return Boolean.TRUE;
     case 'f':
       parseText(Boolean.FALSE.toString(), it);
       return Boolean.FALSE;
     case 'n':
       parseText(NULL, it);
       return null;
   }
   throw error(
       "Bad JSON starting character '" + it.current() + "'", it); // $NON-NLS-1$ //$NON-NLS-2$;
 }
 private static boolean isSuspended(ChannelHandlerContext ctx) {
   Boolean suspended = ctx.attr(READ_SUSPENDED).get();
   if (suspended == null || Boolean.FALSE.equals(suspended)) {
     return false;
   }
   return true;
 }
Example #27
0
 private ImmutableMap<ConfigurationKeys, String> getPushParameters() {
   ImmutableMap<Factory.ConfigurationKeys, String> response = null;
   if (Push.PUSH_SANDBOX_ENABLE.getValueAsBoolean()) {
     response =
         ImmutableMap.of(
             ConfigurationKeys.ANDROID_API_KEY,
                 "" + Push.SANDBOX_ANDROID_API_KEY.getValueAsString(),
             ConfigurationKeys.APPLE_TIMEOUT, "" + Push.PUSH_APPLE_TIMEOUT.getValueAsString(),
             ConfigurationKeys.IOS_CERTIFICATE,
                 "" + Push.SANDBOX_IOS_CERTIFICATE.getValueAsString(),
             ConfigurationKeys.IOS_CERTIFICATE_PASSWORD,
                 "" + Push.SANDBOX_IOS_CERTIFICATE_PASSWORD.getValueAsString(),
             ConfigurationKeys.IOS_SANDBOX, "" + Boolean.TRUE.toString());
   } else {
     response =
         ImmutableMap.of(
             ConfigurationKeys.ANDROID_API_KEY,
                 "" + Push.PRODUCTION_ANDROID_API_KEY.getValueAsString(),
             ConfigurationKeys.APPLE_TIMEOUT, "" + Push.PUSH_APPLE_TIMEOUT.getValueAsString(),
             ConfigurationKeys.IOS_CERTIFICATE,
                 "" + Push.PRODUCTION_IOS_CERTIFICATE.getValueAsString(),
             ConfigurationKeys.IOS_CERTIFICATE_PASSWORD,
                 "" + Push.PRODUCTION_IOS_CERTIFICATE_PASSWORD.getValueAsString(),
             ConfigurationKeys.IOS_SANDBOX, "" + Boolean.FALSE.toString());
   }
   return response;
 }
 private void doMoveClass(PsiSubstitutor substitutor, MemberInfo info) {
   PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(myProject);
   PsiClass aClass = (PsiClass) info.getMember();
   if (Boolean.FALSE.equals(info.getOverrides())) {
     final PsiReferenceList sourceReferenceList = info.getSourceReferenceList();
     LOG.assertTrue(sourceReferenceList != null);
     PsiJavaCodeReferenceElement ref =
         mySourceClass.equals(sourceReferenceList.getParent())
             ? RefactoringUtil.removeFromReferenceList(sourceReferenceList, aClass)
             : RefactoringUtil.findReferenceToClass(sourceReferenceList, aClass);
     if (ref != null && !myTargetSuperClass.isInheritor(aClass, false)) {
       RefactoringUtil.replaceMovedMemberTypeParameters(
           ref, PsiUtil.typeParametersIterable(mySourceClass), substitutor, elementFactory);
       final PsiReferenceList referenceList =
           myIsTargetInterface
               ? myTargetSuperClass.getExtendsList()
               : myTargetSuperClass.getImplementsList();
       assert referenceList != null;
       referenceList.add(ref);
     }
   } else {
     RefactoringUtil.replaceMovedMemberTypeParameters(
         aClass, PsiUtil.typeParametersIterable(mySourceClass), substitutor, elementFactory);
     fixReferencesToStatic(aClass);
     final PsiMember movedElement =
         (PsiMember)
             myTargetSuperClass.add(
                 convertClassToLanguage(aClass, myTargetSuperClass.getLanguage()));
     myMembersAfterMove.add(movedElement);
     aClass.delete();
   }
 }
Example #29
0
  /*
   * Tests a row against this CHECK constraint.
   */
  void checkCheckConstraint(Session session, Table table, Object[] data) {

    /*
            if (session.compiledStatementExecutor.rangeIterators[1] == null) {
                session.compiledStatementExecutor.rangeIterators[1] =
                    rangeVariable.getIterator(session);
            }
    */
    RangeIteratorBase it = (RangeIteratorBase) session.sessionContext.getCheckIterator();

    if (it == null) {
      it = rangeVariable.getIterator(session);

      session.sessionContext.setCheckIterator(it);
    }

    it.currentData = data;

    boolean nomatch = Boolean.FALSE.equals(check.getValue(session));

    it.currentData = null;

    if (nomatch) {
      String[] info = new String[] {name.name, table.tableName.name};

      throw Error.error(ErrorCode.X_23504, ErrorCode.CONSTRAINT, info);
    }
  }
Example #30
0
 /**
  * Returns <tt>true</tt> if this event has been aborted via <tt>preventDefault()</tt> in
  * standards-compliant browsers, or via the event's <tt>returnValue</tt> property in IE, or by the
  * event handler returning <tt>false</tt>.
  *
  * @param result the event handler result (if <tt>false</tt>, the event is considered aborted)
  * @return <tt>true</tt> if this event has been aborted
  */
 public boolean isAborted(final ScriptResult result) {
   final boolean checkReturnValue =
       getBrowserVersion().hasFeature(JS_EVENT_ABORTED_BY_RETURN_VALUE_FALSE);
   return ScriptResult.isFalse(result)
       || (!checkReturnValue && preventDefault_)
       || (checkReturnValue && Boolean.FALSE.equals(returnValue_));
 }