protected void updateLDAPUser(User ldapUser, Contact ldapContact, User user)
      throws PortalException, SystemException {

    Contact contact = user.getContact();

    ldapContact.setAimSn(GetterUtil.getString(contact.getAimSn()));
    ldapContact.setFacebookSn(GetterUtil.getString(contact.getFacebookSn()));
    ldapContact.setIcqSn(GetterUtil.getString(contact.getIcqSn()));
    ldapContact.setJabberSn(GetterUtil.getString(contact.getJabberSn()));
    ldapContact.setMale(GetterUtil.getBoolean(contact.getMale()));
    ldapContact.setMsnSn(GetterUtil.getString(contact.getMsnSn()));
    ldapContact.setMySpaceSn(GetterUtil.getString(contact.getMySpaceSn()));
    ldapContact.setPrefixId(GetterUtil.getInteger(contact.getPrefixId()));
    ldapContact.setSkypeSn(GetterUtil.getString(contact.getSkypeSn()));
    ldapContact.setSmsSn(GetterUtil.getString(contact.getSmsSn()));
    ldapContact.setSuffixId(GetterUtil.getInteger(contact.getSuffixId()));
    ldapContact.setTwitterSn(GetterUtil.getString(contact.getTwitterSn()));
    ldapContact.setYmSn(GetterUtil.getString(contact.getYmSn()));

    ldapUser.setComments(GetterUtil.getString(user.getComments()));
    ldapUser.setGreeting(GetterUtil.getString(user.getGreeting()));
    ldapUser.setJobTitle(GetterUtil.getString(user.getJobTitle()));
    ldapUser.setLanguageId(GetterUtil.getString(user.getLanguageId()));
    ldapUser.setMiddleName(GetterUtil.getString(user.getMiddleName()));
    ldapUser.setOpenId(GetterUtil.getString(user.getOpenId()));
    ldapUser.setTimeZoneId(GetterUtil.getString(user.getTimeZoneId()));
  }
  public void execute() throws BuildException {
    try {
      InetAddress localHost = InetAddress.getLocalHost();

      if (Validator.isNotNull(_hostAddressProperty)) {
        getProject().setUserProperty(_hostAddressProperty, localHost.getHostAddress());
      }

      if (Validator.isNotNull(_hostNameProperty)) {
        getProject().setUserProperty(_hostNameProperty, localHost.getHostName());
      }

      if (Validator.isNotNull(_vmId1Property)) {
        int id = GetterUtil.getInteger(StringUtil.extractDigits(localHost.getHostName()));

        getProject().setUserProperty(_vmId1Property, String.valueOf((id * 2) - 1));
      }

      if (Validator.isNotNull(_vmId2Property)) {
        int id = GetterUtil.getInteger(StringUtil.extractDigits(localHost.getHostName()));

        getProject().setUserProperty(_vmId2Property, String.valueOf((id * 2)));
      }
    } catch (UnknownHostException uhe) {
      throw new BuildException(uhe);
    }
  }
  protected void initVideoFrameRate(Properties videoProperties) {
    int numerator =
        GetterUtil.getInteger(
            videoProperties.getProperty(
                PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO_FRAME_RATE_NUMERATOR
                    + "["
                    + _videoContainer
                    + "]"));
    int denominator =
        GetterUtil.getInteger(
            videoProperties.getProperty(
                PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO_FRAME_RATE_DENOMINATOR
                    + StringPool.OPEN_BRACKET
                    + _videoContainer
                    + StringPool.CLOSE_BRACKET));

    if ((numerator > 0) && (denominator > 0)) {
      _videoFrameRate = IRational.make(numerator, denominator);

      if (_log.isInfoEnabled()) {
        _log.info(
            "Default frame rate for "
                + _videoContainer
                + " configured to "
                + _videoFrameRate.getNumerator()
                + "/"
                + _videoFrameRate.getDenominator());
      }
    }
  }
  @Override
  public void mouseMoveAt(String locator, String coordString) {
    WebElement webElement = getWebElement(locator);

    WrapsDriver wrapsDriver = (WrapsDriver) webElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    Actions actions = new Actions(webDriver);

    if (coordString.contains(",")) {
      String[] coords = coordString.split(",");

      int x = GetterUtil.getInteger(coords[0]);
      int y = GetterUtil.getInteger(coords[1]);

      actions.moveToElement(webElement, x, y);
      actions.clickAndHold(webElement);
    } else {
      actions.moveToElement(webElement);
      actions.clickAndHold(webElement);
    }

    Action action = actions.build();

    action.perform();
  }
  @Override
  public void clickAt(String locator, String coordString) {
    if (locator.contains("x:")) {
      String url = getHtmlNodeHref(locator);

      open(url);
    } else {
      WebElement webElement = getWebElement(locator);

      if (coordString.contains(",")) {
        WrapsDriver wrapsDriver = (WrapsDriver) webElement;

        WebDriver webDriver = wrapsDriver.getWrappedDriver();

        Actions actions = new Actions(webDriver);

        String[] coords = coordString.split(",");

        int x = GetterUtil.getInteger(coords[0]);
        int y = GetterUtil.getInteger(coords[1]);

        actions.moveToElement(webElement, x, y);
        actions.click();

        Action action = actions.build();

        action.perform();
      } else {
        webElement.click();
      }
    }
  }
  public LiferayVideoConverter(
      String inputURL,
      String outputURL,
      String tempFileName,
      Properties videoProperties,
      Properties ffpresetProperties) {

    _inputURL = inputURL;
    _outputURL = outputURL;
    _tempFileName = tempFileName;
    _ffpresetProperties = ffpresetProperties;

    _height =
        GetterUtil.getInteger(
            videoProperties.getProperty(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO_HEIGHT), _height);
    _width =
        GetterUtil.getInteger(
            videoProperties.getProperty(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO_WIDTH), _width);
    _previewVideoContainers =
        StringUtil.split(
            videoProperties.getProperty(PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO_CONTAINERS));

    initVideoBitRateMap(videoProperties);
    initVideoFrameRateMap(videoProperties);
  }
