All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.backendless.AbstractDataPermission Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
/*
 * ********************************************************************************************************************
 *  

* BACKENDLESS.COM CONFIDENTIAL *

* ******************************************************************************************************************** *

* Copyright 2012 BACKENDLESS.COM. All Rights Reserved. *

* NOTICE: All information contained herein is, and remains the property of Backendless.com and its suppliers, * if any. The intellectual and technical concepts contained herein are proprietary to Backendless.com and its * suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret * or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from Backendless.com. *

* ******************************************************************************************************************** */ package com.backendless; import com.backendless.async.callback.AsyncCallback; import com.backendless.core.responder.AdaptingResponder; import com.backendless.core.responder.policy.PoJoAdaptingPolicy; import com.backendless.persistence.PersistenceOperations; import com.backendless.utils.PermissionTypes; public abstract class AbstractDataPermission { private static final String PERMISSION_SERVICE = "com.backendless.services.persistence.permissions.ClientPermissionService"; protected abstract PersistenceOperations getOperation(); public void grantForUser( String userId, T dataObject ) { grantForUser( userId, dataObject, null ); } public void grantForUser( String userId, T dataObject, AsyncCallback responder ) { String method = "updateUserPermission"; Object[] args = { Backendless.getApplicationId(), Backendless.getVersion(), dataObject.getClass().getSimpleName(), userId, Persistence.getEntityId( dataObject ), getOperation(), PermissionTypes.GRANT }; serverCall( responder, method, args, dataObject.getClass() ); } public void denyForUser( String userId, T dataObject ) { denyForUser( userId, dataObject, null ); } public void denyForUser( String userId, T dataObject, AsyncCallback responder ) { String method = "updateUserPermission"; Object[] args = { Backendless.getApplicationId(), Backendless.getVersion(), dataObject.getClass().getSimpleName(), userId, Persistence.getEntityId( dataObject ), getOperation(), PermissionTypes.DENY }; serverCall( responder, method, args, null ); } public void grantForRole( String roleName, Object dataObject ) { grantForRole( roleName, dataObject, null ); } public void grantForRole( String roleName, Object dataObject, AsyncCallback responder ) { String method = "updateRolePermission"; Object[] args = { Backendless.getApplicationId(), Backendless.getVersion(), dataObject.getClass().getSimpleName(), roleName, Persistence.getEntityId( dataObject ), getOperation(), PermissionTypes.GRANT }; serverCall( responder, method, args, dataObject.getClass() ); } public void denyForRole( String roleName, Object dataObject ) { denyForRole( roleName, dataObject, null ); } public void denyForRole( String roleName, Object dataObject, AsyncCallback responder ) { String method = "updateRolePermission"; Object[] args = { Backendless.getApplicationId(), Backendless.getVersion(), dataObject.getClass().getSimpleName(), roleName, Persistence.getEntityId( dataObject ), getOperation(), PermissionTypes.DENY }; serverCall( responder, method, args, null ); } public void grantForAllUsers( Object dataObject ) { grantForAllUsers( dataObject, null ); } public void grantForAllUsers( Object dataObject, AsyncCallback responder ) { String method = "updateAllUserPermission"; Object[] args = { Backendless.getApplicationId(), Backendless.getVersion(), dataObject.getClass().getSimpleName(), Persistence.getEntityId( dataObject ), getOperation(), PermissionTypes.GRANT }; serverCall( responder, method, args, dataObject.getClass() ); } public void denyForAllUsers( Object dataObject ) { denyForAllUsers( dataObject, null ); } public void denyForAllUsers( Object dataObject, AsyncCallback responder ) { String method = "updateAllUserPermission"; Object[] args = { Backendless.getApplicationId(), Backendless.getVersion(), dataObject.getClass().getSimpleName(), Persistence.getEntityId( dataObject ), getOperation(), PermissionTypes.DENY }; serverCall( responder, method, args, null ); } public void grantForAllRoles( Object dataObject ) { grantForAllRoles( dataObject, null ); } public void grantForAllRoles( Object dataObject, AsyncCallback responder ) { String method = "updateAllRolePermission"; Object[] args = { Backendless.getApplicationId(), Backendless.getVersion(), dataObject.getClass().getSimpleName(), Persistence.getEntityId( dataObject ), getOperation(), PermissionTypes.GRANT }; serverCall( responder, method, args, dataObject.getClass() ); } public void denyForAllRoles( Object dataObject ) { denyForAllRoles( dataObject, null ); } public void denyForAllRoles( Object dataObject, AsyncCallback responder ) { String method = "updateAllRolePermission"; Object[] args = { Backendless.getApplicationId(), Backendless.getVersion(), dataObject.getClass().getSimpleName(), Persistence.getEntityId( dataObject ), getOperation(), PermissionTypes.DENY }; serverCall( responder, method, args, null ); } private void serverCall( AsyncCallback responder, String method, Object[] args, Class type ) { Invoker.invokeAsync( PERMISSION_SERVICE, method, args, responder, new AdaptingResponder( type, new PoJoAdaptingPolicy() ) ); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy