1 /*
2 * Copyright 2003 - 2013 The eFaps Team
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * Revision: $Rev$
17 * Last Changed: $Date$
18 * Last Changed By: $Author$
19 */
20
21
22 package org.efaps.rest;
23
24 import java.util.UUID;
25
26 import org.efaps.admin.user.Role;
27 import org.efaps.db.Context;
28 import org.efaps.util.EFapsException;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32
33 /**
34 * Base class for all Rest implementations inside eFaps.
35 *
36 * @author The eFaps Team
37 * @version $Id$
38 */
39 public abstract class AbstractRest
40 {
41 /**
42 * Logging instance used to give logging information of this class.
43 */
44 protected static final Logger LOG = LoggerFactory.getLogger(AbstractRest.class);
45
46 /**
47 * Check if the logged in users has access to rest.
48 * User must be assigned to the Role "Admin_Rest".
49 *
50 * @return true if user is assigned to Roles "Admin_Rest", else false
51 * @throws EFapsException on error
52 */
53 protected boolean hasAccess()
54 throws EFapsException
55 {
56 //Admin_REST
57 return Context.getThreadContext().getPerson().isAssigned(Role.get(
58 UUID.fromString("2d142645-140d-46ad-af67-835161a8d732")));
59 }
60 }