Ejemplo n.º 7
0
  /**
   * Returns <code>true</code> if the string contains a valid number according to the Luhn
   * algorithm, commonly used to validate credit card numbers.
   *
   * @param number the string to check
   * @return <code>true</code> if the string contains a valid number according to the Luhn
   *     algorithm; <code>false</code> otherwise
   */
  public static boolean isLUHN(String number) {
    if (number == null) {
      return false;
    }

    number = StringUtil.reverse(number);

    int total = 0;

    for (int i = 0; i < number.length(); i++) {
      int x = 0;

      if (((i + 1) % 2) == 0) {
        x = GetterUtil.getInteger(number.substring(i, i + 1)) * 2;

        if (x >= 10) {
          String s = String.valueOf(x);

          x = GetterUtil.getInteger(s.substring(0, 1)) + GetterUtil.getInteger(s.substring(1, 2));
        }
      } else {
        x = GetterUtil.getInteger(number.substring(i, i + 1));
      }

      total = total + x;
    }

    if ((total % 10) == 0) {
      return true;
    } else {
      return false;
    }
  }
  @Reference(unbind = "-")
  protected void setProps(Props props) {
    _props = props;

    _descriptionMaxLength =
        GetterUtil.getInteger(_props.get(PropsKeys.SCHEDULER_DESCRIPTION_MAX_LENGTH), 120);

    _groupNameMaxLength =
        GetterUtil.getInteger(_props.get(PropsKeys.SCHEDULER_GROUP_NAME_MAX_LENGTH), 80);

    _jobNameMaxLength =
        GetterUtil.getInteger(_props.get(PropsKeys.SCHEDULER_JOB_NAME_MAX_LENGTH), 80);
  }
