001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Florent Guillaume 011 */ 012 013package org.nuxeo.ecm.core.storage.sql; 014 015import java.io.Serializable; 016import java.util.Calendar; 017import java.util.Comparator; 018 019/** 020 * A simple value holding one row of the ACLs table. 021 * 022 * @author Florent Guillaume 023 */ 024public class ACLRow implements Serializable { 025 026 private static final long serialVersionUID = 1L; 027 028 public final int pos; 029 030 public final String name; 031 032 public final boolean grant; 033 034 public final String permission; 035 036 public final String user; 037 038 public final String group; 039 040 /** 041 * @since 7.4 042 */ 043 public final Calendar begin; 044 045 /** 046 * @since 7.4 047 */ 048 public final Calendar end; 049 050 /** 051 * @since 7.4 052 */ 053 public final String creator; 054 055 /** 056 * Status of the ACL row: null, 0, 1 or 2. 057 * 058 * @see org.nuxeo.ecm.core.api.security.ACE 059 * @since 7.4. 060 */ 061 public final Long status; 062 063 /** 064 * @since 7.4 065 */ 066 public ACLRow(int pos, String name, boolean grant, String permission, String user, String group, String creator, 067 Calendar begin, Calendar end, Long status) { 068 this.pos = pos; 069 this.name = name; 070 this.grant = grant; 071 this.permission = permission; 072 this.user = user; 073 this.group = group; 074 this.creator = creator; 075 this.begin = begin; 076 this.end = end; 077 this.status = status; 078 } 079 080 public ACLRow(int pos, String name, boolean grant, String permission, String user, String group) { 081 this(pos, name, grant, permission, user, group, null, null, null, null); 082 } 083 084 @Override 085 public String toString() { 086 return getClass().getSimpleName() + '(' + pos + ',' + name + ',' + (grant ? "GRANT" : "DENY") + ',' + permission 087 + ',' + user + ',' + group + ',' + begin + ',' + end + +',' + status + ')'; 088 } 089 090 /** 091 * Comparator of {@link ACLRow}s according to their pos field. 092 */ 093 public static class ACLRowPositionComparator implements Comparator<ACLRow> { 094 095 public static final ACLRowPositionComparator INSTANCE = new ACLRowPositionComparator(); 096 097 @Override 098 public int compare(ACLRow acl1, ACLRow acl2) { 099 return acl1.pos - acl2.pos; 100 } 101 } 102 103}