1 /*******************************************************************************
2 * ============LICENSE_START====================================================
4 * * ===========================================================================
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * * ===========================================================================
7 * * Licensed under the Apache License, Version 2.0 (the "License");
8 * * you may not use this file except in compliance with the License.
9 * * You may obtain a copy of the License at
11 * * http://www.apache.org/licenses/LICENSE-2.0
13 * * Unless required by applicable law or agreed to in writing, software
14 * * distributed under the License is distributed on an "AS IS" BASIS,
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * * See the License for the specific language governing permissions and
17 * * limitations under the License.
18 * * ============LICENSE_END====================================================
21 ******************************************************************************/
22 package org.onap.aaf.org;
25 import java.io.IOException;
27 import org.onap.aaf.auth.local.AbsData;
28 import org.onap.aaf.auth.local.DataFile.Token.Field;
31 * Example User Data file, which can be modified for many different kinds of Data Feeds.
33 * Note: This has shown to be extremely effective in AT&T, an acknowledged very large organizations,
34 * because there is no need to synchronize records. AAF simply receives a Data Feed in Organization
35 * defined intervals. (You might want to check for validity, such as size, etc), then is copied into
36 * Data Directory. You will want to do so first creating a "lock" file. Assuming the File name is "users.dat",
37 * the Lock File is "users.lock".
39 * After the movement of the Datafile into place, it is best to remove the Index File, then remove the lock file.
41 * Note, Any AAF Programs needing this data WILL wait on the Lock file, so you should get fresh Data files
42 * in a "stage" directory, from WEB, or wherever, and then, after it is correct, do the following as fast as feasible.
49 * If the Index File is either non-existent or out of date from the Data File, it will be reindexed, which
50 * has proven to be a very quick function, even with large numbers of entries.
52 * This Sample Feed is set for a file with delimiter of "|". 512 is maximum expected line length. The "0" is the
53 * field offset for the "key" to the record, which, for user, should be the unique Organization Identity.
56 public class Identities extends AbsData {
57 public final static Data NO_DATA = new Data();
59 public Identities(File users) throws IOException {
60 super(users,'|',512,0);
64 * Example Field Layout. note, in this example, Application IDs and People IDs are mixed. You may want to split
65 * out AppIDs, choose your own status indicators, or whatever you use.
72 * 6 - employment status e=employee, c=contractor, a=application, n=no longer with company
73 * 7 - responsible to (i.e Supervisor for People, or AppOwner, if it's an App ID)
75 public static class Data {
76 public final String id;
77 public final String name;
78 public final String fname;
79 public final String lname;
80 public final String phone;
81 public final String email;
82 public final String status;
83 public final String responsibleTo;
85 private Data(Field f) {
94 responsibleTo =f.next();
98 id = name = fname = lname =
99 phone = email = status = responsibleTo
103 public String toString() {
114 // Here, make up your own Methods which help you easily determine your Organization's structure
115 // in your Organization Object
116 public boolean hasStatus(String possible) {
117 return possible.contains(status);
120 public boolean isEmployee() {
121 return "e".equals(status);
124 public boolean isContractor() {
125 return "c".equals(status);
128 public boolean isApplication() {
129 return "a".equals(status);
133 public Data find(Object key,Reuse r) throws IOException {
135 // These are new, to allow for Thread Safety
136 int rec = ti.find(key,r,0);
141 return new Data(r.getFieldData());