Ejemplo n.º 9
0
  protected void remoteServeResource(
      ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception {

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

    OAuthRequest oAuthRequest = new OAuthRequest(Verb.GET, getServerPortletURL());

    setRequestParameters(resourceRequest, resourceResponse, oAuthRequest);

    addOAuthParameter(oAuthRequest, "p_p_lifecycle", "2");
    addOAuthParameter(oAuthRequest, "p_p_resource_id", resourceRequest.getResourceID());

    Response response = getResponse(themeDisplay.getUser(), oAuthRequest);

    String contentType = response.getHeader(HttpHeaders.CONTENT_TYPE);

    if (contentType.startsWith(ContentTypes.APPLICATION_OCTET_STREAM)) {
      String contentDisposition = response.getHeader(HttpHeaders.CONTENT_DISPOSITION);
      int contentLength = GetterUtil.getInteger(response.getHeader(HttpHeaders.CONTENT_LENGTH));

      PortletResponseUtil.sendFile(
          resourceRequest,
          resourceResponse,
          getFileName(contentDisposition),
          response.getStream(),
          contentLength,
          contentType,
          HttpHeaders.CONTENT_DISPOSITION_ATTACHMENT);
    } else {
      PortletResponseUtil.write(resourceResponse, response.getStream());
    }
  }
  @Override
  protected Client createClient(ImmutableSettings.Builder builder) {
    if (_transportAddresses.isEmpty()) {
      throw new IllegalStateException("There must be at least one transport address");
    }

    Class<?> clazz = getClass();

    builder.classLoader(clazz.getClassLoader());

    builder.loadFromClasspath(getConfigFileName());

    TransportClient transportClient = new TransportClient(builder);

    builder.put("client.transport.sniff", true);
    builder.put("cluster.name", getClusterName());

    for (String transportAddress : _transportAddresses) {
      String[] transportAddressParts = StringUtil.split(transportAddress, StringPool.COLON);

      try {
        InetAddress inetAddress = InetAddress.getByName(transportAddressParts[0]);

        int port = GetterUtil.getInteger(transportAddressParts[1]);

        transportClient.addTransportAddress(new InetSocketTransportAddress(inetAddress, port));
      } catch (Exception e) {
        if (_log.isWarnEnabled()) {
          _log.warn("Unable to add transport address " + transportAddress, e);
        }
      }
    }

    return transportClient;
  }
  @Override
  public void keyUp(String locator, String keySequence) {
    WebElement webElement = getWebElement(locator);

    if (keySequence.startsWith("\\")) {
      int index = GetterUtil.getInteger(keySequence.substring(1));

      Keys keys = _keysArray[index];

      if ((index >= 48) && (index <= 90)) {
        webElement.sendKeys(StringPool.ASCII_TABLE[index]);
      } else if ((index == 16) || (index == 17) || (index == 18)) {
        WrapsDriver wrapsDriver = (WrapsDriver) webElement;

        WebDriver webDriver = wrapsDriver.getWrappedDriver();

        Actions actions = new Actions(webDriver);

        actions.keyUp(webElement, keys);

        Action action = actions.build();

        action.perform();
      } else {
        webElement.sendKeys(keys);
      }
    } else {
      webElement.sendKeys(keySequence);
    }
  }
  public void setTimeoutImplicit(String timeout) {
    WebDriver.Options options = manage();

    WebDriver.Timeouts timeouts = options.timeouts();

    timeouts.implicitlyWait(GetterUtil.getInteger(timeout), TimeUnit.MILLISECONDS);
  }
  public void importServicePortletPreferences(
      PortletDataContext portletDataContext, Element serviceElement) throws PortalException {

    long ownerId = GetterUtil.getLong(serviceElement.attributeValue("owner-id"));
    int ownerType = GetterUtil.getInteger(serviceElement.attributeValue("owner-type"));
    String serviceName = serviceElement.attributeValue("service-name");

    if (ownerType == PortletKeys.PREFS_OWNER_TYPE_GROUP) {
      ownerId = portletDataContext.getGroupId();
    } else if (ownerType == PortletKeys.PREFS_OWNER_TYPE_COMPANY) {
      ownerId = portletDataContext.getCompanyId();
    }

    PortletPreferences portletPreferences =
        getPortletPreferences(
            portletDataContext.getCompanyId(),
            ownerId,
            ownerType,
            LayoutConstants.DEFAULT_PLID,
            serviceName);

    for (Attribute attribute : serviceElement.attributes()) {
      serviceElement.remove(attribute);
    }

    String xml = serviceElement.asXML();

    portletPreferences.setPreferences(xml);

    _portletPreferencesLocalService.updatePortletPreferences(portletPreferences);
  }
  protected void parseActionElements(List<Element> actionElements, ActionAware actionAware) {

    if (actionElements.isEmpty()) {
      return;
    }

    Set<Action> actions = new HashSet<Action>(actionElements.size());

    for (Element actionElement : actionElements) {
      String name = actionElement.elementText("name");
      String description = actionElement.elementText("description");
      String executionType = actionElement.elementText("execution-type");
      String script = actionElement.elementText("script");
      String scriptLanguage = actionElement.elementText("script-language");
      String scriptRequiredContexts = actionElement.elementText("script-required-contexts");
      int priority = GetterUtil.getInteger(actionElement.elementText("priority"));

      Action action =
          new Action(
              name,
              description,
              executionType,
              script,
              scriptLanguage,
              scriptRequiredContexts,
              priority);

      actions.add(action);
    }

    actionAware.setActions(actions);
  }
  public static void init() {
    if (!_LOG_SANITIZER_ENABLED) {
      return;
    }

    _LOG_SANITIZER_ESCAPE_HTML_ENABLED =
        GetterUtil.getBoolean(SystemProperties.get(PropsKeys.LOG_SANITIZER_ESCAPE_HTML_ENABLED));

    _LOG_SANITIZER_REPLACEMENT_CHARACTER =
        (char)
            GetterUtil.getInteger(
                SystemProperties.get(PropsKeys.LOG_SANITIZER_REPLACEMENT_CHARACTER));

    int[] whitelistCharacters =
        GetterUtil.getIntegerValues(
            SystemProperties.getArray(PropsKeys.LOG_SANITIZER_WHITELIST_CHARACTERS));

    for (int whitelistCharacter : whitelistCharacters) {
      if ((whitelistCharacter >= 0) && (whitelistCharacter < _whitelistCharacters.length)) {

        _whitelistCharacters[whitelistCharacter] = 1;
      } else {
        System.err.println("Unable to register log whitelist character " + whitelistCharacter);
      }
    }
  }
Ejemplo n.º 16
0
  public int getMaxAge(Group group) throws PortalException, SystemException {
    if (group.isLayout()) {
      group = group.getParentGroup();
    }

    int trashEntriesMaxAge =
        PrefsPropsUtil.getInteger(
            group.getCompanyId(),
            PropsKeys.TRASH_ENTRIES_MAX_AGE,
            GetterUtil.getInteger(PropsUtil.get(PropsKeys.TRASH_ENTRIES_MAX_AGE)));

    UnicodeProperties typeSettingsProperties = group.getTypeSettingsProperties();

    return GetterUtil.getInteger(
        typeSettingsProperties.getProperty("trashEntriesMaxAge"), trashEntriesMaxAge);
  }
  protected void importServicePortletPreferences(
      PortletDataContext portletDataContext, Element serviceElement) throws PortalException {

    long ownerId = GetterUtil.getLong(serviceElement.attributeValue("owner-id"));
    int ownerType = GetterUtil.getInteger(serviceElement.attributeValue("owner-type"));
    String serviceName = serviceElement.attributeValue("service-name");

    PortletPreferences portletPreferences =
        getPortletPreferences(
            portletDataContext.getCompanyId(),
            ownerId,
            ownerType,
            LayoutConstants.DEFAULT_PLID,
            serviceName);

    for (Attribute attribute : serviceElement.attributes()) {
      serviceElement.remove(attribute);
    }

    String xml = serviceElement.asXML();

    portletPreferences.setPreferences(xml);

    _portletPreferencesLocalService.updatePortletPreferences(portletPreferences);
  }
  protected void readExpandoTables(PortletDataContext portletDataContext) throws Exception {

    String xml =
        portletDataContext.getZipEntryAsString(
            ExportImportPathUtil.getSourceRootPath(portletDataContext) + "/expando-tables.xml");

    if (xml == null) {
      return;
    }

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    List<Element> expandoTableElements = rootElement.elements("expando-table");

    for (Element expandoTableElement : expandoTableElements) {
      String className = expandoTableElement.attributeValue("class-name");

      ExpandoTable expandoTable = null;

      try {
        expandoTable =
            _expandoTableLocalService.getDefaultTable(portletDataContext.getCompanyId(), className);
      } catch (NoSuchTableException nste) {
        expandoTable =
            _expandoTableLocalService.addDefaultTable(portletDataContext.getCompanyId(), className);
      }

      List<Element> expandoColumnElements = expandoTableElement.elements("expando-column");

      for (Element expandoColumnElement : expandoColumnElements) {
        long columnId = GetterUtil.getLong(expandoColumnElement.attributeValue("column-id"));
        String name = expandoColumnElement.attributeValue("name");
        int type = GetterUtil.getInteger(expandoColumnElement.attributeValue("type"));
        String defaultData = expandoColumnElement.elementText("default-data");
        String typeSettings = expandoColumnElement.elementText("type-settings");

        Serializable defaultDataObject =
            ExpandoConverterUtil.getAttributeFromString(type, defaultData);

        ExpandoColumn expandoColumn =
            _expandoColumnLocalService.getColumn(expandoTable.getTableId(), name);

        if (expandoColumn != null) {
          _expandoColumnLocalService.updateColumn(
              expandoColumn.getColumnId(), name, type, defaultDataObject);
        } else {
          expandoColumn =
              _expandoColumnLocalService.addColumn(
                  expandoTable.getTableId(), name, type, defaultDataObject);
        }

        _expandoColumnLocalService.updateTypeSettings(expandoColumn.getColumnId(), typeSettings);

        portletDataContext.importPermissions(
            ExpandoColumn.class, columnId, expandoColumn.getColumnId());
      }
    }
  }
Ejemplo n.º 19
0
  protected int getRangeSize(String name) {
    if (name.equals(_NAME)) {
      return PropsValues.COUNTER_INCREMENT;
    }

    String incrementType = null;

    int pos = name.indexOf(CharPool.POUND);

    if (pos != -1) {
      incrementType = name.substring(0, pos);
    } else {
      incrementType = name;
    }

    Integer rangeSize = _rangeSizeMap.get(incrementType);

    if (rangeSize == null) {
      rangeSize =
          GetterUtil.getInteger(
              PropsUtil.get(PropsKeys.COUNTER_INCREMENT_PREFIX + incrementType),
              PropsValues.COUNTER_INCREMENT);

      _rangeSizeMap.put(incrementType, rangeSize);
    }

    return rangeSize.intValue();
  }
  @Override
  public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext)
      throws Exception {

    long[] folderIds = searchContext.getFolderIds();

    if ((folderIds != null) && (folderIds.length > 0)) {
      if (folderIds[0] == BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

        return;
      }

      BooleanQuery folderIdsQuery = BooleanQueryFactoryUtil.create(searchContext);

      for (long folderId : folderIds) {
        try {
          BookmarksFolderServiceUtil.getFolder(folderId);
        } catch (Exception e) {
          continue;
        }

        folderIdsQuery.addTerm(Field.FOLDER_ID, folderId);
      }

      contextQuery.add(folderIdsQuery, BooleanClauseOccur.MUST);
    }

    int status =
        GetterUtil.getInteger(
            searchContext.getAttribute(Field.STATUS), WorkflowConstants.STATUS_APPROVED);

    if (status != WorkflowConstants.STATUS_ANY) {
      contextQuery.addRequiredTerm(Field.STATUS, status);
    }
  }
  protected void initVideoBitRateMap(Properties videoProperties) {
    _videoBitRateMap = new HashMap<String, Integer>();

    for (String previewVideoContainer : _previewVideoContainers) {
      int videoBitRate =
          GetterUtil.getInteger(
              videoProperties.getProperty(
                  PropsKeys.DL_FILE_ENTRY_PREVIEW_VIDEO_BIT_RATE
                      + "["
                      + previewVideoContainer
                      + "]"));

      if (videoBitRate > _VIDEO_BIT_RATE_MAX) {
        videoBitRate = _VIDEO_BIT_RATE_MAX;
      }

      if (videoBitRate > 0) {
        _videoBitRateMap.put(previewVideoContainer, videoBitRate);

        if (_log.isInfoEnabled()) {
          _log.info("Bit rate for " + previewVideoContainer + " set to " + videoBitRate);
        }
      }
    }
  }
