protected String getEditorType(InputRichText inputRichText) {

    String editorType = PropsUtil.get(PropsKeys.EDITOR_WYSIWYG_DEFAULT);
    String editorKey = inputRichText.getEditorKey();

    if (editorKey != null) {
      editorType = PropsUtil.get(editorKey);
    }

    return editorType;
  }
  private String _getLogin() {
    String login = PrincipalThreadLocal.getName();

    if (Validator.isNull(login) || _isDefaultUser(login)) {
      return PropsUtil.get(PropsKeys.DL_REPOSITORY_GUEST_USERNAME);
    }

    try {
      String authType = getAuthType();

      if (!authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
        User user = userLocalService.getUser(GetterUtil.getLong(login));

        if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
          login = user.getEmailAddress();
        } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
          login = user.getScreenName();
        }
      }
    } catch (PortalException | SystemException e) {
      if (_log.isWarnEnabled()) {
        _log.warn("Unable to get login to connect to external repository " + _extRepository, e);
      }

      login = null;
    }

    return login;
  }
  @BeforeClass
  public static void setUpClass() throws IOException {

    // Run before the test JVM starts to ensure the dynamic download
    // actually happens during the test run

    PropsUtil.setProps(new PropsImpl());

    String jarName =
        PropsUtil.get(PropsKeys.SETUP_LIFERAY_POOL_PROVIDER_JAR_NAME, new Filter("hikaricp"));

    Path jarPath = Paths.get("lib/portal", jarName);

    if (Files.exists(jarPath)) {
      Path tempFilePath = Files.createTempFile(null, null);

      Files.move(jarPath, tempFilePath, StandardCopyOption.REPLACE_EXISTING);

      URI uri = tempFilePath.toUri();

      URL url = uri.toURL();

      System.setProperty(_HIKARICP_JAR_URL, url.toExternalForm());
    }
  }
  @After
  public void tearDown() throws IOException {
    String jarName =
        PropsUtil.get(PropsKeys.SETUP_LIFERAY_POOL_PROVIDER_JAR_NAME, new Filter("hikaricp"));

    Files.deleteIfExists(Paths.get(PropsValues.LIFERAY_LIB_PORTAL_DIR, jarName));
  }
  public static GoogleCredential getGoogleCredential() throws Exception {
    if (_googleCredential != null) {
      return _googleCredential;
    }

    GoogleCredential.Builder builder = new GoogleCredential.Builder();

    builder.setJsonFactory(new JacksonFactory());
    builder.setServiceAccountId(PortletPropsValues.GOOGLE_API_SERVICE_ACCOUNT_ID);

    File file =
        new File(
            PropsUtil.get(PropsKeys.LIFERAY_HOME)
                + PortletPropsValues.GOOGLE_API_SERVICE_ACCOUNT_PRIVATE_KEY_P12_FILE);

    builder.setServiceAccountPrivateKeyFromP12File(file);

    builder.setServiceAccountScopes(
        Arrays.asList(PortletPropsValues.GOOGLE_API_SERVICE_ACCOUNT_SCOPES));
    builder.setServiceAccountUser(PortletPropsValues.GOOGLE_API_SERVICE_ACCOUNT_USER);
    builder.setTransport(new NetHttpTransport());

    _googleCredential = builder.build();

    return _googleCredential;
  }
Esempio n. 6
0
  /** Inits the. */
  @PostConstruct
  public void init() {
    ThemeDisplay themeDisplay = LiferayFacesContext.getInstance().getThemeDisplay();
    String currentPage = themeDisplay.getLayout().getFriendlyURL();
    if (currentPage.equals("/daten")) {
      metadataType = MetadataEnumType.DATASET.toField();
    } else if (currentPage.equals("/apps")) {
      metadataType = MetadataEnumType.APPLICATION.toField();
    } else if (currentPage.equals("/dokumente")) {
      metadataType = MetadataEnumType.DOCUMENT.toField();
    } else {
      metadataType = "metadata";
    }

    scmBuildnumber = PropsUtil.get("ogdd.buildNumber");
    scmBranch = PropsUtil.get("ogdd.scmBranch");
  }
  private String _getPassword() {
    String login = PrincipalThreadLocal.getName();

    if (Validator.isNull(login) || _isDefaultUser(login)) {
      return PropsUtil.get(PropsKeys.DL_REPOSITORY_GUEST_PASSWORD);
    }

    return PrincipalThreadLocal.getPassword();
  }
  public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
      return _servletContextName;
    }

    synchronized (ClpSerializer.class) {
      if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
      }

      try {
        ClassLoader classLoader = ClpSerializer.class.getClassLoader();

        Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

        Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] {String.class});

        String portletPropsServletContextName =
            (String)
                getMethod.invoke(
                    null,
                    "com.liferay.portal.content.targeting.rule.score.points-deployment-context");

        if (Validator.isNotNull(portletPropsServletContextName)) {
          _servletContextName = portletPropsServletContextName;
        }
      } catch (Throwable t) {
        if (_log.isInfoEnabled()) {
          _log.info("Unable to locate deployment context from portlet properties");
        }
      }

      if (Validator.isNull(_servletContextName)) {
        try {
          String propsUtilServletContextName =
              PropsUtil.get(
                  "com.liferay.portal.content.targeting.rule.score.points-deployment-context");

          if (Validator.isNotNull(propsUtilServletContextName)) {
            _servletContextName = propsUtilServletContextName;
          }
        } catch (Throwable t) {
          if (_log.isInfoEnabled()) {
            _log.info("Unable to locate deployment context from portal properties");
          }
        }
      }

      if (Validator.isNull(_servletContextName)) {
        _servletContextName = "com.liferay.portal.content.targeting.rule.score.points";
      }

      return _servletContextName;
    }
  }
Esempio n. 9
0
  public static boolean isValidMessageFormat(String messageFormat) {
    String editorImpl = PropsUtil.get(BB_CODE_EDITOR_WYSIWYG_IMPL_KEY);

    if (messageFormat.equals("bbcode")
        && !(editorImpl.equals("bbcode") || editorImpl.equals("ckeditor_bbcode"))) {

      return false;
    }

    return true;
  }
Esempio n. 10
0
  public static String getMessageFormat(PortletPreferences preferences) {
    String messageFormat = preferences.getValue("messageFormat", MBMessageConstants.DEFAULT_FORMAT);

    String editorImpl = PropsUtil.get(BB_CODE_EDITOR_WYSIWYG_IMPL_KEY);

    if (messageFormat.equals("bbcode")
        && !(editorImpl.equals("bbcode") || editorImpl.equals("ckeditor_bbcode"))) {

      messageFormat = "html";
    }

    return messageFormat;
  }
  private Map<String, String> _getPrivateField(String privateFieldName) {
    Map<String, String> privateField = new HashMap<String, String>();

    String dataType =
        PropsUtil.get(
            PropsKeys.DYNAMIC_DATA_MAPPING_STRUCTURE_PRIVATE_FIELD_DATATYPE,
            new Filter(privateFieldName));

    privateField.put("dataType", dataType);

    privateField.put("name", privateFieldName);
    privateField.put("private", Boolean.TRUE.toString());

    String repeatable =
        PropsUtil.get(
            PropsKeys.DYNAMIC_DATA_MAPPING_STRUCTURE_PRIVATE_FIELD_REPEATABLE,
            new Filter(privateFieldName));

    privateField.put("repeatable", repeatable);

    return privateField;
  }
  @After
  public void tearDown() throws Exception {
    _storeFactory.setStore(_CLASS_NAME_DB_STORE);

    _convertProcess.setParameterValues(
        new String[] {_CLASS_NAME_FILE_SYSTEM_STORE, Boolean.TRUE.toString()});

    _convertProcess.convert();

    PropsValues.DL_STORE_IMPL = PropsUtil.get(PropsKeys.DL_STORE_IMPL);

    _storeFactory.setStore(PropsValues.DL_STORE_IMPL);
  }
Esempio n. 13
0
  /**
   * Upload CSV or XML file.
   *
   * @param csvXmlFile the file
   * @return the url
   * @throws Exception
   */
  public static String uploadToDocmentLibrary(UploadedFile file) throws Exception {
    LiferayFacesContext lfc = LiferayFacesContext.getInstance();
    ThemeDisplay themeDisplay = lfc.getThemeDisplay();

    // upload file to local liferay storage
    DLFileEntry fileEntry =
        FileUtils.uploadFileToFolder(file, PropsUtil.get("image.folder.id"), themeDisplay);

    return themeDisplay.getPortalURL()
        + "/c/document_library/get_file?uuid="
        + fileEntry.getUuid()
        + "&groupId="
        + themeDisplay.getScopeGroupId();
  }
/** @author Eudaldo Alonso */
public class LayoutCommonTag extends IncludeTag {

  @Override
  protected void cleanUp() {
    _includeStaticPortlets = false;
    _includeWebServerDisplayNode = false;
  }

  @Override
  protected String getPage() {
    return _PAGE;
  }

  @Override
  protected boolean isCleanUpSetAttributes() {
    return _CLEAN_UP_SET_ATTRIBUTES;
  }

  @Override
  protected void setAttributes(HttpServletRequest request) {
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

    if (!themeDisplay.isFacebook()
        && !themeDisplay.isStateExclusive()
        && !themeDisplay.isStatePopUp()
        && !themeDisplay.isWidget()) {

      _includeStaticPortlets = true;
    }

    request.setAttribute("liferay-ui:layout-common:includeStaticPortlets", _includeStaticPortlets);

    if (_WEB_SERVER_DISPLAY_NODE && !themeDisplay.isStatePopUp()) {
      _includeWebServerDisplayNode = true;
    }

    request.setAttribute(
        "liferay-ui:layout-common:includeWebServerDisplayNode", _includeWebServerDisplayNode);
  }

  private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;

  private static final String _PAGE = "/html/taglib/ui/layout_common/page.jsp";

  private static final boolean _WEB_SERVER_DISPLAY_NODE =
      GetterUtil.getBoolean(PropsUtil.get(PropsKeys.WEB_SERVER_DISPLAY_NODE));

  private boolean _includeStaticPortlets;
  private boolean _includeWebServerDisplayNode;
}
  protected void initializeRootDir() {
    String path = getRootDirName();

    _rootDir = new File(path);

    if (!_rootDir.isAbsolute()) {
      _rootDir = new File(PropsUtil.get(PropsKeys.LIFERAY_HOME), path);
    }

    try {
      FileUtil.mkdirs(_rootDir);
    } catch (IOException ioe) {
      throw new SystemException(ioe);
    }
  }
Esempio 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);
  }
  @AfterClass
  public static void tearDownClass() throws Exception {
    String hikaricpJarURL = System.clearProperty(_HIKARICP_JAR_URL);

    if (hikaricpJarURL != null) {
      PropsUtil.setProps(new PropsImpl());

      String jarName =
          PropsUtil.get(PropsKeys.SETUP_LIFERAY_POOL_PROVIDER_JAR_NAME, new Filter("hikaricp"));

      URL url = new URL(hikaricpJarURL);

      Files.move(
          Paths.get(url.toURI()),
          Paths.get("lib/portal", jarName),
          StandardCopyOption.REPLACE_EXISTING);
    }
  }
Esempio n. 18
0
  protected File getLogFile() {
    File logFile = null;

    if (ServerDetector.isJBoss()) {
      File logDirectory = new File(System.getProperty("jboss.server.log.dir"));

      logFile = new File(logDirectory, "server.log");
    } else {
      logFile =
          new File(
              PropsUtil.get(PropsKeys.LIFERAY_HOME)
                  + "/logs/liferay."
                  + getLiferayDateString()
                  + ".log");
    }

    return logFile;
  }
Esempio n. 19
0
  @Override
  public Map<Locale, String> getEmailFileEntryUpdatedBodyMap(PortletPreferences preferences) {

    Map<Locale, String> map =
        LocalizationUtil.getLocalizationMap(preferences, "emailFileEntryUpdatedBody");

    Locale defaultLocale = LocaleUtil.getSiteDefault();

    String defaultValue = map.get(defaultLocale);

    if (Validator.isNotNull(defaultValue)) {
      return map;
    }

    map.put(
        defaultLocale, ContentUtil.get(PropsUtil.get(PropsKeys.DL_EMAIL_FILE_ENTRY_UPDATED_BODY)));

    return map;
  }
  @Override
  public Map<Locale, String> getEmailAssetEntryAddedSubjectMap(PortletPreferences preferences) {

    Map<Locale, String> map =
        LocalizationUtil.getLocalizationMap(preferences, "emailAssetEntryAddedSubject");

    Locale defaultLocale = LocaleUtil.getDefault();

    String defaultValue = map.get(defaultLocale);

    if (Validator.isNotNull(defaultValue)) {
      return map;
    }

    map.put(
        defaultLocale,
        ContentUtil.get(PropsUtil.get(PropsKeys.ASSET_PUBLISHER_EMAIL_ASSET_ENTRY_ADDED_SUBJECT)));

    return map;
  }
  public static String getLogin(boolean encodeLogin) throws Exception {
    String login = null;

    String authType = GetterUtil.getString(PropsUtil.get(PropsKeys.COMPANY_SECURITY_AUTH_TYPE));

    User user = TestPropsValues.getUser();

    if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) {
      login = user.getEmailAddress();

      if (encodeLogin) {
        login = HttpUtil.encodeURL(login);
      }
    } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) {
      login = user.getScreenName();
    } else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) {
      login = Long.toString(TestPropsValues.getUserId());
    }

    return login;
  }
Esempio n. 22
0
  protected boolean isThumbnailEnabled(int index) throws Exception {
    if (index == THUMBNAIL_INDEX_DEFAULT) {
      if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_ENABLED))) {

        return true;
      }
    } else if (index == THUMBNAIL_INDEX_CUSTOM_1) {
      if ((PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_1_MAX_HEIGHT) > 0)
          || (PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_1_MAX_WIDTH)
              > 0)) {

        return true;
      }
    } else if (index == THUMBNAIL_INDEX_CUSTOM_2) {
      if ((PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_2_MAX_HEIGHT) > 0)
          || (PrefsPropsUtil.getInteger(PropsKeys.DL_FILE_ENTRY_THUMBNAIL_CUSTOM_2_MAX_WIDTH)
              > 0)) {

        return true;
      }
    }

    return false;
  }
Esempio n. 23
0
/** @author Brian Wing Shun Chan */
@SuppressWarnings("deprecation")
public class TunnelUtil {

  public static Object invoke(HttpPrincipal httpPrincipal, MethodHandler methodHandler)
      throws Exception {

    HttpURLConnection urlc = _getConnection(httpPrincipal);

    ObjectOutputStream oos = new ObjectOutputStream(urlc.getOutputStream());

    oos.writeObject(
        new ObjectValuePair<HttpPrincipal, MethodHandler>(httpPrincipal, methodHandler));

    oos.flush();
    oos.close();

    Object returnObj = null;

    try {
      ObjectInputStream ois = new ObjectInputStream(urlc.getInputStream());

      returnObj = ois.readObject();

      ois.close();
    } catch (EOFException eofe) {
    } catch (IOException ioe) {
      String ioeMessage = ioe.getMessage();

      if ((ioeMessage != null) && (ioeMessage.indexOf("HTTP response code: 401") != -1)) {

        throw new PrincipalException(ioeMessage);
      } else {
        throw ioe;
      }
    }

    if ((returnObj != null) && returnObj instanceof Exception) {
      throw (Exception) returnObj;
    }

    return returnObj;
  }

  /** @deprecated */
  public static Object invoke(HttpPrincipal httpPrincipal, MethodWrapper methodWrapper)
      throws Exception {

    HttpURLConnection urlc = _getConnection(httpPrincipal);

    ObjectOutputStream oos = new ObjectOutputStream(urlc.getOutputStream());

    oos.writeObject(
        new ObjectValuePair<HttpPrincipal, MethodWrapper>(httpPrincipal, methodWrapper));

    oos.flush();
    oos.close();

    Object returnObj = null;

    try {
      ObjectInputStream ois = new ObjectInputStream(urlc.getInputStream());

      returnObj = ois.readObject();

      ois.close();
    } catch (EOFException eofe) {
    } catch (IOException ioe) {
      String ioeMessage = ioe.getMessage();

      if ((ioeMessage != null) && (ioeMessage.indexOf("HTTP response code: 401") != -1)) {

        throw new PrincipalException(ioeMessage);
      } else {
        throw ioe;
      }
    }

    if ((returnObj != null) && returnObj instanceof Exception) {
      throw (Exception) returnObj;
    }

    return returnObj;
  }

