001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.dynamicdatamapping.storage;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portal.service.ServiceContext;
019    import com.liferay.portlet.dynamicdatamapping.StorageException;
020    
021    /**
022     * @author Eduardo Lundgren
023     */
024    public class StorageEngineUtil {
025    
026            public static long create(
027                            long companyId, long ddmStructureId, DDMFormValues ddmFormValues,
028                            ServiceContext serviceContext)
029                    throws StorageException {
030    
031                    return getStorageEngine().create(
032                            companyId, ddmStructureId, ddmFormValues, serviceContext);
033            }
034    
035            public static void deleteByClass(long classPK) throws StorageException {
036                    getStorageEngine().deleteByClass(classPK);
037            }
038    
039            public static void deleteByDDMStructure(long ddmStructureId)
040                    throws StorageException {
041    
042                    getStorageEngine().deleteByDDMStructure(ddmStructureId);
043            }
044    
045            public static DDMFormValues getDDMFormValues(long classPK)
046                    throws StorageException {
047    
048                    return getStorageEngine().getDDMFormValues(classPK);
049            }
050    
051            public static StorageEngine getStorageEngine() {
052                    PortalRuntimePermission.checkGetBeanProperty(StorageEngineUtil.class);
053    
054                    return _storageEngine;
055            }
056    
057            public static void update(
058                            long classPK, DDMFormValues ddmFormValues,
059                            ServiceContext serviceContext)
060                    throws StorageException {
061    
062                    getStorageEngine().update(classPK, ddmFormValues, serviceContext);
063            }
064    
065            public void setStorageEngine(StorageEngine storageEngine) {
066                    PortalRuntimePermission.checkSetBeanProperty(getClass());
067    
068                    _storageEngine = storageEngine;
069            }
070    
071            private static StorageEngine _storageEngine;
072    
073    }