// Path: src/main/java/com/webpagebytes/wpbsample/utility/SampleFopService.java
// public class SampleFopService {
// 
// 	private static SampleFopService instance;
// 	private FopFactory fopFactory;
// 	private TransformerFactory transformerFactory;
// 	private static volatile Object lock = new Object();
// 	
// 	private SampleFopService()
// 	{
// 		transformerFactory = TransformerFactory.newInstance();
// 		fopFactory = FopFactory.newInstance();
// 	}
// 
// 	public static SampleFopService getInstance()
// 	{
// 		if (instance == null)
// 		{
// 			synchronized (lock)
// 			{
// 				if (null == instance)
// 				{
// 					instance = new SampleFopService();
// 				}
// 			}
// 		}
// 		return instance;
// 	}
// 	
// 	public void getContent(InputStream  is, String mimeType, OutputStream os) throws Exception
// 	{
// 		Source source = null;
// 		try
// 		{	
// 			Transformer transformer = transformerFactory.newTransformer(); // identity transformer
// 			source = new StreamSource(is);		
// 			Fop fop = fopFactory.newFop(mimeType, os);
// 			Result res = new SAXResult(fop.getDefaultHandler());
// 			transformer.transform(source, res);			
// 		} catch (Exception e)
// 		{
// 			throw e;
// 		}
// 	}
// 
// }


import com.webpagebytes.wpbsample.utility.SampleFopService;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.apache.fop.apps.MimeConstants;
import com.webpagebytes.cms.WPBContentProvider;
import com.webpagebytes.cms.WPBForward;
import com.webpagebytes.cms.WPBModel;
import com.webpagebytes.cms.exception.WPBException;

/*
 *   Copyright 2015 Webpagebytes
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

package com.webpagebytes.wpbsample.controllers;





public class NotificationImageController extends GenericController {


		public void initialize(WPBContentProvider contentProvider) {
			// TODO Auto-generated method stub
			super.initialize(contentProvider);
		}

		public void handleRequest(HttpServletRequest request,
				HttpServletResponse response, WPBModel model, WPBForward forward) throws WPBException {
			
			OutputStream os = null;
			ByteArrayOutputStream baos = new ByteArrayOutputStream(10000);
			ByteArrayInputStream bis = null;
			try
			{
				String type=request.getParameter("type");
				if (null != type)
				{
					model.getCmsApplicationModel().put("type", type);
				}
				response.setContentType("image/png");

// Path: src/main/java/com/webpagebytes/wpbsample/utility/SampleFopService.java
// public class SampleFopService {
// 
// 	private static SampleFopService instance;
// 	private FopFactory fopFactory;
// 	private TransformerFactory transformerFactory;
// 	private static volatile Object lock = new Object();
// 	
// 	private SampleFopService()
// 	{
// 		transformerFactory = TransformerFactory.newInstance();
// 		fopFactory = FopFactory.newInstance();
// 	}
// 
// 	public static SampleFopService getInstance()
// 	{
// 		if (instance == null)
// 		{
// 			synchronized (lock)
// 			{
// 				if (null == instance)
// 				{
// 					instance = new SampleFopService();
// 				}
// 			}
// 		}
// 		return instance;
// 	}
// 	
// 	public void getContent(InputStream  is, String mimeType, OutputStream os) throws Exception
// 	{
// 		Source source = null;
// 		try
// 		{	
// 			Transformer transformer = transformerFactory.newTransformer(); // identity transformer
// 			source = new StreamSource(is);		
// 			Fop fop = fopFactory.newFop(mimeType, os);
// 			Result res = new SAXResult(fop.getDefaultHandler());
// 			transformer.transform(source, res);			
// 		} catch (Exception e)
// 		{
// 			throw e;
// 		}
// 	}
// 
// }


// Path: src/main/java/com/webpagebytes/wpbsample/controllers/NotificationImageController.java
import com.webpagebytes.wpbsample.utility.SampleFopService;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.apache.fop.apps.MimeConstants;
import com.webpagebytes.cms.WPBContentProvider;
import com.webpagebytes.cms.WPBForward;
import com.webpagebytes.cms.WPBModel;
import com.webpagebytes.cms.exception.WPBException;

/*
 *   Copyright 2015 Webpagebytes
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

package com.webpagebytes.wpbsample.controllers;





public class NotificationImageController extends GenericController {


		public void initialize(WPBContentProvider contentProvider) {
			// TODO Auto-generated method stub
			super.initialize(contentProvider);
		}

		public void handleRequest(HttpServletRequest request,
				HttpServletResponse response, WPBModel model, WPBForward forward) throws WPBException {
			
			OutputStream os = null;
			ByteArrayOutputStream baos = new ByteArrayOutputStream(10000);
			ByteArrayInputStream bis = null;
			try
			{
				String type=request.getParameter("type");
				if (null != type)
				{
					model.getCmsApplicationModel().put("type", type);
				}
				response.setContentType("image/png");

				SampleFopService fopService = SampleFopService.getInstance();
