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.util.ArrayList; 022import java.util.List; 023import java.util.stream.Collectors; 024 025import org.nuxeo.common.xmap.annotation.XNode; 026import org.nuxeo.common.xmap.annotation.XNodeList; 027import org.nuxeo.common.xmap.annotation.XObject; 028 029/** 030 * Template item descriptor. Immutable. 031 */ 032@XObject(value = "templateItem") 033public class TemplateItemDescriptor { 034 035 @XNode("@typeName") 036 private String typeName; 037 038 @XNode("@id") 039 private String id; 040 041 @XNode("@title") 042 private String title; 043 044 @XNode("@path") 045 private String path; 046 047 @XNode("@description") 048 private String description; 049 050 @XNodeList(value = "acl/ace", type = ArrayList.class, componentType = ACEDescriptor.class) 051 public List<ACEDescriptor> acl; 052 053 @XNodeList(value = "properties/property", type = ArrayList.class, componentType = PropertyDescriptor.class) 054 public List<PropertyDescriptor> properties; 055 056 @XNodeList(value = "notifications/notification", type = ArrayList.class, componentType = NotificationDescriptor.class) 057 public List<NotificationDescriptor> notifications; 058 059 public TemplateItemDescriptor() { 060 // default constructor 061 acl = new ArrayList<>(); 062 properties = new ArrayList<>(); 063 notifications = new ArrayList<>(); 064 } 065 066 public TemplateItemDescriptor(TemplateItemDescriptor toCopy) { 067 this.typeName = toCopy.typeName; 068 this.id = toCopy.id; 069 this.title = toCopy.title; 070 this.path = toCopy.path; 071 this.description = toCopy.description; 072 this.acl = toCopy.acl.stream().map(ACEDescriptor::new).collect(Collectors.toList()); 073 this.properties = toCopy.properties.stream().map(PropertyDescriptor::new).collect(Collectors.toList()); 074 this.notifications = toCopy.notifications.stream().map(NotificationDescriptor::new).collect(Collectors.toList()); 075 } 076 077 public String getPath() { 078 return path; 079 } 080 081 public String getDescription() { 082 return description; 083 } 084 085 public String getId() { 086 return id; 087 } 088 089 public String getTypeName() { 090 return typeName; 091 } 092 093 public String getTitle() { 094 return title; 095 } 096 097 public List<ACEDescriptor> getAcl() { 098 return acl; 099 } 100 101 public List<PropertyDescriptor> getProperties() { 102 return properties; 103 } 104 105 public List<NotificationDescriptor> getNotifications() { 106 return notifications; 107 } 108 109}