// Path: core/src/main/java/com/sinnerschrader/aem/react/exception/TechnicalException.java
// public class TechnicalException extends RuntimeException {
// 
// 	private static final long serialVersionUID = 3287666209672379245L;
// 
// 	public TechnicalException (String msg, Throwable cause) {
// 		super(msg, cause);
// 	}
// 
//   public TechnicalException(String msg) {
//     super(msg);
//   }
// 
// }
// 
// Path: core/src/main/java/com/sinnerschrader/aem/react/repo/RepositoryConnection.java
// public interface RepositoryConnection extends AutoCloseable {
// 
// 	public com.day.cq.wcm.api.PageManager getPageManager();
// 	ResourceResolver getResourceResolver();
// 
// 	public Session getSession();
// 
// 	/**
// 	 * Re-declared without "throws Exception".
// 	 */
// 	@Override
// 	public void close();
// 
// 
// }
// 
// Path: core/src/main/java/com/sinnerschrader/aem/react/repo/RepositoryConnectionFactory.java
// public interface RepositoryConnectionFactory {
// 
// 	public RepositoryConnection getConnection(String subServiceName);
// }


import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import com.sinnerschrader.aem.react.exception.TechnicalException;
import com.sinnerschrader.aem.react.repo.RepositoryConnection;
import com.sinnerschrader.aem.react.repo.RepositoryConnectionFactory;
package com.sinnerschrader.aem.react.loader;





/**
 *
 *
 *
 * @author stemey
 *
 */
@Service
@Component(immediate = true)
public class JcrScriptLoaderImpl implements ScriptLoader {

  @Reference
  private RepositoryConnectionFactory connectionFactory;

  @Override
  public Reader loadJcrScript(String nodePath, String subServiceName) {

    try (RepositoryConnection con = connectionFactory.getConnection(subServiceName)) {
      Node node;
      try {
// Path: core/src/main/java/com/sinnerschrader/aem/react/exception/TechnicalException.java
// public class TechnicalException extends RuntimeException {
// 
// 	private static final long serialVersionUID = 3287666209672379245L;
// 
// 	public TechnicalException (String msg, Throwable cause) {
// 		super(msg, cause);
// 	}
// 
//   public TechnicalException(String msg) {
//     super(msg);
//   }
// 
// }
// 
// Path: core/src/main/java/com/sinnerschrader/aem/react/repo/RepositoryConnection.java
// public interface RepositoryConnection extends AutoCloseable {
// 
// 	public com.day.cq.wcm.api.PageManager getPageManager();
// 	ResourceResolver getResourceResolver();
// 
// 	public Session getSession();
// 
// 	/**
// 	 * Re-declared without "throws Exception".
// 	 */
// 	@Override
// 	public void close();
// 
// 
// }
// 
// Path: core/src/main/java/com/sinnerschrader/aem/react/repo/RepositoryConnectionFactory.java
// public interface RepositoryConnectionFactory {
// 
// 	public RepositoryConnection getConnection(String subServiceName);
// }


// Path: core/src/main/java/com/sinnerschrader/aem/react/loader/JcrScriptLoaderImpl.java
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import com.sinnerschrader.aem.react.exception.TechnicalException;
import com.sinnerschrader.aem.react.repo.RepositoryConnection;
import com.sinnerschrader.aem.react.repo.RepositoryConnectionFactory;

package com.sinnerschrader.aem.react.loader;





/**
 *
 *
 *
 * @author stemey
 *
 */
@Service
@Component(immediate = true)
public class JcrScriptLoaderImpl implements ScriptLoader {

  @Reference
  private RepositoryConnectionFactory connectionFactory;

  @Override
  public Reader loadJcrScript(String nodePath, String subServiceName) {

    try (RepositoryConnection con = connectionFactory.getConnection(subServiceName)) {
      Node node;
      try {
        node = con.getSession().getNode(nodePath);