001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Florent Guillaume
011 */
012
013package org.nuxeo.ecm.core.storage.sql.db;
014
015import java.sql.SQLException;
016
017/**
018 * Functions used as stored procedures for Derby.
019 *
020 * @author Florent Guillaume
021 */
022public class DerbyFunctions extends EmbeddedFunctions {
023
024    public static short isInTreeString(String id, String baseId) throws SQLException {
025        return isInTree(id, baseId) ? (short) 1 : (short) 0;
026    }
027
028    public static short isInTreeLong(Long id, Long baseId) throws SQLException {
029        return isInTree(id, baseId) ? (short) 1 : (short) 0;
030    }
031
032    public static short isAccessAllowedString(String id, String principals, String permissions) throws SQLException {
033        return isAccessAllowed(id, split(principals), split(permissions)) ? (short) 1 : (short) 0;
034    }
035
036    public static short isAccessAllowedLong(Long id, String principals, String permissions) throws SQLException {
037        return isAccessAllowed(id, split(principals), split(permissions)) ? (short) 1 : (short) 0;
038    }
039
040    public static short matchesFullTextDerby(String fulltext, String query) {
041        return matchesFullText(fulltext, query) ? (short) 1 : (short) 0;
042    }
043
044}