1 /*******************************************************************************
2  * Copyright (c) 2008, 2017 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *     Red Hat Inc. - Fix compiler problems from generified IAdaptable#getAdapter
14  *******************************************************************************/
15 package org.eclipse.equinox.internal.p2.updatesite.artifact;
16 
17 import java.io.OutputStream;
18 import java.net.URI;
19 import java.util.Map;
20 import org.eclipse.core.runtime.IProgressMonitor;
21 import org.eclipse.core.runtime.IStatus;
22 import org.eclipse.equinox.p2.core.IProvisioningAgent;
23 import org.eclipse.equinox.p2.core.ProvisionException;
24 import org.eclipse.equinox.p2.metadata.IArtifactKey;
25 import org.eclipse.equinox.p2.metadata.Version;
26 import org.eclipse.equinox.p2.query.*;
27 import org.eclipse.equinox.p2.repository.IRunnableWithProgress;
28 import org.eclipse.equinox.p2.repository.artifact.*;
29 
30 public class UpdateSiteArtifactRepository implements IArtifactRepository {
31 
32 	public static final String TYPE = "org.eclipse.equinox.p2.updatesite.artifactRepository"; //$NON-NLS-1$
33 	public static final String VERSION = Integer.toString(1);
34 
35 	private URI location;
36 	private IArtifactRepository delegate;
37 
UpdateSiteArtifactRepository(URI location, IArtifactRepository repository)38 	public UpdateSiteArtifactRepository(URI location, IArtifactRepository repository) {
39 		this.location = location;
40 		this.delegate = repository;
41 	}
42 
43 	@Override
addDescriptor(IArtifactDescriptor descriptor, IProgressMonitor monitor)44 	public void addDescriptor(IArtifactDescriptor descriptor, IProgressMonitor monitor) {
45 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
46 	}
47 
48 	@Override
49 	@Deprecated
addDescriptor(IArtifactDescriptor descriptor)50 	public void addDescriptor(IArtifactDescriptor descriptor) {
51 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
52 	}
53 
54 	@Override
addDescriptors(IArtifactDescriptor[] descriptors, IProgressMonitor monitor)55 	public void addDescriptors(IArtifactDescriptor[] descriptors, IProgressMonitor monitor) {
56 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
57 	}
58 
59 	@Override
60 	@Deprecated
addDescriptors(IArtifactDescriptor[] descriptors)61 	public void addDescriptors(IArtifactDescriptor[] descriptors) {
62 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
63 	}
64 
65 	@Override
contains(IArtifactDescriptor descriptor)66 	public boolean contains(IArtifactDescriptor descriptor) {
67 		return delegate.contains(descriptor);
68 	}
69 
70 	@Override
contains(IArtifactKey key)71 	public boolean contains(IArtifactKey key) {
72 		return delegate.contains(key);
73 	}
74 
75 	@Override
getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor)76 	public IStatus getArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
77 		return delegate.getArtifact(descriptor, destination, monitor);
78 	}
79 
80 	@Override
getArtifactDescriptors(IArtifactKey key)81 	public IArtifactDescriptor[] getArtifactDescriptors(IArtifactKey key) {
82 		return delegate.getArtifactDescriptors(key);
83 	}
84 
85 	@Override
getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor)86 	public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) {
87 		return delegate.getArtifacts(requests, monitor);
88 	}
89 
90 	@Override
getOutputStream(IArtifactDescriptor descriptor)91 	public OutputStream getOutputStream(IArtifactDescriptor descriptor) throws ProvisionException {
92 		// TODO Auto-generated method stub
93 		return null;
94 	}
95 
96 	@Override
getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor)97 	public IStatus getRawArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) {
98 		return delegate.getRawArtifact(descriptor, destination, monitor);
99 	}
100 
101 	@Override
removeAll(IProgressMonitor monitor)102 	public void removeAll(IProgressMonitor monitor) {
103 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
104 	}
105 
106 	@Override
107 	@Deprecated
removeAll()108 	public void removeAll() {
109 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
110 	}
111 
112 	@Override
removeDescriptor(IArtifactDescriptor descriptor, IProgressMonitor monitor)113 	public void removeDescriptor(IArtifactDescriptor descriptor, IProgressMonitor monitor) {
114 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
115 	}
116 
117 	@Override
118 	@Deprecated
removeDescriptor(IArtifactDescriptor descriptor)119 	public void removeDescriptor(IArtifactDescriptor descriptor) {
120 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
121 	}
122 
123 	@Override
removeDescriptors(IArtifactDescriptor[] descriptors, IProgressMonitor monitor)124 	public void removeDescriptors(IArtifactDescriptor[] descriptors, IProgressMonitor monitor) {
125 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
126 	}
127 
128 	@Override
129 	@Deprecated
removeDescriptors(IArtifactDescriptor[] descriptors)130 	public void removeDescriptors(IArtifactDescriptor[] descriptors) {
131 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
132 	}
133 
134 	@Override
removeDescriptor(IArtifactKey key, IProgressMonitor monitor)135 	public void removeDescriptor(IArtifactKey key, IProgressMonitor monitor) {
136 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
137 	}
138 
139 	@Override
140 	@Deprecated
removeDescriptor(IArtifactKey key)141 	public void removeDescriptor(IArtifactKey key) {
142 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
143 	}
144 
145 	@Override
removeDescriptors(IArtifactKey[] keys, IProgressMonitor monitor)146 	public void removeDescriptors(IArtifactKey[] keys, IProgressMonitor monitor) {
147 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
148 	}
149 
150 	@Override
151 	@Deprecated
removeDescriptors(IArtifactKey[] keys)152 	public void removeDescriptors(IArtifactKey[] keys) {
153 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
154 	}
155 
156 	@Override
getDescription()157 	public String getDescription() {
158 		return delegate.getDescription();
159 	}
160 
161 	@Override
getLocation()162 	public URI getLocation() {
163 		return this.location;
164 	}
165 
166 	@Override
getName()167 	public String getName() {
168 		return delegate.getName();
169 	}
170 
171 	@Override
getProperties()172 	public Map<String, String> getProperties() {
173 		return delegate.getProperties();
174 	}
175 
176 	@Override
getProperty(String key)177 	public String getProperty(String key) {
178 		return delegate.getProperty(key);
179 	}
180 
181 	@Override
getProvider()182 	public String getProvider() {
183 		return delegate.getProvider();
184 	}
185 
186 	@Override
getProvisioningAgent()187 	public IProvisioningAgent getProvisioningAgent() {
188 		return delegate.getProvisioningAgent();
189 	}
190 
191 	@Override
getType()192 	public String getType() {
193 		return TYPE;
194 	}
195 
196 	@Override
getVersion()197 	public String getVersion() {
198 		return VERSION;
199 	}
200 
201 	@Override
isModifiable()202 	public boolean isModifiable() {
203 		return false;
204 	}
205 
setDescription(String description)206 	public void setDescription(String description) {
207 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
208 	}
209 
setName(String name)210 	public void setName(String name) {
211 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
212 	}
213 
214 	@Override
setProperty(String key, String value, IProgressMonitor monitor)215 	public String setProperty(String key, String value, IProgressMonitor monitor) {
216 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
217 	}
218 
219 	@Override
setProperty(String key, String value)220 	public String setProperty(String key, String value) {
221 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
222 	}
223 
setProvider(String provider)224 	public void setProvider(String provider) {
225 		throw new UnsupportedOperationException("Repository not modifiable: " + location); //$NON-NLS-1$
226 	}
227 
228 	@Override
getAdapter(Class<T> adapter)229 	public <T> T getAdapter(Class<T> adapter) {
230 		return delegate.getAdapter(adapter);
231 	}
232 
233 	@Override
createArtifactDescriptor(IArtifactKey key)234 	public IArtifactDescriptor createArtifactDescriptor(IArtifactKey key) {
235 		return delegate.createArtifactDescriptor(key);
236 	}
237 
238 	@Override
createArtifactKey(String classifier, String id, Version version)239 	public IArtifactKey createArtifactKey(String classifier, String id, Version version) {
240 		return delegate.createArtifactKey(classifier, id, version);
241 	}
242 
243 	@Override
descriptorQueryable()244 	public IQueryable<IArtifactDescriptor> descriptorQueryable() {
245 		return delegate.descriptorQueryable();
246 	}
247 
248 	@Override
query(IQuery<IArtifactKey> query, IProgressMonitor monitor)249 	public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) {
250 		return delegate.query(query, monitor);
251 	}
252 
253 	@Override
executeBatch(IRunnableWithProgress runnable, IProgressMonitor monitor)254 	public IStatus executeBatch(IRunnableWithProgress runnable, IProgressMonitor monitor) {
255 		return delegate.executeBatch(runnable, monitor);
256 	}
257 }
258