  private static HttpURLConnection _getConnection(HttpPrincipal httpPrincipal) throws IOException {

    if ((httpPrincipal == null) || (httpPrincipal.getUrl() == null)) {
      return null;
    }

    URL url = new URL(httpPrincipal.getUrl() + "/api/liferay/do");

    HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();

    httpURLConnection.setDoInput(true);
    httpURLConnection.setDoOutput(true);

    if (!_VERIFY_SSL_HOSTNAME && (httpURLConnection instanceof HttpsURLConnection)) {

      HttpsURLConnection httpsURLConnection = (HttpsURLConnection) httpURLConnection;

      httpsURLConnection.setHostnameVerifier(
          new HostnameVerifier() {

            public boolean verify(String hostname, SSLSession session) {
              return true;
            }
          });
    }

    httpURLConnection.setRequestProperty(
        HttpHeaders.CONTENT_TYPE, ContentTypes.APPLICATION_X_JAVA_SERIALIZED_OBJECT);
    httpURLConnection.setUseCaches(false);

    httpURLConnection.setRequestMethod("POST");

    if (Validator.isNotNull(httpPrincipal.getLogin())
        && Validator.isNotNull(httpPrincipal.getPassword())) {

      String userNameAndPassword =
          httpPrincipal.getLogin() + StringPool.COLON + httpPrincipal.getPassword();

      httpURLConnection.setRequestProperty(
          HttpHeaders.AUTHORIZATION,
          HttpServletRequest.BASIC_AUTH
              + StringPool.SPACE
              + Base64.encode(userNameAndPassword.getBytes()));
    }

    return httpURLConnection;
  }

  private static final boolean _VERIFY_SSL_HOSTNAME =
      GetterUtil.getBoolean(PropsUtil.get(TunnelUtil.class.getName() + ".verify.ssl.hostname"));
}
/**
 * The persistence implementation for the projects entry service.
 *
 * <p>Caching information and settings can be found in <code>portal.properties</code>
 *
 * @author Brian Wing Shun Chan
 * @see ProjectsEntryPersistence
 * @see ProjectsEntryUtil
 * @generated
 */
public class ProjectsEntryPersistenceImpl extends BasePersistenceImpl<ProjectsEntry>
    implements ProjectsEntryPersistence {
  /*
   * NOTE FOR DEVELOPERS:
   *
   * Never modify or reference this class directly. Always use {@link ProjectsEntryUtil} to access the projects entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
   */
  public static final String FINDER_CLASS_NAME_ENTITY = ProjectsEntryImpl.class.getName();
  public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION =
      FINDER_CLASS_NAME_ENTITY + ".List1";
  public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION =
      FINDER_CLASS_NAME_ENTITY + ".List2";
  public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL =
      new FinderPath(
          ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED,
          ProjectsEntryModelImpl.FINDER_CACHE_ENABLED,
          ProjectsEntryImpl.class,
          FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
          "findAll",
          new String[0]);
  public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL =
      new FinderPath(
          ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED,
          ProjectsEntryModelImpl.FINDER_CACHE_ENABLED,
          ProjectsEntryImpl.class,
          FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
          "findAll",
          new String[0]);
  public static final FinderPath FINDER_PATH_COUNT_ALL =
      new FinderPath(
          ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED,
          ProjectsEntryModelImpl.FINDER_CACHE_ENABLED,
          Long.class,
          FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
          "countAll",
          new String[0]);
  public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID =
      new FinderPath(
          ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED,
          ProjectsEntryModelImpl.FINDER_CACHE_ENABLED,
          ProjectsEntryImpl.class,
          FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
          "findByUserId",
          new String[] {
            Long.class.getName(),
            Integer.class.getName(),
            Integer.class.getName(),
            OrderByComparator.class.getName()
          });
  public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID =
      new FinderPath(
          ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED,
          ProjectsEntryModelImpl.FINDER_CACHE_ENABLED,
          ProjectsEntryImpl.class,
          FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
          "findByUserId",
          new String[] {Long.class.getName()},
          ProjectsEntryModelImpl.USERID_COLUMN_BITMASK
              | ProjectsEntryModelImpl.ENDDATE_COLUMN_BITMASK);
  public static final FinderPath FINDER_PATH_COUNT_BY_USERID =
      new FinderPath(
          ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED,
          ProjectsEntryModelImpl.FINDER_CACHE_ENABLED,
          Long.class,
          FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
          "countByUserId",
          new String[] {Long.class.getName()});

  /**
   * Returns all the projects entries where userId = &#63;.
   *
   * @param userId the user ID
   * @return the matching projects entries
   * @throws SystemException if a system exception occurred
   */
  @Override
  public List<ProjectsEntry> findByUserId(long userId) throws SystemException {
    return findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
  }

  /**
   * Returns a range of all the projects entries where userId = &#63;.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set. If <code>orderByComparator</code> is specified, then the query
   * will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and
   * pagination is required (<code>start</code> and <code>end</code> are not {@link
   * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default
   * ORDER BY logic from {@link com.liferay.so.model.impl.ProjectsEntryModelImpl}. If both <code>
   * orderByComparator</code> and pagination are absent, for performance reasons, the query will not
   * have an ORDER BY clause and the returned result set will be sorted on by the primary key in an
   * ascending order.
   *
   * @param userId the user ID
   * @param start the lower bound of the range of projects entries
   * @param end the upper bound of the range of projects entries (not inclusive)
   * @return the range of matching projects entries
   * @throws SystemException if a system exception occurred
   */
  @Override
  public List<ProjectsEntry> findByUserId(long userId, int start, int end) throws SystemException {
    return findByUserId(userId, start, end, null);
  }

  /**
   * Returns an ordered range of all the projects entries where userId = &#63;.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set. If <code>orderByComparator</code> is specified, then the query
   * will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and
   * pagination is required (<code>start</code> and <code>end</code> are not {@link
   * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default
   * ORDER BY logic from {@link com.liferay.so.model.impl.ProjectsEntryModelImpl}. If both <code>
   * orderByComparator</code> and pagination are absent, for performance reasons, the query will not
   * have an ORDER BY clause and the returned result set will be sorted on by the primary key in an
   * ascending order.
   *
   * @param userId the user ID
   * @param start the lower bound of the range of projects entries
   * @param end the upper bound of the range of projects entries (not inclusive)
   * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
   * @return the ordered range of matching projects entries
   * @throws SystemException if a system exception occurred
   */
  @Override
  public List<ProjectsEntry> findByUserId(
      long userId, int start, int end, OrderByComparator orderByComparator) throws SystemException {
    boolean pagination = true;
    FinderPath finderPath = null;
    Object[] finderArgs = null;

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
      pagination = false;
      finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID;
      finderArgs = new Object[] {userId};
    } else {
      finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_USERID;
      finderArgs = new Object[] {userId, start, end, orderByComparator};
    }

    List<ProjectsEntry> list =
        (List<ProjectsEntry>) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
      for (ProjectsEntry projectsEntry : list) {
        if ((userId != projectsEntry.getUserId())) {
          list = null;

          break;
        }
      }
    }

    if (list == null) {
      StringBundler query = null;

      if (orderByComparator != null) {
        query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3));
      } else {
        query = new StringBundler(3);
      }

      query.append(_SQL_SELECT_PROJECTSENTRY_WHERE);

      query.append(_FINDER_COLUMN_USERID_USERID_2);

      if (orderByComparator != null) {
        appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
      } else if (pagination) {
        query.append(ProjectsEntryModelImpl.ORDER_BY_JPQL);
      }

      String sql = query.toString();

      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(sql);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(userId);

        if (!pagination) {
          list = (List<ProjectsEntry>) QueryUtil.list(q, getDialect(), start, end, false);

          Collections.sort(list);

          list = Collections.unmodifiableList(list);
        } else {
          list = (List<ProjectsEntry>) QueryUtil.list(q, getDialect(), start, end);
        }

        cacheResult(list);

        FinderCacheUtil.putResult(finderPath, finderArgs, list);
      } catch (Exception e) {
        FinderCacheUtil.removeResult(finderPath, finderArgs);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return list;
  }

  /**
   * Returns the first projects entry in the ordered set where userId = &#63;.
   *
   * @param userId the user ID
   * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
   * @return the first matching projects entry
   * @throws com.liferay.so.NoSuchProjectsEntryException if a matching projects entry could not be
   *     found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProjectsEntry findByUserId_First(long userId, OrderByComparator orderByComparator)
      throws NoSuchProjectsEntryException, SystemException {
    ProjectsEntry projectsEntry = fetchByUserId_First(userId, orderByComparator);

    if (projectsEntry != null) {
      return projectsEntry;
    }

    StringBundler msg = new StringBundler(4);

    msg.append(_NO_SUCH_ENTITY_WITH_KEY);

    msg.append("userId=");
    msg.append(userId);

    msg.append(StringPool.CLOSE_CURLY_BRACE);

    throw new NoSuchProjectsEntryException(msg.toString());
  }

  /**
   * Returns the first projects entry in the ordered set where userId = &#63;.
   *
   * @param userId the user ID
   * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
   * @return the first matching projects entry, or <code>null</code> if a matching projects entry
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProjectsEntry fetchByUserId_First(long userId, OrderByComparator orderByComparator)
      throws SystemException {
    List<ProjectsEntry> list = findByUserId(userId, 0, 1, orderByComparator);

    if (!list.isEmpty()) {
      return list.get(0);
    }

    return null;
  }

  /**
   * Returns the last projects entry in the ordered set where userId = &#63;.
   *
   * @param userId the user ID
   * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
   * @return the last matching projects entry
   * @throws com.liferay.so.NoSuchProjectsEntryException if a matching projects entry could not be
   *     found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProjectsEntry findByUserId_Last(long userId, OrderByComparator orderByComparator)
      throws NoSuchProjectsEntryException, SystemException {
    ProjectsEntry projectsEntry = fetchByUserId_Last(userId, orderByComparator);

    if (projectsEntry != null) {
      return projectsEntry;
    }

    StringBundler msg = new StringBundler(4);

    msg.append(_NO_SUCH_ENTITY_WITH_KEY);

    msg.append("userId=");
    msg.append(userId);

    msg.append(StringPool.CLOSE_CURLY_BRACE);

    throw new NoSuchProjectsEntryException(msg.toString());
  }

  /**
   * Returns the last projects entry in the ordered set where userId = &#63;.
   *
   * @param userId the user ID
   * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
   * @return the last matching projects entry, or <code>null</code> if a matching projects entry
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProjectsEntry fetchByUserId_Last(long userId, OrderByComparator orderByComparator)
      throws SystemException {
    int count = countByUserId(userId);

    if (count == 0) {
      return null;
    }

    List<ProjectsEntry> list = findByUserId(userId, count - 1, count, orderByComparator);

    if (!list.isEmpty()) {
      return list.get(0);
    }

    return null;
  }

  /**
   * Returns the projects entries before and after the current projects entry in the ordered set
   * where userId = &#63;.
   *
   * @param projectsEntryId the primary key of the current projects entry
   * @param userId the user ID
   * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
   * @return the previous, current, and next projects entry
   * @throws com.liferay.so.NoSuchProjectsEntryException if a projects entry with the primary key
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProjectsEntry[] findByUserId_PrevAndNext(
      long projectsEntryId, long userId, OrderByComparator orderByComparator)
      throws NoSuchProjectsEntryException, SystemException {
    ProjectsEntry projectsEntry = findByPrimaryKey(projectsEntryId);

    Session session = null;

    try {
      session = openSession();

      ProjectsEntry[] array = new ProjectsEntryImpl[3];

      array[0] = getByUserId_PrevAndNext(session, projectsEntry, userId, orderByComparator, true);

      array[1] = projectsEntry;

      array[2] = getByUserId_PrevAndNext(session, projectsEntry, userId, orderByComparator, false);

      return array;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }

  protected ProjectsEntry getByUserId_PrevAndNext(
      Session session,
      ProjectsEntry projectsEntry,
      long userId,
      OrderByComparator orderByComparator,
      boolean previous) {
    StringBundler query = null;

    if (orderByComparator != null) {
      query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6));
    } else {
      query = new StringBundler(3);
    }

    query.append(_SQL_SELECT_PROJECTSENTRY_WHERE);

    query.append(_FINDER_COLUMN_USERID_USERID_2);

    if (orderByComparator != null) {
      String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();

      if (orderByConditionFields.length > 0) {
        query.append(WHERE_AND);
      }

      for (int i = 0; i < orderByConditionFields.length; i++) {
        query.append(_ORDER_BY_ENTITY_ALIAS);
        query.append(orderByConditionFields[i]);

        if ((i + 1) < orderByConditionFields.length) {
          if (orderByComparator.isAscending() ^ previous) {
            query.append(WHERE_GREATER_THAN_HAS_NEXT);
          } else {
            query.append(WHERE_LESSER_THAN_HAS_NEXT);
          }
        } else {
          if (orderByComparator.isAscending() ^ previous) {
            query.append(WHERE_GREATER_THAN);
          } else {
            query.append(WHERE_LESSER_THAN);
          }
        }
      }

      query.append(ORDER_BY_CLAUSE);

      String[] orderByFields = orderByComparator.getOrderByFields();

      for (int i = 0; i < orderByFields.length; i++) {
        query.append(_ORDER_BY_ENTITY_ALIAS);
        query.append(orderByFields[i]);

        if ((i + 1) < orderByFields.length) {
          if (orderByComparator.isAscending() ^ previous) {
            query.append(ORDER_BY_ASC_HAS_NEXT);
          } else {
            query.append(ORDER_BY_DESC_HAS_NEXT);
          }
        } else {
          if (orderByComparator.isAscending() ^ previous) {
            query.append(ORDER_BY_ASC);
          } else {
            query.append(ORDER_BY_DESC);
          }
        }
      }
    } else {
      query.append(ProjectsEntryModelImpl.ORDER_BY_JPQL);
    }

    String sql = query.toString();

    Query q = session.createQuery(sql);

    q.setFirstResult(0);
    q.setMaxResults(2);

    QueryPos qPos = QueryPos.getInstance(q);

    qPos.add(userId);

    if (orderByComparator != null) {
      Object[] values = orderByComparator.getOrderByConditionValues(projectsEntry);

      for (Object value : values) {
        qPos.add(value);
      }
    }

    List<ProjectsEntry> list = q.list();

    if (list.size() == 2) {
      return list.get(1);
    } else {
      return null;
    }
  }

  /**
   * Removes all the projects entries where userId = &#63; from the database.
   *
   * @param userId the user ID
   * @throws SystemException if a system exception occurred
   */
  @Override
  public void removeByUserId(long userId) throws SystemException {
    for (ProjectsEntry projectsEntry :
        findByUserId(userId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
      remove(projectsEntry);
    }
  }

  /**
   * Returns the number of projects entries where userId = &#63;.
   *
   * @param userId the user ID
   * @return the number of matching projects entries
   * @throws SystemException if a system exception occurred
   */
  @Override
  public int countByUserId(long userId) throws SystemException {
    FinderPath finderPath = FINDER_PATH_COUNT_BY_USERID;

    Object[] finderArgs = new Object[] {userId};

    Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (count == null) {
      StringBundler query = new StringBundler(2);

      query.append(_SQL_COUNT_PROJECTSENTRY_WHERE);

      query.append(_FINDER_COLUMN_USERID_USERID_2);

      String sql = query.toString();

      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(sql);

        QueryPos qPos = QueryPos.getInstance(q);

        qPos.add(userId);

        count = (Long) q.uniqueResult();

        FinderCacheUtil.putResult(finderPath, finderArgs, count);
      } catch (Exception e) {
        FinderCacheUtil.removeResult(finderPath, finderArgs);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return count.intValue();
  }

  private static final String _FINDER_COLUMN_USERID_USERID_2 = "projectsEntry.userId = ?";

  public ProjectsEntryPersistenceImpl() {
    setModelClass(ProjectsEntry.class);
  }

  /**
   * Caches the projects entry in the entity cache if it is enabled.
   *
   * @param projectsEntry the projects entry
   */
  @Override
  public void cacheResult(ProjectsEntry projectsEntry) {
    EntityCacheUtil.putResult(
        ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED,
        ProjectsEntryImpl.class,
        projectsEntry.getPrimaryKey(),
        projectsEntry);

    projectsEntry.resetOriginalValues();
  }

  /**
   * Caches the projects entries in the entity cache if it is enabled.
   *
   * @param projectsEntries the projects entries
   */
  @Override
  public void cacheResult(List<ProjectsEntry> projectsEntries) {
    for (ProjectsEntry projectsEntry : projectsEntries) {
      if (EntityCacheUtil.getResult(
              ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED,
              ProjectsEntryImpl.class,
              projectsEntry.getPrimaryKey())
          == null) {
        cacheResult(projectsEntry);
      } else {
        projectsEntry.resetOriginalValues();
      }
    }
  }

  /**
   * Clears the cache for all projects entries.
   *
   * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link
   * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
   */
  @Override
  public void clearCache() {
    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      CacheRegistryUtil.clear(ProjectsEntryImpl.class.getName());
    }

    EntityCacheUtil.clearCache(ProjectsEntryImpl.class);

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }

  /**
   * Clears the cache for the projects entry.
   *
   * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link
   * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
   */
  @Override
  public void clearCache(ProjectsEntry projectsEntry) {
    EntityCacheUtil.removeResult(
        ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED,
        ProjectsEntryImpl.class,
        projectsEntry.getPrimaryKey());

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }

  @Override
  public void clearCache(List<ProjectsEntry> projectsEntries) {
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);

    for (ProjectsEntry projectsEntry : projectsEntries) {
      EntityCacheUtil.removeResult(
          ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED,
          ProjectsEntryImpl.class,
          projectsEntry.getPrimaryKey());
    }
  }

  /**
   * Creates a new projects entry with the primary key. Does not add the projects entry to the
   * database.
   *
   * @param projectsEntryId the primary key for the new projects entry
   * @return the new projects entry
   */
  @Override
  public ProjectsEntry create(long projectsEntryId) {
    ProjectsEntry projectsEntry = new ProjectsEntryImpl();

    projectsEntry.setNew(true);
    projectsEntry.setPrimaryKey(projectsEntryId);

    return projectsEntry;
  }

  /**
   * Removes the projects entry with the primary key from the database. Also notifies the
   * appropriate model listeners.
   *
   * @param projectsEntryId the primary key of the projects entry
   * @return the projects entry that was removed
   * @throws com.liferay.so.NoSuchProjectsEntryException if a projects entry with the primary key
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProjectsEntry remove(long projectsEntryId)
      throws NoSuchProjectsEntryException, SystemException {
    return remove((Serializable) projectsEntryId);
  }

  /**
   * Removes the projects entry with the primary key from the database. Also notifies the
   * appropriate model listeners.
   *
   * @param primaryKey the primary key of the projects entry
   * @return the projects entry that was removed
   * @throws com.liferay.so.NoSuchProjectsEntryException if a projects entry with the primary key
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProjectsEntry remove(Serializable primaryKey)
      throws NoSuchProjectsEntryException, SystemException {
    Session session = null;

    try {
      session = openSession();

      ProjectsEntry projectsEntry =
          (ProjectsEntry) session.get(ProjectsEntryImpl.class, primaryKey);

      if (projectsEntry == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchProjectsEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(projectsEntry);
    } catch (NoSuchProjectsEntryException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }

  @Override
  protected ProjectsEntry removeImpl(ProjectsEntry projectsEntry) throws SystemException {
    projectsEntry = toUnwrappedModel(projectsEntry);

    Session session = null;

    try {
      session = openSession();

      if (!session.contains(projectsEntry)) {
        projectsEntry =
            (ProjectsEntry) session.get(ProjectsEntryImpl.class, projectsEntry.getPrimaryKeyObj());
      }

      if (projectsEntry != null) {
        session.delete(projectsEntry);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    if (projectsEntry != null) {
      clearCache(projectsEntry);
    }

    return projectsEntry;
  }

  @Override
  public ProjectsEntry updateImpl(com.liferay.so.model.ProjectsEntry projectsEntry)
      throws SystemException {
    projectsEntry = toUnwrappedModel(projectsEntry);

    boolean isNew = projectsEntry.isNew();

    ProjectsEntryModelImpl projectsEntryModelImpl = (ProjectsEntryModelImpl) projectsEntry;

    Session session = null;

    try {
      session = openSession();

      if (projectsEntry.isNew()) {
        session.save(projectsEntry);

        projectsEntry.setNew(false);
      } else {
        session.merge(projectsEntry);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !ProjectsEntryModelImpl.COLUMN_BITMASK_ENABLED) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    } else {
      if ((projectsEntryModelImpl.getColumnBitmask()
              & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID.getColumnBitmask())
          != 0) {
        Object[] args = new Object[] {projectsEntryModelImpl.getOriginalUserId()};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID, args);

        args = new Object[] {projectsEntryModelImpl.getUserId()};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_USERID, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_USERID, args);
      }
    }

    EntityCacheUtil.putResult(
        ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED,
        ProjectsEntryImpl.class,
        projectsEntry.getPrimaryKey(),
        projectsEntry,
        false);

    projectsEntry.resetOriginalValues();

    return projectsEntry;
  }

  protected ProjectsEntry toUnwrappedModel(ProjectsEntry projectsEntry) {
    if (projectsEntry instanceof ProjectsEntryImpl) {
      return projectsEntry;
    }

    ProjectsEntryImpl projectsEntryImpl = new ProjectsEntryImpl();

    projectsEntryImpl.setNew(projectsEntry.isNew());
    projectsEntryImpl.setPrimaryKey(projectsEntry.getPrimaryKey());

    projectsEntryImpl.setProjectsEntryId(projectsEntry.getProjectsEntryId());
    projectsEntryImpl.setCompanyId(projectsEntry.getCompanyId());
    projectsEntryImpl.setUserId(projectsEntry.getUserId());
    projectsEntryImpl.setUserName(projectsEntry.getUserName());
    projectsEntryImpl.setCreateDate(projectsEntry.getCreateDate());
    projectsEntryImpl.setModifiedDate(projectsEntry.getModifiedDate());
    projectsEntryImpl.setTitle(projectsEntry.getTitle());
    projectsEntryImpl.setDescription(projectsEntry.getDescription());
    projectsEntryImpl.setStartDate(projectsEntry.getStartDate());
    projectsEntryImpl.setEndDate(projectsEntry.getEndDate());
    projectsEntryImpl.setData(projectsEntry.getData());

    return projectsEntryImpl;
  }

  /**
   * Returns the projects entry with the primary key or throws a {@link
   * com.liferay.portal.NoSuchModelException} if it could not be found.
   *
   * @param primaryKey the primary key of the projects entry
   * @return the projects entry
   * @throws com.liferay.so.NoSuchProjectsEntryException if a projects entry with the primary key
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProjectsEntry findByPrimaryKey(Serializable primaryKey)
      throws NoSuchProjectsEntryException, SystemException {
    ProjectsEntry projectsEntry = fetchByPrimaryKey(primaryKey);

    if (projectsEntry == null) {
      if (_log.isWarnEnabled()) {
        _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      throw new NoSuchProjectsEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
    }

    return projectsEntry;
  }

  /**
   * Returns the projects entry with the primary key or throws a {@link
   * com.liferay.so.NoSuchProjectsEntryException} if it could not be found.
   *
   * @param projectsEntryId the primary key of the projects entry
   * @return the projects entry
   * @throws com.liferay.so.NoSuchProjectsEntryException if a projects entry with the primary key
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProjectsEntry findByPrimaryKey(long projectsEntryId)
      throws NoSuchProjectsEntryException, SystemException {
    return findByPrimaryKey((Serializable) projectsEntryId);
  }

  /**
   * Returns the projects entry with the primary key or returns <code>null</code> if it could not be
   * found.
   *
   * @param primaryKey the primary key of the projects entry
   * @return the projects entry, or <code>null</code> if a projects entry with the primary key could
   *     not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProjectsEntry fetchByPrimaryKey(Serializable primaryKey) throws SystemException {
    ProjectsEntry projectsEntry =
        (ProjectsEntry)
            EntityCacheUtil.getResult(
                ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED, ProjectsEntryImpl.class, primaryKey);

    if (projectsEntry == _nullProjectsEntry) {
      return null;
    }

    if (projectsEntry == null) {
      Session session = null;

      try {
        session = openSession();

        projectsEntry = (ProjectsEntry) session.get(ProjectsEntryImpl.class, primaryKey);

        if (projectsEntry != null) {
          cacheResult(projectsEntry);
        } else {
          EntityCacheUtil.putResult(
              ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED,
              ProjectsEntryImpl.class,
              primaryKey,
              _nullProjectsEntry);
        }
      } catch (Exception e) {
        EntityCacheUtil.removeResult(
            ProjectsEntryModelImpl.ENTITY_CACHE_ENABLED, ProjectsEntryImpl.class, primaryKey);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return projectsEntry;
  }

  /**
   * Returns the projects entry with the primary key or returns <code>null</code> if it could not be
   * found.
   *
   * @param projectsEntryId the primary key of the projects entry
   * @return the projects entry, or <code>null</code> if a projects entry with the primary key could
   *     not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public ProjectsEntry fetchByPrimaryKey(long projectsEntryId) throws SystemException {
    return fetchByPrimaryKey((Serializable) projectsEntryId);
  }

  /**
   * Returns all the projects entries.
   *
   * @return the projects entries
   * @throws SystemException if a system exception occurred
   */
  @Override
  public List<ProjectsEntry> findAll() throws SystemException {
    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
  }

  /**
   * Returns a range of all the projects entries.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set. If <code>orderByComparator</code> is specified, then the query
   * will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and
   * pagination is required (<code>start</code> and <code>end</code> are not {@link
   * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default
   * ORDER BY logic from {@link com.liferay.so.model.impl.ProjectsEntryModelImpl}. If both <code>
   * orderByComparator</code> and pagination are absent, for performance reasons, the query will not
   * have an ORDER BY clause and the returned result set will be sorted on by the primary key in an
   * ascending order.
   *
   * @param start the lower bound of the range of projects entries
   * @param end the upper bound of the range of projects entries (not inclusive)
   * @return the range of projects entries
   * @throws SystemException if a system exception occurred
   */
  @Override
  public List<ProjectsEntry> findAll(int start, int end) throws SystemException {
    return findAll(start, end, null);
  }

  /**
   * Returns an ordered range of all the projects entries.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set. If <code>orderByComparator</code> is specified, then the query
   * will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and
   * pagination is required (<code>start</code> and <code>end</code> are not {@link
   * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default
   * ORDER BY logic from {@link com.liferay.so.model.impl.ProjectsEntryModelImpl}. If both <code>
   * orderByComparator</code> and pagination are absent, for performance reasons, the query will not
   * have an ORDER BY clause and the returned result set will be sorted on by the primary key in an
   * ascending order.
   *
   * @param start the lower bound of the range of projects entries
   * @param end the upper bound of the range of projects entries (not inclusive)
   * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
   * @return the ordered range of projects entries
   * @throws SystemException if a system exception occurred
   */
  @Override
  public List<ProjectsEntry> findAll(int start, int end, OrderByComparator orderByComparator)
      throws SystemException {
    boolean pagination = true;
    FinderPath finderPath = null;
    Object[] finderArgs = null;

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
      pagination = false;
      finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
      finderArgs = FINDER_ARGS_EMPTY;
    } else {
      finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
      finderArgs = new Object[] {start, end, orderByComparator};
    }

    List<ProjectsEntry> list =
        (List<ProjectsEntry>) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (list == null) {
      StringBundler query = null;
      String sql = null;

      if (orderByComparator != null) {
        query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 3));

        query.append(_SQL_SELECT_PROJECTSENTRY);

        appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);

        sql = query.toString();
      } else {
        sql = _SQL_SELECT_PROJECTSENTRY;

        if (pagination) {
          sql = sql.concat(ProjectsEntryModelImpl.ORDER_BY_JPQL);
        }
      }

      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(sql);

        if (!pagination) {
          list = (List<ProjectsEntry>) QueryUtil.list(q, getDialect(), start, end, false);

          Collections.sort(list);

          list = Collections.unmodifiableList(list);
        } else {
          list = (List<ProjectsEntry>) QueryUtil.list(q, getDialect(), start, end);
        }

        cacheResult(list);

        FinderCacheUtil.putResult(finderPath, finderArgs, list);
      } catch (Exception e) {
        FinderCacheUtil.removeResult(finderPath, finderArgs);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return list;
  }

  /**
   * Removes all the projects entries from the database.
   *
   * @throws SystemException if a system exception occurred
   */
  @Override
  public void removeAll() throws SystemException {
    for (ProjectsEntry projectsEntry : findAll()) {
      remove(projectsEntry);
    }
  }

  /**
   * Returns the number of projects entries.
   *
   * @return the number of projects entries
   * @throws SystemException if a system exception occurred
   */
  @Override
  public int countAll() throws SystemException {
    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this);

    if (count == null) {
      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(_SQL_COUNT_PROJECTSENTRY);

        count = (Long) q.uniqueResult();

        FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count);
      } catch (Exception e) {
        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return count.intValue();
  }

  @Override
  protected Set<String> getBadColumnNames() {
    return _badColumnNames;
  }

  /** Initializes the projects entry persistence. */
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.util.service.ServiceProps.get(
                    "value.object.listener.com.liferay.so.model.ProjectsEntry")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<ProjectsEntry>> listenersList =
            new ArrayList<ModelListener<ProjectsEntry>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add(
              (ModelListener<ProjectsEntry>)
                  InstanceFactory.newInstance(getClassLoader(), listenerClassName));
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }
  }

  public void destroy() {
    EntityCacheUtil.removeCache(ProjectsEntryImpl.class.getName());
    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }

  private static final String _SQL_SELECT_PROJECTSENTRY =
      "SELECT projectsEntry FROM ProjectsEntry projectsEntry";
  private static final String _SQL_SELECT_PROJECTSENTRY_WHERE =
      "SELECT projectsEntry FROM ProjectsEntry projectsEntry WHERE ";
  private static final String _SQL_COUNT_PROJECTSENTRY =
      "SELECT COUNT(projectsEntry) FROM ProjectsEntry projectsEntry";
  private static final String _SQL_COUNT_PROJECTSENTRY_WHERE =
      "SELECT COUNT(projectsEntry) FROM ProjectsEntry projectsEntry WHERE ";
  private static final String _ORDER_BY_ENTITY_ALIAS = "projectsEntry.";
  private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY =
      "No ProjectsEntry exists with the primary key ";
  private static final String _NO_SUCH_ENTITY_WITH_KEY = "No ProjectsEntry exists with the key {";
  private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE =
      GetterUtil.getBoolean(PropsUtil.get(PropsKeys.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE));
  private static Log _log = LogFactoryUtil.getLog(ProjectsEntryPersistenceImpl.class);
  private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {"data"});
  private static ProjectsEntry _nullProjectsEntry =
      new ProjectsEntryImpl() {
        @Override
        public Object clone() {
          return this;
        }

        @Override
        public CacheModel<ProjectsEntry> toCacheModel() {
          return _nullProjectsEntryCacheModel;
        }
      };

  private static CacheModel<ProjectsEntry> _nullProjectsEntryCacheModel =
      new CacheModel<ProjectsEntry>() {
        @Override
        public ProjectsEntry toEntityModel() {
          return _nullProjectsEntry;
        }
      };
}
/**
 * The persistence implementation for the bar service.
 *
 * <p>Caching information and settings can be found in <code>portal.properties</code>
 *
 * @author Brian Wing Shun Chan
 * @see BarPersistence
 * @see BarUtil
 * @generated
 */
