@@ -109,11 +109,6 @@ protected ResourceBase(final UriInfo uriInfo, final Request request, final Media
109109 {
110110 super (uriInfo , request , mediaTypes , uri , service );
111111
112- // if (templateCall == null)
113- // {
114- // if (log.isDebugEnabled()) log.debug("Resource {} has not matched any template, returning 404 Not Found", getURI());
115- // throw new NotFoundException("Resource has not matched any template");
116- // }
117112 if (application == null ) throw new IllegalArgumentException ("Application cannot be null" );
118113 if (ontology == null ) throw new IllegalArgumentException ("Ontology cannot be null" );
119114 if (httpHeaders == null ) throw new IllegalArgumentException ("HttpHeaders cannot be null" );
@@ -203,13 +198,7 @@ protected ResourceBase(final UriInfo uriInfo, final Request request, final Media
203198 @ Override
204199 public Object getSubResource ()
205200 {
206- if (!getTemplateCall ().isPresent ())
207- {
208- if (log .isDebugEnabled ()) log .debug ("Resource {} has not matched any ldt:Template, returning 404 Not Found" , getURI ());
209- throw new NotFoundException ("Resource has not matched any ldt:Template" );
210- }
211-
212- if (getTemplateCall ().get ().getTemplate ().getLoadClass () != null )
201+ if (getTemplateCall ().isPresent () && getTemplateCall ().get ().getTemplate ().getLoadClass () != null )
213202 {
214203 Resource javaClass = getTemplateCall ().get ().getTemplate ().getLoadClass ();
215204 if (!javaClass .isURIResource ())
@@ -235,6 +224,11 @@ public Object getSubResource()
235224 @ Override
236225 public Response get ()
237226 {
227+ if (!getTemplateCall ().isPresent ())
228+ {
229+ if (log .isDebugEnabled ()) log .debug ("Resource {} has not matched any ldt:Template, returning 404 Not Found" , getURI ());
230+ throw new NotFoundException ("Resource has not matched any ldt:Template" );
231+ }
238232 if (getQueryResource () == null ) // cannot be validated in constructor in Jersey 2.x: https://github.com/eclipse-ee4j/jersey/issues/4436
239233 {
240234 if (log .isErrorEnabled ()) log .error ("ldt:query value for template '{}' is missing" , getTemplateCall ().get ().getTemplate ());
0 commit comments