title: CQ - Check whether the resource object is valid
body: <p>I need to check whether the resource object is valid or not for the below 'resource' object. For example If I pass any url like <code>getResource("some path which is not available in cq")</code> in this case I need to restrict it</p>
  
  <pre><code>Resource resource= resourceResolver.getResource(/content/rc/test/jcr:content");
  Node node = resource.adaptTo(Node.class);
  String parentPagePath= node.getProperty("someproperty").getValue().getString();
  </code></pre>
  
  <p>Is there any way to do?</p>