public class BarPersistenceImpl extends BasePersistenceImpl<Bar> implements BarPersistence {
  /*
   * NOTE FOR DEVELOPERS:
   *
   * Never modify or reference this class directly. Always use {@link BarUtil} to access the bar persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
   */
  public static final String FINDER_CLASS_NAME_ENTITY = BarImpl.class.getName();
  public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION =
      FINDER_CLASS_NAME_ENTITY + ".List1";
  public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION =
      FINDER_CLASS_NAME_ENTITY + ".List2";
  public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL =
      new FinderPath(
          BarModelImpl.ENTITY_CACHE_ENABLED,
          BarModelImpl.FINDER_CACHE_ENABLED,
          BarImpl.class,
          FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
          "findAll",
          new String[0]);
  public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL =
      new FinderPath(
          BarModelImpl.ENTITY_CACHE_ENABLED,
          BarModelImpl.FINDER_CACHE_ENABLED,
          BarImpl.class,
          FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
          "findAll",
          new String[0]);
  public static final FinderPath FINDER_PATH_COUNT_ALL =
      new FinderPath(
          BarModelImpl.ENTITY_CACHE_ENABLED,
          BarModelImpl.FINDER_CACHE_ENABLED,
          Long.class,
          FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
          "countAll",
          new String[0]);
  public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_TEXT =
      new FinderPath(
          BarModelImpl.ENTITY_CACHE_ENABLED,
          BarModelImpl.FINDER_CACHE_ENABLED,
          BarImpl.class,
          FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
          "findByText",
          new String[] {
            String.class.getName(),
            Integer.class.getName(),
            Integer.class.getName(),
            OrderByComparator.class.getName()
          });
  public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEXT =
      new FinderPath(
          BarModelImpl.ENTITY_CACHE_ENABLED,
          BarModelImpl.FINDER_CACHE_ENABLED,
          BarImpl.class,
          FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
          "findByText",
          new String[] {String.class.getName()},
          BarModelImpl.TEXT_COLUMN_BITMASK);
  public static final FinderPath FINDER_PATH_COUNT_BY_TEXT =
      new FinderPath(
          BarModelImpl.ENTITY_CACHE_ENABLED,
          BarModelImpl.FINDER_CACHE_ENABLED,
          Long.class,
          FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
          "countByText",
          new String[] {String.class.getName()});

  /**
   * Returns all the bars where text = &#63;.
   *
   * @param text the text
   * @return the matching bars
   */
  @Override
  public List<Bar> findByText(String text) {
    return findByText(text, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
  }

  /**
   * Returns a range of all the bars where text = &#63;.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set. If <code>orderByComparator</code> is specified, then the query
   * will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and
   * pagination is required (<code>start</code> and <code>end</code> are not {@link
   * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default
   * ORDER BY logic from {@link com.liferay.testtransaction.model.impl.BarModelImpl}. If both <code>
   * orderByComparator</code> and pagination are absent, for performance reasons, the query will not
   * have an ORDER BY clause and the returned result set will be sorted on by the primary key in an
   * ascending order.
   *
   * @param text the text
   * @param start the lower bound of the range of bars
   * @param end the upper bound of the range of bars (not inclusive)
   * @return the range of matching bars
   */
  @Override
  public List<Bar> findByText(String text, int start, int end) {
    return findByText(text, start, end, null);
  }

  /**
   * Returns an ordered range of all the bars where text = &#63;.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set. If <code>orderByComparator</code> is specified, then the query
   * will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and
   * pagination is required (<code>start</code> and <code>end</code> are not {@link
   * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default
   * ORDER BY logic from {@link com.liferay.testtransaction.model.impl.BarModelImpl}. If both <code>
   * orderByComparator</code> and pagination are absent, for performance reasons, the query will not
   * have an ORDER BY clause and the returned result set will be sorted on by the primary key in an
   * ascending order.
   *
   * @param text the text
   * @param start the lower bound of the range of bars
   * @param end the upper bound of the range of bars (not inclusive)
   * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
   * @return the ordered range of matching bars
   */
  @Override
  public List<Bar> findByText(
      String text, int start, int end, OrderByComparator<Bar> orderByComparator) {
    boolean pagination = true;
    FinderPath finderPath = null;
    Object[] finderArgs = null;

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
      pagination = false;
      finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEXT;
      finderArgs = new Object[] {text};
    } else {
      finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_TEXT;
      finderArgs = new Object[] {text, start, end, orderByComparator};
    }

    List<Bar> list = (List<Bar>) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if ((list != null) && !list.isEmpty()) {
      for (Bar bar : list) {
        if (!Validator.equals(text, bar.getText())) {
          list = null;

          break;
        }
      }
    }

    if (list == null) {
      StringBundler query = null;

      if (orderByComparator != null) {
        query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3));
      } else {
        query = new StringBundler(3);
      }

      query.append(_SQL_SELECT_BAR_WHERE);

      boolean bindText = false;

      if (text == null) {
        query.append(_FINDER_COLUMN_TEXT_TEXT_1);
      } else if (text.equals(StringPool.BLANK)) {
        query.append(_FINDER_COLUMN_TEXT_TEXT_3);
      } else {
        bindText = true;

        query.append(_FINDER_COLUMN_TEXT_TEXT_2);
      }

      if (orderByComparator != null) {
        appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);
      } else if (pagination) {
        query.append(BarModelImpl.ORDER_BY_JPQL);
      }

      String sql = query.toString();

      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(sql);

        QueryPos qPos = QueryPos.getInstance(q);

        if (bindText) {
          qPos.add(text);
        }

        if (!pagination) {
          list = (List<Bar>) QueryUtil.list(q, getDialect(), start, end, false);

          Collections.sort(list);

          list = Collections.unmodifiableList(list);
        } else {
          list = (List<Bar>) QueryUtil.list(q, getDialect(), start, end);
        }

        cacheResult(list);

        FinderCacheUtil.putResult(finderPath, finderArgs, list);
      } catch (Exception e) {
        FinderCacheUtil.removeResult(finderPath, finderArgs);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return list;
  }

  /**
   * Returns the first bar in the ordered set where text = &#63;.
   *
   * @param text the text
   * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
   * @return the first matching bar
   * @throws com.liferay.testtransaction.NoSuchBarException if a matching bar could not be found
   */
  @Override
  public Bar findByText_First(String text, OrderByComparator<Bar> orderByComparator)
      throws NoSuchBarException {
    Bar bar = fetchByText_First(text, orderByComparator);

    if (bar != null) {
      return bar;
    }

    StringBundler msg = new StringBundler(4);

    msg.append(_NO_SUCH_ENTITY_WITH_KEY);

    msg.append("text=");
    msg.append(text);

    msg.append(StringPool.CLOSE_CURLY_BRACE);

    throw new NoSuchBarException(msg.toString());
  }

  /**
   * Returns the first bar in the ordered set where text = &#63;.
   *
   * @param text the text
   * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
   * @return the first matching bar, or <code>null</code> if a matching bar could not be found
   */
  @Override
  public Bar fetchByText_First(String text, OrderByComparator<Bar> orderByComparator) {
    List<Bar> list = findByText(text, 0, 1, orderByComparator);

    if (!list.isEmpty()) {
      return list.get(0);
    }

    return null;
  }

  /**
   * Returns the last bar in the ordered set where text = &#63;.
   *
   * @param text the text
   * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
   * @return the last matching bar
   * @throws com.liferay.testtransaction.NoSuchBarException if a matching bar could not be found
   */
  @Override
  public Bar findByText_Last(String text, OrderByComparator<Bar> orderByComparator)
      throws NoSuchBarException {
    Bar bar = fetchByText_Last(text, orderByComparator);

    if (bar != null) {
      return bar;
    }

    StringBundler msg = new StringBundler(4);

    msg.append(_NO_SUCH_ENTITY_WITH_KEY);

    msg.append("text=");
    msg.append(text);

    msg.append(StringPool.CLOSE_CURLY_BRACE);

    throw new NoSuchBarException(msg.toString());
  }

  /**
   * Returns the last bar in the ordered set where text = &#63;.
   *
   * @param text the text
   * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
   * @return the last matching bar, or <code>null</code> if a matching bar could not be found
   */
  @Override
  public Bar fetchByText_Last(String text, OrderByComparator<Bar> orderByComparator) {
    int count = countByText(text);

    if (count == 0) {
      return null;
    }

    List<Bar> list = findByText(text, count - 1, count, orderByComparator);

    if (!list.isEmpty()) {
      return list.get(0);
    }

    return null;
  }

  /**
   * Returns the bars before and after the current bar in the ordered set where text = &#63;.
   *
   * @param barId the primary key of the current bar
   * @param text the text
   * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
   * @return the previous, current, and next bar
   * @throws com.liferay.testtransaction.NoSuchBarException if a bar with the primary key could not
   *     be found
   */
  @Override
  public Bar[] findByText_PrevAndNext(
      long barId, String text, OrderByComparator<Bar> orderByComparator) throws NoSuchBarException {
    Bar bar = findByPrimaryKey(barId);

    Session session = null;

    try {
      session = openSession();

      Bar[] array = new BarImpl[3];

      array[0] = getByText_PrevAndNext(session, bar, text, orderByComparator, true);

      array[1] = bar;

      array[2] = getByText_PrevAndNext(session, bar, text, orderByComparator, false);

      return array;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }

  protected Bar getByText_PrevAndNext(
      Session session,
      Bar bar,
      String text,
      OrderByComparator<Bar> orderByComparator,
      boolean previous) {
    StringBundler query = null;

    if (orderByComparator != null) {
      query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6));
    } else {
      query = new StringBundler(3);
    }

    query.append(_SQL_SELECT_BAR_WHERE);

    boolean bindText = false;

    if (text == null) {
      query.append(_FINDER_COLUMN_TEXT_TEXT_1);
    } else if (text.equals(StringPool.BLANK)) {
      query.append(_FINDER_COLUMN_TEXT_TEXT_3);
    } else {
      bindText = true;

      query.append(_FINDER_COLUMN_TEXT_TEXT_2);
    }

    if (orderByComparator != null) {
      String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();

      if (orderByConditionFields.length > 0) {
        query.append(WHERE_AND);
      }

      for (int i = 0; i < orderByConditionFields.length; i++) {
        query.append(_ORDER_BY_ENTITY_ALIAS);
        query.append(orderByConditionFields[i]);

        if ((i + 1) < orderByConditionFields.length) {
          if (orderByComparator.isAscending() ^ previous) {
            query.append(WHERE_GREATER_THAN_HAS_NEXT);
          } else {
            query.append(WHERE_LESSER_THAN_HAS_NEXT);
          }
        } else {
          if (orderByComparator.isAscending() ^ previous) {
            query.append(WHERE_GREATER_THAN);
          } else {
            query.append(WHERE_LESSER_THAN);
          }
        }
      }

      query.append(ORDER_BY_CLAUSE);

      String[] orderByFields = orderByComparator.getOrderByFields();

      for (int i = 0; i < orderByFields.length; i++) {
        query.append(_ORDER_BY_ENTITY_ALIAS);
        query.append(orderByFields[i]);

        if ((i + 1) < orderByFields.length) {
          if (orderByComparator.isAscending() ^ previous) {
            query.append(ORDER_BY_ASC_HAS_NEXT);
          } else {
            query.append(ORDER_BY_DESC_HAS_NEXT);
          }
        } else {
          if (orderByComparator.isAscending() ^ previous) {
            query.append(ORDER_BY_ASC);
          } else {
            query.append(ORDER_BY_DESC);
          }
        }
      }
    } else {
      query.append(BarModelImpl.ORDER_BY_JPQL);
    }

    String sql = query.toString();

    Query q = session.createQuery(sql);

    q.setFirstResult(0);
    q.setMaxResults(2);

    QueryPos qPos = QueryPos.getInstance(q);

    if (bindText) {
      qPos.add(text);
    }

    if (orderByComparator != null) {
      Object[] values = orderByComparator.getOrderByConditionValues(bar);

      for (Object value : values) {
        qPos.add(value);
      }
    }

    List<Bar> list = q.list();

    if (list.size() == 2) {
      return list.get(1);
    } else {
      return null;
    }
  }

  /**
   * Removes all the bars where text = &#63; from the database.
   *
   * @param text the text
   */
  @Override
  public void removeByText(String text) {
    for (Bar bar : findByText(text, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
      remove(bar);
    }
  }

  /**
   * Returns the number of bars where text = &#63;.
   *
   * @param text the text
   * @return the number of matching bars
   */
  @Override
  public int countByText(String text) {
    FinderPath finderPath = FINDER_PATH_COUNT_BY_TEXT;

    Object[] finderArgs = new Object[] {text};

    Long count = (Long) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (count == null) {
      StringBundler query = new StringBundler(2);

      query.append(_SQL_COUNT_BAR_WHERE);

      boolean bindText = false;

      if (text == null) {
        query.append(_FINDER_COLUMN_TEXT_TEXT_1);
      } else if (text.equals(StringPool.BLANK)) {
        query.append(_FINDER_COLUMN_TEXT_TEXT_3);
      } else {
        bindText = true;

        query.append(_FINDER_COLUMN_TEXT_TEXT_2);
      }

      String sql = query.toString();

      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(sql);

        QueryPos qPos = QueryPos.getInstance(q);

        if (bindText) {
          qPos.add(text);
        }

        count = (Long) q.uniqueResult();

        FinderCacheUtil.putResult(finderPath, finderArgs, count);
      } catch (Exception e) {
        FinderCacheUtil.removeResult(finderPath, finderArgs);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return count.intValue();
  }

  private static final String _FINDER_COLUMN_TEXT_TEXT_1 = "bar.text IS NULL";
  private static final String _FINDER_COLUMN_TEXT_TEXT_2 = "bar.text = ?";
  private static final String _FINDER_COLUMN_TEXT_TEXT_3 = "(bar.text IS NULL OR bar.text = '')";

  public BarPersistenceImpl() {
    setModelClass(Bar.class);
  }

  /**
   * Caches the bar in the entity cache if it is enabled.
   *
   * @param bar the bar
   */
  @Override
  public void cacheResult(Bar bar) {
    EntityCacheUtil.putResult(
        BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, bar.getPrimaryKey(), bar);

    bar.resetOriginalValues();
  }

  /**
   * Caches the bars in the entity cache if it is enabled.
   *
   * @param bars the bars
   */
  @Override
  public void cacheResult(List<Bar> bars) {
    for (Bar bar : bars) {
      if (EntityCacheUtil.getResult(
              BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, bar.getPrimaryKey())
          == null) {
        cacheResult(bar);
      } else {
        bar.resetOriginalValues();
      }
    }
  }

  /**
   * Clears the cache for all bars.
   *
   * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link
   * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
   */
  @Override
  public void clearCache() {
    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      CacheRegistryUtil.clear(BarImpl.class.getName());
    }

    EntityCacheUtil.clearCache(BarImpl.class);

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }

  /**
   * Clears the cache for the bar.
   *
   * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link
   * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
   */
  @Override
  public void clearCache(Bar bar) {
    EntityCacheUtil.removeResult(
        BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, bar.getPrimaryKey());

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }

  @Override
  public void clearCache(List<Bar> bars) {
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);

    for (Bar bar : bars) {
      EntityCacheUtil.removeResult(
          BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, bar.getPrimaryKey());
    }
  }

  /**
   * Creates a new bar with the primary key. Does not add the bar to the database.
   *
   * @param barId the primary key for the new bar
   * @return the new bar
   */
  @Override
  public Bar create(long barId) {
    Bar bar = new BarImpl();

    bar.setNew(true);
    bar.setPrimaryKey(barId);

    return bar;
  }

  /**
   * Removes the bar with the primary key from the database. Also notifies the appropriate model
   * listeners.
   *
   * @param barId the primary key of the bar
   * @return the bar that was removed
   * @throws com.liferay.testtransaction.NoSuchBarException if a bar with the primary key could not
   *     be found
   */
  @Override
  public Bar remove(long barId) throws NoSuchBarException {
    return remove((Serializable) barId);
  }

  /**
   * Removes the bar with the primary key from the database. Also notifies the appropriate model
   * listeners.
   *
   * @param primaryKey the primary key of the bar
   * @return the bar that was removed
   * @throws com.liferay.testtransaction.NoSuchBarException if a bar with the primary key could not
   *     be found
   */
  @Override
  public Bar remove(Serializable primaryKey) throws NoSuchBarException {
    Session session = null;

    try {
      session = openSession();

      Bar bar = (Bar) session.get(BarImpl.class, primaryKey);

      if (bar == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchBarException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(bar);
    } catch (NoSuchBarException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }

  @Override
  protected Bar removeImpl(Bar bar) {
    bar = toUnwrappedModel(bar);

    Session session = null;

    try {
      session = openSession();

      if (!session.contains(bar)) {
        bar = (Bar) session.get(BarImpl.class, bar.getPrimaryKeyObj());
      }

      if (bar != null) {
        session.delete(bar);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    if (bar != null) {
      clearCache(bar);
    }

    return bar;
  }

  @Override
  public Bar updateImpl(com.liferay.testtransaction.model.Bar bar) {
    bar = toUnwrappedModel(bar);

    boolean isNew = bar.isNew();

    BarModelImpl barModelImpl = (BarModelImpl) bar;

    Session session = null;

    try {
      session = openSession();

      if (bar.isNew()) {
        session.save(bar);

        bar.setNew(false);
      } else {
        session.merge(bar);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !BarModelImpl.COLUMN_BITMASK_ENABLED) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    } else {
      if ((barModelImpl.getColumnBitmask()
              & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEXT.getColumnBitmask())
          != 0) {
        Object[] args = new Object[] {barModelImpl.getOriginalText()};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEXT, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEXT, args);

        args = new Object[] {barModelImpl.getText()};

        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TEXT, args);
        FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TEXT, args);
      }
    }

    EntityCacheUtil.putResult(
        BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, bar.getPrimaryKey(), bar, false);

    bar.resetOriginalValues();

    return bar;
  }

  protected Bar toUnwrappedModel(Bar bar) {
    if (bar instanceof BarImpl) {
      return bar;
    }

    BarImpl barImpl = new BarImpl();

    barImpl.setNew(bar.isNew());
    barImpl.setPrimaryKey(bar.getPrimaryKey());

    barImpl.setBarId(bar.getBarId());
    barImpl.setText(bar.getText());

    return barImpl;
  }

  /**
   * Returns the bar with the primary key or throws a {@link
   * com.liferay.portal.NoSuchModelException} if it could not be found.
   *
   * @param primaryKey the primary key of the bar
   * @return the bar
   * @throws com.liferay.testtransaction.NoSuchBarException if a bar with the primary key could not
   *     be found
   */
  @Override
  public Bar findByPrimaryKey(Serializable primaryKey) throws NoSuchBarException {
    Bar bar = fetchByPrimaryKey(primaryKey);

    if (bar == null) {
      if (_log.isWarnEnabled()) {
        _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      throw new NoSuchBarException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
    }

    return bar;
  }

  /**
   * Returns the bar with the primary key or throws a {@link
   * com.liferay.testtransaction.NoSuchBarException} if it could not be found.
   *
   * @param barId the primary key of the bar
   * @return the bar
   * @throws com.liferay.testtransaction.NoSuchBarException if a bar with the primary key could not
   *     be found
   */
  @Override
  public Bar findByPrimaryKey(long barId) throws NoSuchBarException {
    return findByPrimaryKey((Serializable) barId);
  }

  /**
   * Returns the bar with the primary key or returns <code>null</code> if it could not be found.
   *
   * @param primaryKey the primary key of the bar
   * @return the bar, or <code>null</code> if a bar with the primary key could not be found
   */
  @Override
  public Bar fetchByPrimaryKey(Serializable primaryKey) {
    Bar bar =
        (Bar)
            EntityCacheUtil.getResult(BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey);

    if (bar == _nullBar) {
      return null;
    }

    if (bar == null) {
      Session session = null;

      try {
        session = openSession();

        bar = (Bar) session.get(BarImpl.class, primaryKey);

        if (bar != null) {
          cacheResult(bar);
        } else {
          EntityCacheUtil.putResult(
              BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey, _nullBar);
        }
      } catch (Exception e) {
        EntityCacheUtil.removeResult(BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return bar;
  }

  /**
   * Returns the bar with the primary key or returns <code>null</code> if it could not be found.
   *
   * @param barId the primary key of the bar
   * @return the bar, or <code>null</code> if a bar with the primary key could not be found
   */
  @Override
  public Bar fetchByPrimaryKey(long barId) {
    return fetchByPrimaryKey((Serializable) barId);
  }

  @Override
  public Map<Serializable, Bar> fetchByPrimaryKeys(Set<Serializable> primaryKeys) {
    if (primaryKeys.isEmpty()) {
      return Collections.emptyMap();
    }

    Map<Serializable, Bar> map = new HashMap<Serializable, Bar>();

    if (primaryKeys.size() == 1) {
      Iterator<Serializable> iterator = primaryKeys.iterator();

      Serializable primaryKey = iterator.next();

      Bar bar = fetchByPrimaryKey(primaryKey);

      if (bar != null) {
        map.put(primaryKey, bar);
      }

      return map;
    }

    Set<Serializable> uncachedPrimaryKeys = null;

    for (Serializable primaryKey : primaryKeys) {
      Bar bar =
          (Bar)
              EntityCacheUtil.getResult(
                  BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey);

      if (bar == null) {
        if (uncachedPrimaryKeys == null) {
          uncachedPrimaryKeys = new HashSet<Serializable>();
        }

        uncachedPrimaryKeys.add(primaryKey);
      } else {
        map.put(primaryKey, bar);
      }
    }

    if (uncachedPrimaryKeys == null) {
      return map;
    }

    StringBundler query = new StringBundler((uncachedPrimaryKeys.size() * 2) + 1);

    query.append(_SQL_SELECT_BAR_WHERE_PKS_IN);

    for (Serializable primaryKey : uncachedPrimaryKeys) {
      query.append(String.valueOf(primaryKey));

      query.append(StringPool.COMMA);
    }

    query.setIndex(query.index() - 1);

    query.append(StringPool.CLOSE_PARENTHESIS);

    String sql = query.toString();

    Session session = null;

    try {
      session = openSession();

      Query q = session.createQuery(sql);

      for (Bar bar : (List<Bar>) q.list()) {
        map.put(bar.getPrimaryKeyObj(), bar);

        cacheResult(bar);

        uncachedPrimaryKeys.remove(bar.getPrimaryKeyObj());
      }

      for (Serializable primaryKey : uncachedPrimaryKeys) {
        EntityCacheUtil.putResult(
            BarModelImpl.ENTITY_CACHE_ENABLED, BarImpl.class, primaryKey, _nullBar);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    return map;
  }

  /**
   * Returns all the bars.
   *
   * @return the bars
   */
  @Override
  public List<Bar> findAll() {
    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
  }

  /**
   * Returns a range of all the bars.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set. If <code>orderByComparator</code> is specified, then the query
   * will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and
   * pagination is required (<code>start</code> and <code>end</code> are not {@link
   * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default
   * ORDER BY logic from {@link com.liferay.testtransaction.model.impl.BarModelImpl}. If both <code>
   * orderByComparator</code> and pagination are absent, for performance reasons, the query will not
   * have an ORDER BY clause and the returned result set will be sorted on by the primary key in an
   * ascending order.
   *
   * @param start the lower bound of the range of bars
   * @param end the upper bound of the range of bars (not inclusive)
   * @return the range of bars
   */
  @Override
  public List<Bar> findAll(int start, int end) {
    return findAll(start, end, null);
  }

  /**
   * Returns an ordered range of all the bars.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set. If <code>orderByComparator</code> is specified, then the query
   * will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and
   * pagination is required (<code>start</code> and <code>end</code> are not {@link
   * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default
   * ORDER BY logic from {@link com.liferay.testtransaction.model.impl.BarModelImpl}. If both <code>
   * orderByComparator</code> and pagination are absent, for performance reasons, the query will not
   * have an ORDER BY clause and the returned result set will be sorted on by the primary key in an
   * ascending order.
   *
   * @param start the lower bound of the range of bars
   * @param end the upper bound of the range of bars (not inclusive)
   * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
   * @return the ordered range of bars
   */
  @Override
  public List<Bar> findAll(int start, int end, OrderByComparator<Bar> orderByComparator) {
    boolean pagination = true;
    FinderPath finderPath = null;
    Object[] finderArgs = null;

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
      pagination = false;
      finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
      finderArgs = FINDER_ARGS_EMPTY;
    } else {
      finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
      finderArgs = new Object[] {start, end, orderByComparator};
    }

    List<Bar> list = (List<Bar>) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (list == null) {
      StringBundler query = null;
      String sql = null;

      if (orderByComparator != null) {
        query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 3));

        query.append(_SQL_SELECT_BAR);

        appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);

        sql = query.toString();
      } else {
        sql = _SQL_SELECT_BAR;

        if (pagination) {
          sql = sql.concat(BarModelImpl.ORDER_BY_JPQL);
        }
      }

      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(sql);

        if (!pagination) {
          list = (List<Bar>) QueryUtil.list(q, getDialect(), start, end, false);

          Collections.sort(list);

          list = Collections.unmodifiableList(list);
        } else {
          list = (List<Bar>) QueryUtil.list(q, getDialect(), start, end);
        }

        cacheResult(list);

        FinderCacheUtil.putResult(finderPath, finderArgs, list);
      } catch (Exception e) {
        FinderCacheUtil.removeResult(finderPath, finderArgs);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return list;
  }

  /** Removes all the bars from the database. */
  @Override
  public void removeAll() {
    for (Bar bar : findAll()) {
      remove(bar);
    }
  }

  /**
   * Returns the number of bars.
   *
   * @return the number of bars
   */
  @Override
  public int countAll() {
    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this);

    if (count == null) {
      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(_SQL_COUNT_BAR);

        count = (Long) q.uniqueResult();

        FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count);
      } catch (Exception e) {
        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return count.intValue();
  }

  @Override
  protected Set<String> getBadColumnNames() {
    return _badColumnNames;
  }

  /** Initializes the bar persistence. */
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.util.service.ServiceProps.get(
                    "value.object.listener.com.liferay.testtransaction.model.Bar")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<Bar>> listenersList = new ArrayList<ModelListener<Bar>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add(
              (ModelListener<Bar>)
                  InstanceFactory.newInstance(getClassLoader(), listenerClassName));
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }
  }

  public void destroy() {
    EntityCacheUtil.removeCache(BarImpl.class.getName());
    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }

  private static final String _SQL_SELECT_BAR = "SELECT bar FROM Bar bar";
  private static final String _SQL_SELECT_BAR_WHERE_PKS_IN =
      "SELECT bar FROM Bar bar WHERE barId IN (";
  private static final String _SQL_SELECT_BAR_WHERE = "SELECT bar FROM Bar bar WHERE ";
  private static final String _SQL_COUNT_BAR = "SELECT COUNT(bar) FROM Bar bar";
  private static final String _SQL_COUNT_BAR_WHERE = "SELECT COUNT(bar) FROM Bar bar WHERE ";
  private static final String _ORDER_BY_ENTITY_ALIAS = "bar.";
  private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY =
      "No Bar exists with the primary key ";
  private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Bar exists with the key {";
  private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE =
      GetterUtil.getBoolean(PropsUtil.get(PropsKeys.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE));
  private static Log _log = LogFactoryUtil.getLog(BarPersistenceImpl.class);
  private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {"text"});
  private static Bar _nullBar =
      new BarImpl() {
        @Override
        public Object clone() {
          return this;
        }

        @Override
        public CacheModel<Bar> toCacheModel() {
          return _nullBarCacheModel;
        }
      };

  private static CacheModel<Bar> _nullBarCacheModel =
      new CacheModel<Bar>() {
        @Override
        public Bar toEntityModel() {
          return _nullBar;
        }
      };
}
/**
 * The persistence implementation for the i project service.
 *
 * <p>Caching information and settings can be found in <code>portal.properties</code>
 *
 * @author Shruthi
 * @see iProjectPersistence
 * @see iProjectUtil
 * @generated
 */