Ejemplo n.º 22
0
  protected int getStatus(RenderRequest renderRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (!themeDisplay.isSignedIn()) {
      return WorkflowConstants.STATUS_APPROVED;
    }

    String value = renderRequest.getParameter("status");
    int status = GetterUtil.getInteger(value);

    if ((value != null) && (status == WorkflowConstants.STATUS_APPROVED)) {
      return WorkflowConstants.STATUS_APPROVED;
    }

    long resourcePrimKey = getResourcePrimKey(renderRequest);

    if (resourcePrimKey == 0) {
      return WorkflowConstants.STATUS_APPROVED;
    }

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (KBArticlePermission.contains(permissionChecker, resourcePrimKey, ActionKeys.UPDATE)) {

      return ParamUtil.getInteger(renderRequest, "status", WorkflowConstants.STATUS_ANY);
    }

    return WorkflowConstants.STATUS_APPROVED;
  }
Ejemplo n.º 23
0
  public static List<Calendar> getSelectedCalendars(long userId)
      throws PortalException, SystemException {

    ArrayList<Calendar> calendars = new ArrayList<Calendar>();

    String otherCalendarPreferences = "calendar-portlet-other-calendars";

    if (_calendarVersion == 0) {
      Portlet calendarPortlet = PortletLocalServiceUtil.getPortletById(PortletKeys.CALENDAR);

      String calendarVersionStr = calendarPortlet.getPluginPackage().getVersion();

      Version calendarVersion = Version.getInstance(calendarVersionStr);

      _calendarVersion = GetterUtil.getInteger(calendarVersion.getBuildNumber(), 1);
    }

    if (_calendarVersion < 10) {
      otherCalendarPreferences = "otherCalendars";
    }

    long[] calendarIds =
        GetterUtil.getLongValues(
            StringUtil.split(
                PortletPreferencesFactoryUtil.getPortalPreferences(userId, true)
                    .getValue(SessionClicks.class.getName(), otherCalendarPreferences)));

    for (long calendarId : calendarIds) {
      calendars.add(CalendarServiceUtil.getCalendar(calendarId));
    }

    return calendars;
  }
