001/* 002 * (C) Copyright 2015 Nuxeo SA (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 018 */ 019 020package org.nuxeo.ecm.showcase.content.service; 021 022import java.net.URL; 023 024import org.nuxeo.common.xmap.annotation.XNode; 025import org.nuxeo.common.xmap.annotation.XObject; 026import org.nuxeo.ecm.core.api.NuxeoException; 027import org.nuxeo.runtime.model.ComponentInstance; 028 029@XObject(value = "content") 030public class ShowcaseContentDescriptor { 031 032 @XNode("@name") 033 protected String name; 034 035 @XNode("filename") 036 protected String filename; 037 038 @XNode("@enable") 039 protected boolean enabled = true; 040 041 protected URL blobUrl; 042 043 public String getName() { 044 return name; 045 } 046 047 public void setName(String name) { 048 this.name = name; 049 } 050 051 public String getFilename() { 052 return filename; 053 } 054 055 public void setFilename(String filename) { 056 this.filename = filename; 057 } 058 059 public URL getBlobUrl() { 060 if (blobUrl == null) { 061 throw new NuxeoException("Unable to find expected file: " + filename); 062 } 063 return blobUrl; 064 } 065 066 public void setBlobUrl(URL blobUrl) { 067 this.blobUrl = blobUrl; 068 } 069 070 public void computeBlobUrl(ComponentInstance component) { 071 setBlobUrl(component.getRuntimeContext().getResource(filename)); 072 } 073}