public class iProjectPersistenceImpl extends BasePersistenceImpl<iProject>
    implements iProjectPersistence {
  /*
   * NOTE FOR DEVELOPERS:
   *
   * Never modify or reference this class directly. Always use {@link iProjectUtil} to access the i project persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
   */
  public static final String FINDER_CLASS_NAME_ENTITY = iProjectImpl.class.getName();
  public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION =
      FINDER_CLASS_NAME_ENTITY + ".List1";
  public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION =
      FINDER_CLASS_NAME_ENTITY + ".List2";
  public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL =
      new FinderPath(
          iProjectModelImpl.ENTITY_CACHE_ENABLED,
          iProjectModelImpl.FINDER_CACHE_ENABLED,
          iProjectImpl.class,
          FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
          "findAll",
          new String[0]);
  public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL =
      new FinderPath(
          iProjectModelImpl.ENTITY_CACHE_ENABLED,
          iProjectModelImpl.FINDER_CACHE_ENABLED,
          iProjectImpl.class,
          FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
          "findAll",
          new String[0]);
  public static final FinderPath FINDER_PATH_COUNT_ALL =
      new FinderPath(
          iProjectModelImpl.ENTITY_CACHE_ENABLED,
          iProjectModelImpl.FINDER_CACHE_ENABLED,
          Long.class,
          FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
          "countAll",
          new String[0]);

  /**
   * Caches the i project in the entity cache if it is enabled.
   *
   * @param iProject the i project
   */
  public void cacheResult(iProject iProject) {
    EntityCacheUtil.putResult(
        iProjectModelImpl.ENTITY_CACHE_ENABLED,
        iProjectImpl.class,
        iProject.getPrimaryKey(),
        iProject);

    iProject.resetOriginalValues();
  }

  /**
   * Caches the i projects in the entity cache if it is enabled.
   *
   * @param iProjects the i projects
   */
  public void cacheResult(List<iProject> iProjects) {
    for (iProject iProject : iProjects) {
      if (EntityCacheUtil.getResult(
              iProjectModelImpl.ENTITY_CACHE_ENABLED, iProjectImpl.class, iProject.getPrimaryKey())
          == null) {
        cacheResult(iProject);
      } else {
        iProject.resetOriginalValues();
      }
    }
  }

  /**
   * Clears the cache for all i projects.
   *
   * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link
   * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
   */
  @Override
  public void clearCache() {
    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      CacheRegistryUtil.clear(iProjectImpl.class.getName());
    }

    EntityCacheUtil.clearCache(iProjectImpl.class.getName());

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }

  /**
   * Clears the cache for the i project.
   *
   * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link
   * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
   */
  @Override
  public void clearCache(iProject iProject) {
    EntityCacheUtil.removeResult(
        iProjectModelImpl.ENTITY_CACHE_ENABLED, iProjectImpl.class, iProject.getPrimaryKey());

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }

  @Override
  public void clearCache(List<iProject> iProjects) {
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);

    for (iProject iProject : iProjects) {
      EntityCacheUtil.removeResult(
          iProjectModelImpl.ENTITY_CACHE_ENABLED, iProjectImpl.class, iProject.getPrimaryKey());
    }
  }

  /**
   * Creates a new i project with the primary key. Does not add the i project to the database.
   *
   * @param projectID the primary key for the new i project
   * @return the new i project
   */
  public iProject create(long projectID) {
    iProject iProject = new iProjectImpl();

    iProject.setNew(true);
    iProject.setPrimaryKey(projectID);

    return iProject;
  }

  /**
   * Removes the i project with the primary key from the database. Also notifies the appropriate
   * model listeners.
   *
   * @param projectID the primary key of the i project
   * @return the i project that was removed
   * @throws com.asu.poly.iProjects.NoSuchiProjectException if a i project with the primary key
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  public iProject remove(long projectID) throws NoSuchiProjectException, SystemException {
    return remove(Long.valueOf(projectID));
  }

  /**
   * Removes the i project with the primary key from the database. Also notifies the appropriate
   * model listeners.
   *
   * @param primaryKey the primary key of the i project
   * @return the i project that was removed
   * @throws com.asu.poly.iProjects.NoSuchiProjectException if a i project with the primary key
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public iProject remove(Serializable primaryKey) throws NoSuchiProjectException, SystemException {
    Session session = null;

    try {
      session = openSession();

      iProject iProject = (iProject) session.get(iProjectImpl.class, primaryKey);

      if (iProject == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchiProjectException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(iProject);
    } catch (NoSuchiProjectException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }

  @Override
  protected iProject removeImpl(iProject iProject) throws SystemException {
    iProject = toUnwrappedModel(iProject);

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.delete(session, iProject);
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    clearCache(iProject);

    return iProject;
  }

  @Override
  public iProject updateImpl(com.asu.poly.iProjects.model.iProject iProject, boolean merge)
      throws SystemException {
    iProject = toUnwrappedModel(iProject);

    boolean isNew = iProject.isNew();

    Session session = null;

    try {
      session = openSession();

      BatchSessionUtil.update(session, iProject, merge);

      iProject.setNew(false);
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    EntityCacheUtil.putResult(
        iProjectModelImpl.ENTITY_CACHE_ENABLED,
        iProjectImpl.class,
        iProject.getPrimaryKey(),
        iProject);

    return iProject;
  }

  protected iProject toUnwrappedModel(iProject iProject) {
    if (iProject instanceof iProjectImpl) {
      return iProject;
    }

    iProjectImpl iProjectImpl = new iProjectImpl();

    iProjectImpl.setNew(iProject.isNew());
    iProjectImpl.setPrimaryKey(iProject.getPrimaryKey());

    iProjectImpl.setProjectID(iProject.getProjectID());
    iProjectImpl.setProjectTitle(iProject.getProjectTitle());
    iProjectImpl.setProjectdescription(iProject.getProjectdescription());
    iProjectImpl.setSponsor(iProject.getSponsor());
    iProjectImpl.setRequiredSkills(iProject.getRequiredSkills());
    iProjectImpl.setContact(iProject.getContact());
    iProjectImpl.setStatus(iProject.getStatus());
    iProjectImpl.setLink(iProject.getLink());
    iProjectImpl.setDepartments(iProject.getDepartments());
    iProjectImpl.setDateAdded(iProject.getDateAdded());
    iProjectImpl.setDateModified(iProject.getDateModified());

    return iProjectImpl;
  }

  /**
   * Returns the i project with the primary key or throws a {@link
   * com.liferay.portal.NoSuchModelException} if it could not be found.
   *
   * @param primaryKey the primary key of the i project
   * @return the i project
   * @throws com.liferay.portal.NoSuchModelException if a i project with the primary key could not
   *     be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public iProject findByPrimaryKey(Serializable primaryKey)
      throws NoSuchModelException, SystemException {
    return findByPrimaryKey(((Long) primaryKey).longValue());
  }

  /**
   * Returns the i project with the primary key or throws a {@link
   * com.asu.poly.iProjects.NoSuchiProjectException} if it could not be found.
   *
   * @param projectID the primary key of the i project
   * @return the i project
   * @throws com.asu.poly.iProjects.NoSuchiProjectException if a i project with the primary key
   *     could not be found
   * @throws SystemException if a system exception occurred
   */
  public iProject findByPrimaryKey(long projectID) throws NoSuchiProjectException, SystemException {
    iProject iProject = fetchByPrimaryKey(projectID);

    if (iProject == null) {
      if (_log.isWarnEnabled()) {
        _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + projectID);
      }

      throw new NoSuchiProjectException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + projectID);
    }

    return iProject;
  }

  /**
   * Returns the i project with the primary key or returns <code>null</code> if it could not be
   * found.
   *
   * @param primaryKey the primary key of the i project
   * @return the i project, or <code>null</code> if a i project with the primary key could not be
   *     found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public iProject fetchByPrimaryKey(Serializable primaryKey) throws SystemException {
    return fetchByPrimaryKey(((Long) primaryKey).longValue());
  }

  /**
   * Returns the i project with the primary key or returns <code>null</code> if it could not be
   * found.
   *
   * @param projectID the primary key of the i project
   * @return the i project, or <code>null</code> if a i project with the primary key could not be
   *     found
   * @throws SystemException if a system exception occurred
   */
  public iProject fetchByPrimaryKey(long projectID) throws SystemException {
    iProject iProject =
        (iProject)
            EntityCacheUtil.getResult(
                iProjectModelImpl.ENTITY_CACHE_ENABLED, iProjectImpl.class, projectID);

    if (iProject == _nulliProject) {
      return null;
    }

    if (iProject == null) {
      Session session = null;

      boolean hasException = false;

      try {
        session = openSession();

        iProject = (iProject) session.get(iProjectImpl.class, Long.valueOf(projectID));
      } catch (Exception e) {
        hasException = true;

        throw processException(e);
      } finally {
        if (iProject != null) {
          cacheResult(iProject);
        } else if (!hasException) {
          EntityCacheUtil.putResult(
              iProjectModelImpl.ENTITY_CACHE_ENABLED, iProjectImpl.class, projectID, _nulliProject);
        }

        closeSession(session);
      }
    }

    return iProject;
  }

  /**
   * Returns all the i projects.
   *
   * @return the i projects
   * @throws SystemException if a system exception occurred
   */
  public List<iProject> findAll() throws SystemException {
    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
  }

  /**
   * Returns a range of all the i projects.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set.
   *
   * @param start the lower bound of the range of i projects
   * @param end the upper bound of the range of i projects (not inclusive)
   * @return the range of i projects
   * @throws SystemException if a system exception occurred
   */
  public List<iProject> findAll(int start, int end) throws SystemException {
    return findAll(start, end, null);
  }

  /**
   * Returns an ordered range of all the i projects.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set.
   *
   * @param start the lower bound of the range of i projects
   * @param end the upper bound of the range of i projects (not inclusive)
   * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
   * @return the ordered range of i projects
   * @throws SystemException if a system exception occurred
   */
  public List<iProject> findAll(int start, int end, OrderByComparator orderByComparator)
      throws SystemException {
    FinderPath finderPath = null;
    Object[] finderArgs = new Object[] {start, end, orderByComparator};

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
      finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
      finderArgs = FINDER_ARGS_EMPTY;
    } else {
      finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
      finderArgs = new Object[] {start, end, orderByComparator};
    }

    List<iProject> list = (List<iProject>) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (list == null) {
      StringBundler query = null;
      String sql = null;

      if (orderByComparator != null) {
        query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 3));

        query.append(_SQL_SELECT_IPROJECT);

        appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);

        sql = query.toString();
      } else {
        sql = _SQL_SELECT_IPROJECT;
      }

      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(sql);

        if (orderByComparator == null) {
          list = (List<iProject>) QueryUtil.list(q, getDialect(), start, end, false);

          Collections.sort(list);
        } else {
          list = (List<iProject>) QueryUtil.list(q, getDialect(), start, end);
        }
      } catch (Exception e) {
        throw processException(e);
      } finally {
        if (list == null) {
          FinderCacheUtil.removeResult(finderPath, finderArgs);
        } else {
          cacheResult(list);

          FinderCacheUtil.putResult(finderPath, finderArgs, list);
        }

        closeSession(session);
      }
    }

    return list;
  }

  /**
   * Removes all the i projects from the database.
   *
   * @throws SystemException if a system exception occurred
   */
  public void removeAll() throws SystemException {
    for (iProject iProject : findAll()) {
      remove(iProject);
    }
  }

  /**
   * Returns the number of i projects.
   *
   * @return the number of i projects
   * @throws SystemException if a system exception occurred
   */
  public int countAll() throws SystemException {
    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this);

    if (count == null) {
      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(_SQL_COUNT_IPROJECT);

        count = (Long) q.uniqueResult();
      } catch (Exception e) {
        throw processException(e);
      } finally {
        if (count == null) {
          count = Long.valueOf(0);
        }

        FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count);

        closeSession(session);
      }
    }

    return count.intValue();
  }

  /** Initializes the i project persistence. */
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.util.service.ServiceProps.get(
                    "value.object.listener.com.asu.poly.iProjects.model.iProject")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<iProject>> listenersList = new ArrayList<ModelListener<iProject>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add(
              (ModelListener<iProject>) InstanceFactory.newInstance(listenerClassName));
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }
  }

  public void destroy() {
    EntityCacheUtil.removeCache(iProjectImpl.class.getName());
    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }

  @BeanReference(type = iProjectPersistence.class)
  protected iProjectPersistence iProjectPersistence;

  @BeanReference(type = ResourcePersistence.class)
  protected ResourcePersistence resourcePersistence;

  @BeanReference(type = UserPersistence.class)
  protected UserPersistence userPersistence;

  private static final String _SQL_SELECT_IPROJECT = "SELECT iProject FROM iProject iProject";
  private static final String _SQL_COUNT_IPROJECT = "SELECT COUNT(iProject) FROM iProject iProject";
  private static final String _ORDER_BY_ENTITY_ALIAS = "iProject.";
  private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY =
      "No iProject exists with the primary key ";
  private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE =
      GetterUtil.getBoolean(PropsUtil.get(PropsKeys.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE));
  private static Log _log = LogFactoryUtil.getLog(iProjectPersistenceImpl.class);
  private static iProject _nulliProject =
      new iProjectImpl() {
        @Override
        public Object clone() {
          return this;
        }

        @Override
        public CacheModel<iProject> toCacheModel() {
          return _nulliProjectCacheModel;
        }
      };

  private static CacheModel<iProject> _nulliProjectCacheModel =
      new CacheModel<iProject>() {
        public iProject toEntityModel() {
          return _nulliProject;
        }
      };
}
/**
 * @author Shuyang Zhou
 * @author Raymond Augé
 */
