001/* 002 * (C) Copyright 2006-2017 Nuxeo (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 */ 019package org.nuxeo.ecm.platform.content.template.service; 020 021import java.io.Serializable; 022import java.util.ArrayList; 023import java.util.List; 024import java.util.stream.Collectors; 025 026import org.nuxeo.common.xmap.annotation.XNode; 027import org.nuxeo.common.xmap.annotation.XNodeList; 028import org.nuxeo.common.xmap.annotation.XObject; 029 030/** 031 * Template item descriptor. Immutable. 032 */ 033@XObject(value = "templateItem") 034public class TemplateItemDescriptor implements Serializable { 035 036 private static final long serialVersionUID = 18765764747899L; 037 038 @XNode("@typeName") 039 private String typeName; 040 041 @XNode("@id") 042 private String id; 043 044 @XNode("@title") 045 private String title; 046 047 @XNode("@path") 048 private String path; 049 050 @XNode("@description") 051 private String description; 052 053 // Declared as ArrayList to be serializable. 054 @XNodeList(value = "acl/ace", type = ArrayList.class, componentType = ACEDescriptor.class) 055 public List<ACEDescriptor> acl; 056 057 @XNodeList(value = "properties/property", type = ArrayList.class, componentType = PropertyDescriptor.class) 058 public List<PropertyDescriptor> properties; 059 060 @XNodeList(value = "notifications/notification", type = ArrayList.class, componentType = NotificationDescriptor.class) 061 public List<NotificationDescriptor> notifications; 062 063 public TemplateItemDescriptor() { 064 // default constructor 065 acl = new ArrayList<>(); 066 properties = new ArrayList<>(); 067 notifications = new ArrayList<>(); 068 } 069 070 public TemplateItemDescriptor(TemplateItemDescriptor toCopy) { 071 this.typeName = toCopy.typeName; 072 this.id = toCopy.id; 073 this.title = toCopy.title; 074 this.path = toCopy.path; 075 this.description = toCopy.description; 076 this.acl = toCopy.acl.stream().map(ACEDescriptor::new).collect(Collectors.toList()); 077 this.properties = toCopy.properties.stream().map(PropertyDescriptor::new).collect(Collectors.toList()); 078 this.notifications = toCopy.notifications.stream().map(NotificationDescriptor::new).collect(Collectors.toList()); 079 } 080 081 public String getPath() { 082 return path; 083 } 084 085 public String getDescription() { 086 return description; 087 } 088 089 public String getId() { 090 return id; 091 } 092 093 public String getTypeName() { 094 return typeName; 095 } 096 097 public String getTitle() { 098 return title; 099 } 100 101 public List<ACEDescriptor> getAcl() { 102 return acl; 103 } 104 105 public List<PropertyDescriptor> getProperties() { 106 return properties; 107 } 108 109 public List<NotificationDescriptor> getNotifications() { 110 return notifications; 111 } 112 113}