+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package org.onap.aaf.dao.aaf.cached;\r
-\r
-import java.util.List;\r
-\r
-import org.onap.aaf.authz.env.AuthzTrans;\r
-import org.onap.aaf.authz.layer.Result;\r
-import org.onap.aaf.dao.CIDAO;\r
-import org.onap.aaf.dao.CachedDAO;\r
-import org.onap.aaf.dao.aaf.cass.PermDAO;\r
-import org.onap.aaf.dao.aaf.cass.RoleDAO;\r
-import org.onap.aaf.dao.aaf.cass.Status;\r
-import org.onap.aaf.dao.aaf.cass.PermDAO.Data;\r
-\r
-public class CachedPermDAO extends CachedDAO<AuthzTrans,PermDAO, PermDAO.Data> {\r
-\r
- public CachedPermDAO(PermDAO dao, CIDAO<AuthzTrans> info) {\r
- super(dao, info, PermDAO.CACHE_SEG);\r
- }\r
-\r
- public Result<List<Data>> readNS(AuthzTrans trans, final String ns) {\r
- DAOGetter getter = new DAOGetter(trans,dao()) {\r
- public Result<List<Data>> call() {\r
- return dao.readNS(trans, ns);\r
- }\r
- };\r
- \r
- Result<List<Data>> lurd = get(trans, ns, getter);\r
- if(lurd.isOKhasData()) {\r
- return lurd;\r
- } else {\r
- \r
- }\r
-// if(getter.result==null) {\r
-// if(lurd==null) {\r
- return Result.err(Status.ERR_PermissionNotFound,"No Permission found - " + lurd.details);\r
-// } else {\r
-// return Result.ok(lurd);\r
-// }\r
-// }\r
-// return getter.result;\r
- }\r
-\r
- public Result<List<Data>> readChildren(AuthzTrans trans, final String ns, final String type) {\r
- return dao().readChildren(trans,ns,type);\r
- }\r
-\r
- /**\r
- * \r
- * @param trans\r
- * @param ns\r
- * @param type\r
- * @return\r
- */\r
- public Result<List<Data>> readByType(AuthzTrans trans, final String ns, final String type) {\r
- DAOGetter getter = new DAOGetter(trans,dao()) {\r
- public Result<List<Data>> call() {\r
- return dao.readByType(trans, ns, type);\r
- }\r
- };\r
- \r
- // Note: Can reuse index1 here, because there is no name collision versus response\r
- Result<List<Data>> lurd = get(trans, ns+'|'+type, getter);\r
- if(lurd.isOK() && lurd.isEmpty()) {\r
- return Result.err(Status.ERR_PermissionNotFound,"No Permission found");\r
- }\r
- return lurd;\r
- }\r
- \r
- /**\r
- * Add desciption to this permission\r
- * \r
- * @param trans\r
- * @param ns\r
- * @param type\r
- * @param instance\r
- * @param action\r
- * @param description\r
- * @return\r
- */\r
- public Result<Void> addDescription(AuthzTrans trans, String ns, String type, \r
- String instance, String action, String description) {\r
- //TODO Invalidate?\r
- return dao().addDescription(trans, ns, type, instance, action, description);\r
- }\r
- \r
- public Result<Void> addRole(AuthzTrans trans, PermDAO.Data perm, RoleDAO.Data role) {\r
- Result<Void> rv = dao().addRole(trans,perm,role.encode());\r
- if(trans.debug().isLoggable())\r
- trans.debug().log("Adding",role.encode(),"to", perm, "with CachedPermDAO.addRole");\r
- invalidate(trans,perm);\r
- return rv;\r
- }\r
-\r
- public Result<Void> delRole(AuthzTrans trans, Data perm, RoleDAO.Data role) {\r
- Result<Void> rv = dao().delRole(trans,perm,role.encode());\r
- if(trans.debug().isLoggable())\r
- trans.debug().log("Removing",role.encode(),"from", perm, "with CachedPermDAO.delRole");\r
- invalidate(trans,perm);\r
- return rv;\r
- }\r
-\r
-\r
-}\r