public class PortletContainerUtil {

  public static List<LayoutTypePortlet> getLayoutTypePortlets(Layout layout)
      throws PortletContainerException {

    if (_PORTLET_EVENT_DISTRIBUTION_LAYOUT_SET) {
      List<Layout> layouts = null;

      try {
        layouts =
            LayoutLocalServiceUtil.getLayouts(
                layout.getGroupId(), layout.isPrivateLayout(), LayoutConstants.TYPE_PORTLET);
      } catch (SystemException se) {
        throw new PortletContainerException(se);
      }

      List<LayoutTypePortlet> layoutTypePortlets = new ArrayList<LayoutTypePortlet>(layouts.size());

      for (Layout curLayout : layouts) {
        LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) curLayout.getLayoutType();

        layoutTypePortlets.add(layoutTypePortlet);
      }

      return layoutTypePortlets;
    }

    if (layout.isTypePortlet()) {
      List<LayoutTypePortlet> layoutTypePortlets = new ArrayList<LayoutTypePortlet>(1);

      LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();

      layoutTypePortlets.add(layoutTypePortlet);

      return layoutTypePortlets;
    }

    return Collections.emptyList();
  }

  public static PortletContainer getPortletContainer() {
    PortalRuntimePermission.checkGetBeanProperty(PortletContainerUtil.class);

    return _portletContainer;
  }

  public static void preparePortlet(HttpServletRequest request, Portlet portlet)
      throws PortletContainerException {

    getPortletContainer().preparePortlet(request, portlet);
  }

  public static void processAction(
      HttpServletRequest request, HttpServletResponse response, Portlet portlet)
      throws PortletContainerException {

    PortletContainer portletContainer = getPortletContainer();

    ActionResult actionResult = portletContainer.processAction(request, response, portlet);

    List<Event> events = actionResult.getEvents();

    if (!events.isEmpty()) {
      _processEvents(request, response, events);
    }

    String location = actionResult.getLocation();

    if (Validator.isNotNull(location)) {
      try {
        response.sendRedirect(location);
      } catch (IOException ioe) {
        throw new PortletContainerException(ioe);
      }
    }
  }

  public static void processEvent(
      HttpServletRequest request,
      HttpServletResponse response,
      Portlet portlet,
      Layout layout,
      Event event)
      throws PortletContainerException {

    PortletContainer portletContainer = getPortletContainer();

    List<Event> events = portletContainer.processEvent(request, response, portlet, layout, event);

    if (!events.isEmpty()) {
      _processEvents(request, response, events);
    }
  }

  public static void render(
      HttpServletRequest request, HttpServletResponse response, Portlet portlet)
      throws PortletContainerException {

    getPortletContainer().render(request, response, portlet);
  }

  public static void serveResource(
      HttpServletRequest request, HttpServletResponse response, Portlet portlet)
      throws PortletContainerException {

    getPortletContainer().serveResource(request, response, portlet);
  }

  public static HttpServletRequest setupOptionalRenderParameters(
      HttpServletRequest request,
      String renderPath,
      String columnId,
      Integer columnPos,
      Integer columnCount) {

    return setupOptionalRenderParameters(
        request, renderPath, columnId, columnPos, columnCount, null, null);
  }

  public static HttpServletRequest setupOptionalRenderParameters(
      HttpServletRequest request,
      String renderPath,
      String columnId,
      Integer columnPos,
      Integer columnCount,
      Boolean boundary,
      Boolean decorate) {

    if ((_LAYOUT_PARALLEL_RENDER_ENABLE && ServerDetector.isTomcat())
        || _PORTLET_CONTAINER_RESTRICT) {

      RestrictPortletServletRequest restrictPortletServletRequest =
          new RestrictPortletServletRequest(request);

      if (renderPath != null) {
        restrictPortletServletRequest.setAttribute(WebKeys.RENDER_PATH, renderPath);
      }

      if (columnId != null) {
        restrictPortletServletRequest.setAttribute(WebKeys.RENDER_PORTLET_COLUMN_ID, columnId);
      }

      if (columnPos != null) {
        restrictPortletServletRequest.setAttribute(WebKeys.RENDER_PORTLET_COLUMN_POS, columnPos);
      }

      if (columnCount != null) {
        restrictPortletServletRequest.setAttribute(
            WebKeys.RENDER_PORTLET_COLUMN_COUNT, columnCount);
      }

      if (boundary != null) {
        restrictPortletServletRequest.setAttribute(WebKeys.RENDER_PORTLET_BOUNDARY, boundary);
      }

      if (decorate != null) {
        restrictPortletServletRequest.setAttribute(WebKeys.PORTLET_DECORATE, decorate);
      }

      return restrictPortletServletRequest;
    }

    TempAttributesServletRequest tempAttributesServletRequest =
        new TempAttributesServletRequest(request);

    if (renderPath != null) {
      tempAttributesServletRequest.setTempAttribute(WebKeys.RENDER_PATH, renderPath);
    }

    if (columnId != null) {
      tempAttributesServletRequest.setTempAttribute(WebKeys.RENDER_PORTLET_COLUMN_ID, columnId);
    }

    if (columnPos != null) {
      tempAttributesServletRequest.setTempAttribute(WebKeys.RENDER_PORTLET_COLUMN_POS, columnPos);
    }

    if (columnCount != null) {
      tempAttributesServletRequest.setTempAttribute(
          WebKeys.RENDER_PORTLET_COLUMN_COUNT, columnCount);
    }

    return tempAttributesServletRequest;
  }

  public void setPortletContainer(PortletContainer portletContainer) {
    PortalRuntimePermission.checkSetBeanProperty(getClass());

    _portletContainer = portletContainer;
  }

  private static void _processEvents(
      HttpServletRequest request, HttpServletResponse response, List<Event> events)
      throws PortletContainerException {

    Layout layout = (Layout) request.getAttribute(WebKeys.LAYOUT);

    List<LayoutTypePortlet> layoutTypePortlets = getLayoutTypePortlets(layout);

    for (LayoutTypePortlet layoutTypePortlet : layoutTypePortlets) {
      List<Portlet> portlets = null;

      try {
        portlets = layoutTypePortlet.getAllPortlets();
      } catch (Exception e) {
        throw new PortletContainerException(e);
      }

      for (Portlet portlet : portlets) {
        for (Event event : events) {
          javax.xml.namespace.QName qName = event.getQName();

          QName processingQName =
              portlet.getProcessingEvent(qName.getNamespaceURI(), qName.getLocalPart());

          if (processingQName == null) {
            continue;
          }

          processEvent(request, response, portlet, layoutTypePortlet.getLayout(), event);
        }
      }
    }
  }

  private static final boolean _LAYOUT_PARALLEL_RENDER_ENABLE =
      GetterUtil.getBoolean(PropsUtil.get(PropsKeys.LAYOUT_PARALLEL_RENDER_ENABLE));

  private static final boolean _PORTLET_CONTAINER_RESTRICT =
      GetterUtil.getBoolean(PropsUtil.get(PropsKeys.PORTLET_CONTAINER_RESTRICT));

  private static final boolean _PORTLET_EVENT_DISTRIBUTION_LAYOUT_SET =
      !StringUtil.equalsIgnoreCase(PropsUtil.get(PropsKeys.PORTLET_EVENT_DISTRIBUTION), "layout");

  private static PortletContainer _portletContainer;
}
Esempio n. 28
0
/**
 * @author Brian Wing Shun Chan
 * @author Bruno Farache
 */
public class DocumentImpl implements Document {

  public static String getLocalizedName(Locale locale, String name) {
    if (locale == null) {
      return name;
    }

    String languageId = LocaleUtil.toLanguageId(locale);

    return getLocalizedName(languageId, name);
  }

  public static String getLocalizedName(String languageId, String name) {
    return LocalizationUtil.getLocalizedName(name, languageId);
  }

  public static String getSortableFieldName(String name) {
    return name.concat(StringPool.UNDERLINE).concat(_SORTABLE_FIELD_SUFFIX);
  }

  public static String getSortFieldName(Sort sort, String scoreFieldName) {
    if (sort.getType() == Sort.SCORE_TYPE) {
      return scoreFieldName;
    }

    String fieldName = sort.getFieldName();

    if (DocumentImpl.isSortableFieldName(fieldName)) {
      return fieldName;
    }

    if ((sort.getType() == Sort.STRING_TYPE) && !DocumentImpl.isSortableTextField(fieldName)) {

      return scoreFieldName;
    }

    return DocumentImpl.getSortableFieldName(fieldName);
  }

  public static boolean isSortableFieldName(String name) {
    return name.endsWith(_SORTABLE_FIELD_SUFFIX);
  }

  public static boolean isSortableTextField(String name) {
    return _defaultSortableTextFields.contains(name);
  }

  @Override
  public void add(Field field) {
    _fields.put(field.getName(), field);
  }

  @Override
  public void addDate(String name, Date value) {
    if (value == null) {
      return;
    }

    addDate(name, new Date[] {value});
  }

  @Override
  public void addDate(String name, Date[] values) {
    if (values == null) {
      return;
    }

    if (_dateFormat == null) {
      _dateFormat = FastDateFormatFactoryUtil.getSimpleDateFormat(_INDEX_DATE_FORMAT_PATTERN);
    }

    String[] datesString = new String[values.length];
    Long[] datesTime = new Long[values.length];

    for (int i = 0; i < values.length; i++) {
      datesString[i] = _dateFormat.format(values[i]);
      datesTime[i] = values[i].getTime();
    }

    createSortableNumericField(name, false, datesTime);

    Field field = createField(name, datesString);

    field.setDates(values);
  }

  @Override
  public void addDateSortable(String name, Date value) {
    if (value == null) {
      return;
    }

    addDateSortable(name, new Date[] {value});
  }

  @Override
  public void addDateSortable(String name, Date[] values) {
    if (values == null) {
      return;
    }

    String[] datesString = new String[values.length];
    Long[] datesTime = new Long[values.length];

    for (int i = 0; i < values.length; i++) {
      datesString[i] = _dateFormat.format(values[i]);
      datesTime[i] = values[i].getTime();
    }

    createSortableNumericField(name, true, datesTime);

    addKeyword(name, datesString);
  }

  @Override
  public void addFile(String name, byte[] bytes, String fileExt) {
    InputStream is = new UnsyncByteArrayInputStream(bytes);

    addFile(name, is, fileExt);
  }

  @Override
  public void addFile(String name, File file, String fileExt) throws IOException {

    InputStream is = new FileInputStream(file);

    addFile(name, is, fileExt);
  }

  @Override
  public void addFile(String name, InputStream is, String fileExt) {
    addText(name, FileUtil.extractText(is, fileExt));
  }

  @Override
  public void addFile(String name, InputStream is, String fileExt, int maxStringLength) {

    addText(name, FileUtil.extractText(is, fileExt, maxStringLength));
  }

  @Override
  public void addGeoLocation(double latitude, double longitude) {
    addGeoLocation(Field.GEO_LOCATION, latitude, longitude);
  }

  @Override
  public void addGeoLocation(String name, double latitude, double longitude) {
    Field field = new Field(name);

    field.setGeoLocationPoint(new GeoLocationPoint(latitude, longitude));

    add(field);
  }

  @Override
  public void addKeyword(String name, boolean value) {
    addKeyword(name, String.valueOf(value));
  }

  @Override
  public void addKeyword(String name, Boolean value) {
    addKeyword(name, String.valueOf(value));
  }

  @Override
  public void addKeyword(String name, boolean[] values) {
    if (values == null) {
      return;
    }

    addKeyword(name, ArrayUtil.toStringArray(values));
  }

  @Override
  public void addKeyword(String name, Boolean[] values) {
    if (values == null) {
      return;
    }

    addKeyword(name, ArrayUtil.toStringArray(values));
  }

  @Override
  public void addKeyword(String name, double value) {
    addKeyword(name, String.valueOf(value));
  }

  @Override
  public void addKeyword(String name, Double value) {
    addKeyword(name, String.valueOf(value));
  }

  @Override
  public void addKeyword(String name, double[] values) {
    if (values == null) {
      return;
    }

    addKeyword(name, ArrayUtil.toStringArray(values));
  }

  @Override
  public void addKeyword(String name, Double[] values) {
    if (values == null) {
      return;
    }

    addKeyword(name, ArrayUtil.toStringArray(values));
  }

  @Override
  public void addKeyword(String name, float value) {
    addKeyword(name, String.valueOf(value));
  }

  @Override
  public void addKeyword(String name, Float value) {
    addKeyword(name, String.valueOf(value));
  }

  @Override
  public void addKeyword(String name, float[] values) {
    if (values == null) {
      return;
    }

    addKeyword(name, ArrayUtil.toStringArray(values));
  }

  @Override
  public void addKeyword(String name, Float[] values) {
    if (values == null) {
      return;
    }

    addKeyword(name, ArrayUtil.toStringArray(values));
  }

  @Override
  public void addKeyword(String name, int value) {
    addKeyword(name, String.valueOf(value));
  }

  @Override
  public void addKeyword(String name, int[] values) {
    if (values == null) {
      return;
    }

    addKeyword(name, ArrayUtil.toStringArray(values));
  }

  @Override
  public void addKeyword(String name, Integer value) {
    addKeyword(name, String.valueOf(value));
  }