Ejemplo n.º 24
0
  @Override
  protected String replaceTemplate(String template, String[] actual) {

    // LPS-12048

    Matcher matcher = _varcharPattern.matcher(template);

    StringBuffer sb = new StringBuffer();

    while (matcher.find()) {
      int size = GetterUtil.getInteger(matcher.group()) * 4;

      if (size > 4000) {
        size = 4000;
      }

      matcher.appendReplacement(sb, "VARCHAR(" + size + ")");
    }

    matcher.appendTail(sb);

    template = sb.toString();

    return super.replaceTemplate(template, actual);
  }
Ejemplo n.º 25
0
  public HostConfiguration getHostConfiguration(String location) throws IOException {

    if (_log.isDebugEnabled()) {
      _log.debug("Location is " + location);
    }

    HostConfiguration hostConfiguration = new HostConfiguration();

    hostConfiguration.setHost(new URI(location, false));

    if (isProxyHost(hostConfiguration.getHost())) {
      hostConfiguration.setProxy(_PROXY_HOST, _PROXY_PORT);
    }

    HttpConnectionManager httpConnectionManager = _httpClient.getHttpConnectionManager();

    HttpConnectionManagerParams httpConnectionManagerParams = httpConnectionManager.getParams();

    int defaultMaxConnectionsPerHost =
        httpConnectionManagerParams.getMaxConnectionsPerHost(hostConfiguration);

    int maxConnectionsPerHost =
        GetterUtil.getInteger(
            PropsUtil.get(
                HttpImpl.class.getName() + ".max.connections.per.host",
                new Filter(hostConfiguration.getHost())));

    if ((maxConnectionsPerHost > 0) && (maxConnectionsPerHost != defaultMaxConnectionsPerHost)) {

      httpConnectionManagerParams.setMaxConnectionsPerHost(
          hostConfiguration, maxConnectionsPerHost);
    }

    int timeout =
        GetterUtil.getInteger(
            PropsUtil.get(
                HttpImpl.class.getName() + ".timeout", new Filter(hostConfiguration.getHost())));

    if (timeout > 0) {
      HostParams hostParams = hostConfiguration.getParams();

      hostParams.setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, timeout);
      hostParams.setIntParameter(HttpConnectionParams.SO_TIMEOUT, timeout);
    }

    return hostConfiguration;
  }
Ejemplo n.º 26
0
  @Override
  public void postProcessContextQuery(BooleanQuery contextQuery, SearchContext searchContext)
      throws Exception {

    Long classNameId = (Long) searchContext.getAttribute(Field.CLASS_NAME_ID);

    if (classNameId != null) {
      contextQuery.addRequiredTerm("classNameId", classNameId.toString());
    }

    int status =
        GetterUtil.getInteger(
            searchContext.getAttribute(Field.STATUS), WorkflowConstants.STATUS_APPROVED);

    if (status != WorkflowConstants.STATUS_ANY) {
      contextQuery.addRequiredTerm(Field.STATUS, status);
    }

    long[] folderIds = searchContext.getFolderIds();

    if ((folderIds != null) && (folderIds.length > 0)) {
      if (folderIds[0] == JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID) {

        return;
      }

      BooleanQuery folderIdsQuery = BooleanQueryFactoryUtil.create(searchContext);

      for (long folderId : folderIds) {
        try {
          JournalFolderServiceUtil.getFolder(folderId);
        } catch (Exception e) {
          continue;
        }

        folderIdsQuery.addTerm(Field.FOLDER_ID, folderId);
      }

      contextQuery.add(folderIdsQuery, BooleanClauseOccur.MUST);
    }

    String articleType = (String) searchContext.getAttribute("articleType");

    if (Validator.isNotNull(articleType)) {
      contextQuery.addRequiredTerm(Field.TYPE, articleType);
    }

    String structureId = (String) searchContext.getAttribute("structureId");

    if (Validator.isNotNull(structureId)) {
      contextQuery.addRequiredTerm("structureId", structureId);
    }

    String templateId = (String) searchContext.getAttribute("templateId");

    if (Validator.isNotNull(templateId)) {
      contextQuery.addRequiredTerm("templateId", templateId);
    }
  }
Ejemplo n.º 27
0
  protected void collectExpirationCache(
      ServiceReference<Portlet> serviceReference, com.liferay.portal.model.Portlet portletModel) {

    int expirationCache =
        GetterUtil.getInteger(serviceReference.getProperty("javax.portlet.expiration-cache"));

    portletModel.setExpCache(expirationCache);
  }
  public int getAbstractLength() {
    if (_abstractLength == null) {
      _abstractLength =
          GetterUtil.getInteger(_portletPreferences.getValue("abstractLength", null), 200);
    }

    return _abstractLength;
  }
  protected Definition doParse(InputStream inputStream) throws Exception {
    Document document = SAXReaderUtil.read(inputStream, _validate);

    Element rootElement = document.getRootElement();

    String name = rootElement.elementText("name");
    String description = rootElement.elementText("description");
    int version = GetterUtil.getInteger(rootElement.elementText("version"));

    Definition definition = new Definition(name, description, document.formattedString(), version);

    List<Element> conditionElements = rootElement.elements("condition");

    for (Element conditionElement : conditionElements) {
      Condition condition = parseCondition(conditionElement);

      definition.addNode(condition);
    }

    List<Element> forkElements = rootElement.elements("fork");

    for (Element forkElement : forkElements) {
      Fork fork = parseFork(forkElement);

      definition.addNode(fork);
    }

    List<Element> joinElements = rootElement.elements("join");

    for (Element joinElement : joinElements) {
      Join join = parseJoin(joinElement);

      definition.addNode(join);
    }

    List<Element> stateElements = rootElement.elements("state");

    for (Element stateElement : stateElements) {
      State state = parseState(stateElement);

      definition.addNode(state);
    }

    List<Element> taskElements = rootElement.elements("task");

    for (Element taskElement : taskElements) {
      Task task = parseTask(taskElement);

      definition.addNode(task);
    }

    parseTransitions(
        definition, conditionElements, forkElements, joinElements, stateElements, taskElements);

    return definition;
  }
Ejemplo n.º 30
0
  @Override
  public void setWindowSize(String coordString) {
    WebElement bodyWebElement = getWebElement("//body");

    WrapsDriver wrapsDriver = (WrapsDriver) bodyWebElement;

    WebDriver webDriver = wrapsDriver.getWrappedDriver();

    WebDriver.Options options = webDriver.manage();

    WebDriver.Window window = options.window();

    String[] screenResolution = StringUtil.split(coordString, ",");

    int x = GetterUtil.getInteger(screenResolution[0]);
    int y = GetterUtil.getInteger(screenResolution[1]);

    window.setSize(new Dimension(x, y));
  }