  @Override
  public void addKeyword(String name, Integer[] values) {
    if (values == null) {
      return;
    }

    addKeyword(name, ArrayUtil.toStringArray(values));
  }

  @Override
  public void addKeyword(String name, long value) {
    addKeyword(name, String.valueOf(value));
  }

  @Override
  public void addKeyword(String name, Long value) {
    addKeyword(name, String.valueOf(value));
  }

  @Override
  public void addKeyword(String name, long[] values) {
    if (values == null) {
      return;
    }

    addKeyword(name, ArrayUtil.toStringArray(values));
  }

  @Override
  public void addKeyword(String name, Long[] values) {
    if (values == null) {
      return;
    }

    addKeyword(name, ArrayUtil.toStringArray(values));
  }

  @Override
  public void addKeyword(String name, short value) {
    addKeyword(name, String.valueOf(value));
  }

  @Override
  public void addKeyword(String name, Short value) {
    addKeyword(name, String.valueOf(value));
  }

  @Override
  public void addKeyword(String name, short[] values) {
    if (values == null) {
      return;
    }

    addKeyword(name, ArrayUtil.toStringArray(values));
  }

  @Override
  public void addKeyword(String name, Short[] values) {
    if (values == null) {
      return;
    }

    addKeyword(name, ArrayUtil.toStringArray(values));
  }

  @Override
  public void addKeyword(String name, String value) {
    addKeyword(name, value, false);
  }

  @Override
  public void addKeyword(String name, String value, boolean lowerCase) {
    createKeywordField(name, value, lowerCase);

    createSortableKeywordField(name, value);
  }

  @Override
  public void addKeyword(String name, String[] values) {
    if (values == null) {
      return;
    }

    createField(name, values);
  }

  @Override
  public void addKeywordSortable(String name, Boolean value) {
    String valueString = String.valueOf(value);

    createKeywordField(name, valueString, false);

    createSortableTextField(name, valueString);
  }

  @Override
  public void addKeywordSortable(String name, Boolean[] values) {
    if (values == null) {
      return;
    }

    String[] valuesString = ArrayUtil.toStringArray(values);

    createField(name, valuesString);

    createSortableTextField(name, valuesString);
  }

  @Override
  public void addKeywordSortable(String name, String value) {
    createKeywordField(name, value, false);

    createSortableTextField(name, value);
  }

  @Override
  public void addKeywordSortable(String name, String[] values) {
    createField(name, values);

    createSortableTextField(name, values);
  }

  @Override
  public void addLocalizedKeyword(String name, Map<Locale, String> values) {
    addLocalizedKeyword(name, values, false);
  }

  @Override
  public void addLocalizedKeyword(String name, Map<Locale, String> values, boolean lowerCase) {

    if ((values == null) || values.isEmpty()) {
      return;
    }

    if (lowerCase) {
      Map<Locale, String> lowerCaseValues = new HashMap<>(values.size());

      for (Map.Entry<Locale, String> entry : values.entrySet()) {
        String value = GetterUtil.getString(entry.getValue());

        lowerCaseValues.put(entry.getKey(), StringUtil.toLowerCase(value));
      }

      values = lowerCaseValues;
    }

    createField(name, values);
  }

  @Override
  public void addLocalizedKeyword(
      String name, Map<Locale, String> values, boolean lowerCase, boolean sortable) {

    if ((values == null) || values.isEmpty()) {
      return;
    }

    if (lowerCase) {
      Map<Locale, String> lowerCaseValues = new HashMap<>(values.size());

      for (Map.Entry<Locale, String> entry : values.entrySet()) {
        String value = GetterUtil.getString(entry.getValue());

        lowerCaseValues.put(entry.getKey(), StringUtil.toLowerCase(value));
      }

      values = lowerCaseValues;
    }

    createField(name, values, sortable);
  }

  @Override
  public void addLocalizedText(String name, Map<Locale, String> values) {
    if ((values == null) || values.isEmpty()) {
      return;
    }

    Field field = createField(name, values);

    field.setTokenized(true);
  }

  @Override
  public void addNumber(String name, BigDecimal value) {
    createNumberField(name, value);
  }

  @Override
  public void addNumber(String name, BigDecimal[] values) {
    createNumberField(name, values);
  }

  @Override
  public void addNumber(String name, double value) {
    createNumberField(name, Double.valueOf(value));
  }

  @Override
  public void addNumber(String name, Double value) {
    createNumberField(name, value);
  }

  @Override
  public void addNumber(String name, double[] values) {
    if (values == null) {
      return;
    }

    createNumberField(name, ArrayUtil.toArray(values));
  }

  @Override
  public void addNumber(String name, Double[] values) {
    createNumberField(name, values);
  }

  @Override
  public void addNumber(String name, float value) {
    createNumberField(name, Float.valueOf(value));
  }

  @Override
  public void addNumber(String name, Float value) {
    createNumberField(name, value);
  }

  @Override
  public void addNumber(String name, float[] values) {
    if (values == null) {
      return;
    }

    createNumberField(name, ArrayUtil.toArray(values));
  }

  @Override
  public void addNumber(String name, Float[] values) {
    createNumberField(name, values);
  }

  @Override
  public void addNumber(String name, int value) {
    createNumberField(name, Integer.valueOf(value));
  }

  @Override
  public void addNumber(String name, int[] values) {
    if (values == null) {
      return;
    }

    createNumberField(name, ArrayUtil.toArray(values));
  }

  @Override
  public void addNumber(String name, Integer value) {
    createNumberField(name, value);
  }

  @Override
  public void addNumber(String name, Integer[] values) {
    createNumberField(name, values);
  }

  @Override
  public void addNumber(String name, long value) {
    createNumberField(name, Long.valueOf(value));
  }

  @Override
  public void addNumber(String name, Long value) {
    createNumberField(name, value);
  }

  @Override
  public void addNumber(String name, long[] values) {
    if (values == null) {
      return;
    }

    createNumberField(name, ArrayUtil.toArray(values));
  }

  @Override
  public void addNumber(String name, Long[] values) {
    createNumberField(name, values);
  }

  @Override
  public void addNumber(String name, String value) {
    createNumberField(name, Long.valueOf(value));
  }

  @Override
  public void addNumber(String name, String[] values) {
    if (values == null) {
      return;
    }

    Long[] longs = new Long[values.length];

    for (int i = 0; i < values.length; i++) {
      longs[i] = Long.valueOf(values[i]);
    }

    createNumberField(name, longs);
  }

  @Override
  public void addNumberSortable(String name, BigDecimal value) {
    createNumberFieldWithTypedSortable(name, value);
  }

  @Override
  public void addNumberSortable(String name, BigDecimal[] values) {
    createNumberFieldWithTypedSortable(name, values);
  }

  @Override
  public void addNumberSortable(String name, Double value) {
    createNumberFieldWithTypedSortable(name, value);
  }

  @Override
  public void addNumberSortable(String name, Double[] values) {
    createNumberFieldWithTypedSortable(name, values);
  }

  @Override
  public void addNumberSortable(String name, Float value) {
    createNumberFieldWithTypedSortable(name, value);
  }

  @Override
  public void addNumberSortable(String name, Float[] values) {
    createNumberFieldWithTypedSortable(name, values);
  }

  @Override
  public void addNumberSortable(String name, Integer value) {
    createNumberFieldWithTypedSortable(name, value);
  }

  @Override
  public void addNumberSortable(String name, Integer[] values) {
    createNumberFieldWithTypedSortable(name, values);
  }

  @Override
  public void addNumberSortable(String name, Long value) {
    createNumberFieldWithTypedSortable(name, value);
  }

  @Override
  public void addNumberSortable(String name, Long[] values) {
    createNumberFieldWithTypedSortable(name, values);
  }

  @Override
  public void addText(String name, String value) {
    if (Validator.isNull(value)) {
      return;
    }

    Field field = createField(name, value);

    field.setTokenized(true);

    createSortableKeywordField(name, value);
  }

  @Override
  public void addText(String name, String[] values) {
    if (values == null) {
      return;
    }

    Field field = createField(name, values);

    field.setTokenized(true);

    createSortableKeywordField(name, values);
  }

  @Override
  public void addTextSortable(String name, String value) {
    if (Validator.isNull(value)) {
      return;
    }

    Field field = createField(name, value);

    field.setTokenized(true);

    createSortableTextField(name, value);
  }

  @Override
  public void addTextSortable(String name, String[] values) {
    if (values == null) {
      return;
    }

    Field field = createField(name, values);

    field.setTokenized(true);

    createSortableTextField(name, values);
  }

  @Override
  public void addUID(String portletId, long field1) {
    addUID(portletId, String.valueOf(field1));
  }

  @Override
  public void addUID(String portletId, long field1, String field2) {
    addUID(portletId, String.valueOf(field1), field2);
  }

  @Override
  public void addUID(String portletId, Long field1) {
    addUID(portletId, field1.longValue());
  }

  @Override
  public void addUID(String portletId, Long field1, String field2) {
    addUID(portletId, field1.longValue(), field2);
  }

  @Override
  public void addUID(String portletId, String field1) {
    addUID(portletId, field1, null);
  }

  @Override
  public void addUID(String portletId, String field1, String field2) {
    addUID(portletId, field1, field2, null);
  }

  @Override
  public void addUID(String portletId, String field1, String field2, String field3) {

    addUID(portletId, field1, field2, field3, null);
  }

  @Override
  public void addUID(String portletId, String field1, String field2, String field3, String field4) {

    String uid = portletId + _UID_PORTLET + field1;

    if (field2 != null) {
      uid += _UID_FIELD + field2;
    }

    if (field3 != null) {
      uid += _UID_FIELD + field3;
    }

    if (field4 != null) {
      uid += _UID_FIELD + field4;
    }

    addKeyword(Field.UID, uid);
  }

  @Override
  public Object clone() {
    DocumentImpl documentImpl = new DocumentImpl();

    documentImpl.setSortableTextFields(_sortableTextFields);

    return documentImpl;
  }

  @Override
  public String get(Locale locale, String name) {
    if (locale == null) {
      return get(name);
    }

    String localizedName = getLocalizedName(locale, name);

    Field field = getField(localizedName);

    if (field == null) {
      field = getField(name);
    }

    if (field == null) {
      return StringPool.BLANK;
    }

    return field.getValue();
  }

  @Override
  public String get(Locale locale, String name, String defaultName) {
    if (locale == null) {
      return get(name, defaultName);
    }

    String localizedName = getLocalizedName(locale, name);

    Field field = getField(localizedName);

    if (field == null) {
      localizedName = getLocalizedName(locale, defaultName);

      field = getField(localizedName);
    }

    if (field == null) {
      return StringPool.BLANK;
    }

    return field.getValue();
  }

  @Override
  public String get(String name) {
    Field field = getField(name);

    if (field == null) {
      return StringPool.BLANK;
    }

    return field.getValue();
  }

  @Override
  public String get(String name, String defaultName) {
    Field field = getField(name);

    if (field == null) {
      return get(defaultName);
    }

    return field.getValue();
  }

  @Override
  public Date getDate(String name) throws ParseException {
    DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat(_INDEX_DATE_FORMAT_PATTERN);

    return dateFormat.parse(get(name));
  }

  @Override
  public Field getField(String name) {
    return doGetField(name, false);
  }

  @Override
  public Map<String, Field> getFields() {
    return _fields;
  }

  @Override
  public String getPortletId() {
    String uid = getUID();

    int pos = uid.indexOf(_UID_PORTLET);

    return uid.substring(0, pos);
  }

  @Override
  public String getUID() {
    Field field = getField(Field.UID);

    if (field == null) {
      throw new RuntimeException("UID is not set");
    }

    return field.getValue();
  }

  @Override
  public String[] getValues(String name) {
    Field field = getField(name);

    if (field == null) {
      return new String[] {StringPool.BLANK};
    }

    return field.getValues();
  }

  @Override
  public boolean hasField(String name) {
    if (_fields.containsKey(name)) {
      return true;
    }

    return false;
  }

  @Override
  public boolean isDocumentSortableTextField(String name) {
    return _sortableTextFields.contains(name);
  }

  @Override
  public void remove(String name) {
    _fields.remove(name);
  }

  public void setFields(Map<String, Field> fields) {
    _fields = fields;
  }

  @Override
  public void setSortableTextFields(String[] sortableTextFields) {
    _sortableTextFields = SetUtil.fromArray(sortableTextFields);
  }

  @Override
  public String toString() {
    StringBundler sb = new StringBundler(5 * _fields.size());

    toString(sb, _fields.values());

    return sb.toString();
  }

  protected Field createField(String name) {
    return doGetField(name, true);
  }

  protected Field createField(String name, boolean sortable, String... values) {

    Field field = createField(name);

    field.setSortable(sortable);
    field.setValues(values);

    return field;
  }

  protected Field createField(String name, Map<Locale, String> localizedValues) {

    return createField(name, localizedValues, false);
  }

  protected Field createField(String name, Map<Locale, String> localizedValues, boolean sortable) {

    Field field = createField(name);

    field.setLocalizedValues(localizedValues);
    field.setSortable(sortable);

    return field;
  }

  protected Field createField(String name, String... values) {
    return createField(name, false, values);
  }

  protected void createKeywordField(String name, String value, boolean lowerCase) {

    if (lowerCase && Validator.isNotNull(value)) {
      value = StringUtil.toLowerCase(value);
    }

    createField(name, value);
  }

  protected void createNumberField(String name, boolean typify, Number value) {

    if (value == null) {
      return;
    }

    String valueString = String.valueOf(value);

    createSortableNumericField(name, typify, valueString, value.getClass());

    createField(name, valueString);
  }

  protected <T extends Number & Comparable<? super T>> void createNumberField(
      String name, boolean typify, T... values) {

    if (values == null) {
      return;
    }

    createSortableNumericField(name, typify, values);

    createField(name, ArrayUtil.toStringArray(values));
  }

  protected void createNumberField(String name, Number value) {
    createNumberField(name, false, value);
  }

  protected <T extends Number & Comparable<? super T>> void createNumberField(
      String name, T... values) {

    createNumberField(name, false, values);
  }

  protected void createNumberFieldWithTypedSortable(String name, Number value) {

    createNumberField(name, true, value);
  }

  protected <T extends Number & Comparable<? super T>> void createNumberFieldWithTypedSortable(
      String name, T... values) {

    createNumberField(name, true, values);
  }

  protected void createSortableKeywordField(String name, String value) {
    if (isDocumentSortableTextField(name)) {
      createSortableTextField(name, value);
    }
  }

  protected void createSortableKeywordField(String name, String[] values) {
    if (isDocumentSortableTextField(name)) {
      createSortableTextField(name, values);
    }
  }

  protected void createSortableNumericField(
      String name, boolean typify, String value, Class<? extends Number> clazz) {

    if (typify) {
      name = name.concat(StringPool.UNDERLINE).concat("Number");
    }

    Field field = createField(getSortableFieldName(name), value);

    field.setNumeric(true);
    field.setNumericClass(clazz);
  }

  protected <T extends Number & Comparable<? super T>> void createSortableNumericField(
      String name, boolean typify, T... values) {

    if ((values == null) || (values.length == 0)) {
      return;
    }

    T minValue = Collections.min(Arrays.asList(values));

    createSortableNumericField(name, typify, String.valueOf(minValue), minValue.getClass());
  }

  protected void createSortableTextField(String name, String value) {
    String truncatedValue = value;

    if (value.length() > _SORTABLE_TEXT_FIELDS_TRUNCATED_LENGTH) {
      truncatedValue = value.substring(0, _SORTABLE_TEXT_FIELDS_TRUNCATED_LENGTH);
    }

    createKeywordField(getSortableFieldName(name), truncatedValue, true);
  }

  protected void createSortableTextField(String name, String[] values) {
    if (values.length == 0) {
      return;
    }

    createSortableTextField(name, Collections.min(Arrays.asList(values)));
  }

  protected Field doGetField(String name, boolean createIfNew) {
    Field field = _fields.get(name);

    if ((field == null) && createIfNew) {
      field = new Field(name);

      _fields.put(name, field);
    }

    return field;
  }

  protected void setSortableTextFields(Set<String> sortableTextFields) {
    _sortableTextFields = sortableTextFields;
  }

  protected void toString(StringBundler sb, Collection<Field> fields) {
    sb.append(StringPool.OPEN_CURLY_BRACE);

    boolean firstField = true;

    for (Field field : fields) {
      if (!firstField) {
        sb.append(StringPool.COMMA);
        sb.append(StringPool.SPACE);
      } else {
        firstField = false;
      }

      if (field.hasChildren()) {
        sb.append(field.getName());
        sb.append(StringPool.COLON);

        toString(sb, field.getFields());
      } else {
        sb.append(field.getName());
        sb.append(StringPool.EQUAL);
        sb.append(Arrays.toString(field.getValues()));
      }
    }

    sb.append(StringPool.CLOSE_CURLY_BRACE);
  }

  private static final String _INDEX_DATE_FORMAT_PATTERN =
      PropsUtil.get(PropsKeys.INDEX_DATE_FORMAT_PATTERN);

  private static final String _SORTABLE_FIELD_SUFFIX = "sortable";

  private static final int _SORTABLE_TEXT_FIELDS_TRUNCATED_LENGTH =
      GetterUtil.getInteger(PropsUtil.get(PropsKeys.INDEX_SORTABLE_TEXT_FIELDS_TRUNCATED_LENGTH));

  private static final String _UID_FIELD = "_FIELD_";

  private static final String _UID_PORTLET = "_PORTLET_";

  private static Format _dateFormat;
  private static final Set<String> _defaultSortableTextFields =
      SetUtil.fromArray(PropsUtil.getArray(PropsKeys.INDEX_SORTABLE_TEXT_FIELDS));

  private Map<String, Field> _fields = new HashMap<>();
  private Set<String> _sortableTextFields = _defaultSortableTextFields;
}
/**
 * The persistence implementation for the asset service.
 *
 * <p>Caching information and settings can be found in <code>portal.properties</code>
 *
 * @author Brian Wing Shun Chan
 * @see AssetPersistence
 * @see AssetUtil
 * @generated
 */
public class AssetPersistenceImpl extends BasePersistenceImpl<Asset> implements AssetPersistence {
  /*
   * NOTE FOR DEVELOPERS:
   *
   * Never modify or reference this class directly. Always use {@link AssetUtil} to access the asset persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
   */
  public static final String FINDER_CLASS_NAME_ENTITY = AssetImpl.class.getName();
  public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION =
      FINDER_CLASS_NAME_ENTITY + ".List1";
  public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION =
      FINDER_CLASS_NAME_ENTITY + ".List2";
  public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL =
      new FinderPath(
          AssetModelImpl.ENTITY_CACHE_ENABLED,
          AssetModelImpl.FINDER_CACHE_ENABLED,
          AssetImpl.class,
          FINDER_CLASS_NAME_LIST_WITH_PAGINATION,
          "findAll",
          new String[0]);
  public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL =
      new FinderPath(
          AssetModelImpl.ENTITY_CACHE_ENABLED,
          AssetModelImpl.FINDER_CACHE_ENABLED,
          AssetImpl.class,
          FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
          "findAll",
          new String[0]);
  public static final FinderPath FINDER_PATH_COUNT_ALL =
      new FinderPath(
          AssetModelImpl.ENTITY_CACHE_ENABLED,
          AssetModelImpl.FINDER_CACHE_ENABLED,
          Long.class,
          FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
          "countAll",
          new String[0]);

  public AssetPersistenceImpl() {
    setModelClass(Asset.class);
  }

  /**
   * Caches the asset in the entity cache if it is enabled.
   *
   * @param asset the asset
   */
  @Override
  public void cacheResult(Asset asset) {
    EntityCacheUtil.putResult(
        AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey(), asset);

    asset.resetOriginalValues();
  }

  /**
   * Caches the assets in the entity cache if it is enabled.
   *
   * @param assets the assets
   */
  @Override
  public void cacheResult(List<Asset> assets) {
    for (Asset asset : assets) {
      if (EntityCacheUtil.getResult(
              AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey())
          == null) {
        cacheResult(asset);
      } else {
        asset.resetOriginalValues();
      }
    }
  }

  /**
   * Clears the cache for all assets.
   *
   * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link
   * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
   */
  @Override
  public void clearCache() {
    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      CacheRegistryUtil.clear(AssetImpl.class.getName());
    }

    EntityCacheUtil.clearCache(AssetImpl.class.getName());

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }

  /**
   * Clears the cache for the asset.
   *
   * <p>The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link
   * com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
   */
  @Override
  public void clearCache(Asset asset) {
    EntityCacheUtil.removeResult(
        AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey());

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }

  @Override
  public void clearCache(List<Asset> assets) {
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);

    for (Asset asset : assets) {
      EntityCacheUtil.removeResult(
          AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey());
    }
  }

  /**
   * Creates a new asset with the primary key. Does not add the asset to the database.
   *
   * @param assetId the primary key for the new asset
   * @return the new asset
   */
  @Override
  public Asset create(long assetId) {
    Asset asset = new AssetImpl();

    asset.setNew(true);
    asset.setPrimaryKey(assetId);

    return asset;
  }

  /**
   * Removes the asset with the primary key from the database. Also notifies the appropriate model
   * listeners.
   *
   * @param assetId the primary key of the asset
   * @return the asset that was removed
   * @throws com.liferay.ams.NoSuchAssetException if a asset with the primary key could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public Asset remove(long assetId) throws NoSuchAssetException, SystemException {
    return remove((Serializable) assetId);
  }

  /**
   * Removes the asset with the primary key from the database. Also notifies the appropriate model
   * listeners.
   *
   * @param primaryKey the primary key of the asset
   * @return the asset that was removed
   * @throws com.liferay.ams.NoSuchAssetException if a asset with the primary key could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public Asset remove(Serializable primaryKey) throws NoSuchAssetException, SystemException {
    Session session = null;

    try {
      session = openSession();

      Asset asset = (Asset) session.get(AssetImpl.class, primaryKey);

      if (asset == null) {
        if (_log.isWarnEnabled()) {
          _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        throw new NoSuchAssetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      return remove(asset);
    } catch (NoSuchAssetException nsee) {
      throw nsee;
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }
  }

  @Override
  protected Asset removeImpl(Asset asset) throws SystemException {
    asset = toUnwrappedModel(asset);

    Session session = null;

    try {
      session = openSession();

      if (!session.contains(asset)) {
        asset = (Asset) session.get(AssetImpl.class, asset.getPrimaryKeyObj());
      }

      if (asset != null) {
        session.delete(asset);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    if (asset != null) {
      clearCache(asset);
    }

    return asset;
  }

  @Override
  public Asset updateImpl(com.liferay.ams.model.Asset asset) throws SystemException {
    asset = toUnwrappedModel(asset);

    boolean isNew = asset.isNew();

    Session session = null;

    try {
      session = openSession();

      if (asset.isNew()) {
        session.save(asset);

        asset.setNew(false);
      } else {
        session.merge(asset);
      }
    } catch (Exception e) {
      throw processException(e);
    } finally {
      closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew) {
      FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    EntityCacheUtil.putResult(
        AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, asset.getPrimaryKey(), asset);

    asset.resetOriginalValues();

    return asset;
  }

  protected Asset toUnwrappedModel(Asset asset) {
    if (asset instanceof AssetImpl) {
      return asset;
    }

    AssetImpl assetImpl = new AssetImpl();

    assetImpl.setNew(asset.isNew());
    assetImpl.setPrimaryKey(asset.getPrimaryKey());

    assetImpl.setAssetId(asset.getAssetId());
    assetImpl.setCompanyId(asset.getCompanyId());
    assetImpl.setUserId(asset.getUserId());
    assetImpl.setUserName(asset.getUserName());
    assetImpl.setCreateDate(asset.getCreateDate());
    assetImpl.setModifiedDate(asset.getModifiedDate());
    assetImpl.setDefinitionId(asset.getDefinitionId());
    assetImpl.setSerialNumber(asset.getSerialNumber());
    assetImpl.setInactiveDate(asset.getInactiveDate());
    assetImpl.setActive(asset.isActive());

    return assetImpl;
  }

  /**
   * Returns the asset with the primary key or throws a {@link
   * com.liferay.portal.NoSuchModelException} if it could not be found.
   *
   * @param primaryKey the primary key of the asset
   * @return the asset
   * @throws com.liferay.ams.NoSuchAssetException if a asset with the primary key could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public Asset findByPrimaryKey(Serializable primaryKey)
      throws NoSuchAssetException, SystemException {
    Asset asset = fetchByPrimaryKey(primaryKey);

    if (asset == null) {
      if (_log.isWarnEnabled()) {
        _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
      }

      throw new NoSuchAssetException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
    }

    return asset;
  }

  /**
   * Returns the asset with the primary key or throws a {@link com.liferay.ams.NoSuchAssetException}
   * if it could not be found.
   *
   * @param assetId the primary key of the asset
   * @return the asset
   * @throws com.liferay.ams.NoSuchAssetException if a asset with the primary key could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public Asset findByPrimaryKey(long assetId) throws NoSuchAssetException, SystemException {
    return findByPrimaryKey((Serializable) assetId);
  }

  /**
   * Returns the asset with the primary key or returns <code>null</code> if it could not be found.
   *
   * @param primaryKey the primary key of the asset
   * @return the asset, or <code>null</code> if a asset with the primary key could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public Asset fetchByPrimaryKey(Serializable primaryKey) throws SystemException {
    Asset asset =
        (Asset)
            EntityCacheUtil.getResult(
                AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, primaryKey);

    if (asset == _nullAsset) {
      return null;
    }

    if (asset == null) {
      Session session = null;

      try {
        session = openSession();

        asset = (Asset) session.get(AssetImpl.class, primaryKey);

        if (asset != null) {
          cacheResult(asset);
        } else {
          EntityCacheUtil.putResult(
              AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, primaryKey, _nullAsset);
        }
      } catch (Exception e) {
        EntityCacheUtil.removeResult(
            AssetModelImpl.ENTITY_CACHE_ENABLED, AssetImpl.class, primaryKey);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return asset;
  }

  /**
   * Returns the asset with the primary key or returns <code>null</code> if it could not be found.
   *
   * @param assetId the primary key of the asset
   * @return the asset, or <code>null</code> if a asset with the primary key could not be found
   * @throws SystemException if a system exception occurred
   */
  @Override
  public Asset fetchByPrimaryKey(long assetId) throws SystemException {
    return fetchByPrimaryKey((Serializable) assetId);
  }

  /**
   * Returns all the assets.
   *
   * @return the assets
   * @throws SystemException if a system exception occurred
   */
  @Override
  public List<Asset> findAll() throws SystemException {
    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
  }

  /**
   * Returns a range of all the assets.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set. If <code>orderByComparator</code> is specified, then the query
   * will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and
   * pagination is required (<code>start</code> and <code>end</code> are not {@link
   * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default
   * ORDER BY logic from {@link com.liferay.ams.model.impl.AssetModelImpl}. If both <code>
   * orderByComparator</code> and pagination are absent, for performance reasons, the query will not
   * have an ORDER BY clause and the returned result set will be sorted on by the primary key in an
   * ascending order.
   *
   * @param start the lower bound of the range of assets
   * @param end the upper bound of the range of assets (not inclusive)
   * @return the range of assets
   * @throws SystemException if a system exception occurred
   */
  @Override
  public List<Asset> findAll(int start, int end) throws SystemException {
    return findAll(start, end, null);
  }

  /**
   * Returns an ordered range of all the assets.
   *
   * <p>Useful when paginating results. Returns a maximum of <code>end - start</code> instances.
   * <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result
   * set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start
   * </code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}
   * will return the full result set. If <code>orderByComparator</code> is specified, then the query
   * will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and
   * pagination is required (<code>start</code> and <code>end</code> are not {@link
   * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default
   * ORDER BY logic from {@link com.liferay.ams.model.impl.AssetModelImpl}. If both <code>
   * orderByComparator</code> and pagination are absent, for performance reasons, the query will not
   * have an ORDER BY clause and the returned result set will be sorted on by the primary key in an
   * ascending order.
   *
   * @param start the lower bound of the range of assets
   * @param end the upper bound of the range of assets (not inclusive)
   * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
   * @return the ordered range of assets
   * @throws SystemException if a system exception occurred
   */
  @Override
  public List<Asset> findAll(int start, int end, OrderByComparator orderByComparator)
      throws SystemException {
    boolean pagination = true;
    FinderPath finderPath = null;
    Object[] finderArgs = null;

    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) {
      pagination = false;
      finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
      finderArgs = FINDER_ARGS_EMPTY;
    } else {
      finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
      finderArgs = new Object[] {start, end, orderByComparator};
    }

    List<Asset> list = (List<Asset>) FinderCacheUtil.getResult(finderPath, finderArgs, this);

    if (list == null) {
      StringBundler query = null;
      String sql = null;

      if (orderByComparator != null) {
        query = new StringBundler(2 + (orderByComparator.getOrderByFields().length * 3));

        query.append(_SQL_SELECT_ASSET);

        appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator);

        sql = query.toString();
      } else {
        sql = _SQL_SELECT_ASSET;

        if (pagination) {
          sql = sql.concat(AssetModelImpl.ORDER_BY_JPQL);
        }
      }

      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(sql);

        if (!pagination) {
          list = (List<Asset>) QueryUtil.list(q, getDialect(), start, end, false);

          Collections.sort(list);

          list = new UnmodifiableList<Asset>(list);
        } else {
          list = (List<Asset>) QueryUtil.list(q, getDialect(), start, end);
        }

        cacheResult(list);

        FinderCacheUtil.putResult(finderPath, finderArgs, list);
      } catch (Exception e) {
        FinderCacheUtil.removeResult(finderPath, finderArgs);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return list;
  }

  /**
   * Removes all the assets from the database.
   *
   * @throws SystemException if a system exception occurred
   */
  @Override
  public void removeAll() throws SystemException {
    for (Asset asset : findAll()) {
      remove(asset);
    }
  }

  /**
   * Returns the number of assets.
   *
   * @return the number of assets
   * @throws SystemException if a system exception occurred
   */
  @Override
  public int countAll() throws SystemException {
    Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, this);

    if (count == null) {
      Session session = null;

      try {
        session = openSession();

        Query q = session.createQuery(_SQL_COUNT_ASSET);

        count = (Long) q.uniqueResult();

        FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY, count);
      } catch (Exception e) {
        FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL, FINDER_ARGS_EMPTY);

        throw processException(e);
      } finally {
        closeSession(session);
      }
    }

    return count.intValue();
  }

  @Override
  protected Set<String> getBadColumnNames() {
    return _badColumnNames;
  }

  /** Initializes the asset persistence. */
  public void afterPropertiesSet() {
    String[] listenerClassNames =
        StringUtil.split(
            GetterUtil.getString(
                com.liferay.util.service.ServiceProps.get(
                    "value.object.listener.com.liferay.ams.model.Asset")));

    if (listenerClassNames.length > 0) {
      try {
        List<ModelListener<Asset>> listenersList = new ArrayList<ModelListener<Asset>>();

        for (String listenerClassName : listenerClassNames) {
          listenersList.add(
              (ModelListener<Asset>)
                  InstanceFactory.newInstance(getClassLoader(), listenerClassName));
        }

        listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
      } catch (Exception e) {
        _log.error(e);
      }
    }
  }

  public void destroy() {
    EntityCacheUtil.removeCache(AssetImpl.class.getName());
    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
  }

  private static final String _SQL_SELECT_ASSET = "SELECT asset FROM Asset asset";
  private static final String _SQL_COUNT_ASSET = "SELECT COUNT(asset) FROM Asset asset";
  private static final String _ORDER_BY_ENTITY_ALIAS = "asset.";
  private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY =
      "No Asset exists with the primary key ";
  private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE =
      GetterUtil.getBoolean(PropsUtil.get(PropsKeys.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE));
  private static Log _log = LogFactoryUtil.getLog(AssetPersistenceImpl.class);
  private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {"active"});
  private static Asset _nullAsset =
      new AssetImpl() {
        @Override
        public Object clone() {
          return this;
        }

        @Override
        public CacheModel<Asset> toCacheModel() {
          return _nullAssetCacheModel;
        }
      };

  private static CacheModel<Asset> _nullAssetCacheModel =
      new CacheModel<Asset>() {
        @Override
        public Asset toEntityModel() {
          return _nullAsset;
        }
      };
}
/**
 * @author Romeo Sheshi
 * @author Ivan Novakov <*****@*****.**>
 */
public class ShibbolethPropsValues {
  public static final boolean SHIBBOLETH_ENABLED =
      GetterUtil.getBoolean(PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_ENABLED));

  public static final String SHIBBOLETH_HEADER =
      PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_HEADER);

  public static final String SHIBBOLETH_HEADER_EMAIL =
      PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_HEADER_EMAIL);

  public static final String SHIBBOLETH_HEADER_FIRSTNAME =
      PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_HEADER_FIRSTNAME);

  public static final String SHIBBOLETH_HEADER_SURNAME =
      PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_HEADER_SURNAME);

  public static final String SHIBBOLETH_HEADER_AFFILIATION =
      PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_HEADER_AFFILIATION);

  public static final boolean SHIBBOLETH_USER_AUTO_CREATE =
      GetterUtil.getBoolean(PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_USER_AUTO_CREATE));

  public static final boolean SHIBBOLETH_USER_AUTO_UPDATE =
      GetterUtil.getBoolean(PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_USER_AUTO_UPDATE));

  public static final boolean SHIBBOLETH_USER_LDAP_IMPORT =
      GetterUtil.getBoolean(PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_USER_LDAP_IMPORT));

  public static final boolean SHIBBOLETH_USER_ROLE_AUTO_ASSIGN =
      GetterUtil.getBoolean(PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_USER_ROLE_AUTO_ASSIGN));

  public static final String SHIBBOLETH_USER_ROLE_AUTO_ASSIGN_SUBTYPE =
      PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_USER_ROLE_AUTO_ASSIGN_SUBTYPE);

  public static final boolean SHIBBOLETH_LOGOUT_ENABLE =
      GetterUtil.getBoolean(PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_LOGOUT_ENABLE));

  public static final String SHIBBOLETH_LOGOUT_URL =
      PropsUtil.get(ShibbolethPropsKeys.SHIBBOLETH_LOGOUT_URL);
}