/* 
 * Copyright 2012-2016 bambooCORE, greenstep of copyright Chen Xin Nien
 * 
 * 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.
 * 
 * -----------------------------------------------------------------------
 * 
 * author: 	Chen Xin Nien
 * contact: chen.xin.nien@gmail.com
 * 
 */
package com.netsteadfast.greenstep.action;

import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.netsteadfast.greenstep.base.Constants;
import com.netsteadfast.greenstep.base.action.BaseSupportAction;
import com.netsteadfast.greenstep.base.exception.ControllerException;
import com.netsteadfast.greenstep.base.exception.ServiceException;
import com.netsteadfast.greenstep.base.model.ControllerAuthority;
import com.netsteadfast.greenstep.util.UploadSupportUtils;

@ControllerAuthority(check=true)
@Controller("core.web.controller.CommonPrintContentAction")
@Scope
public class CommonPrintContentAction extends BaseSupportAction {
	private static final long serialVersionUID = -5861669971660024741L;
	private String oid = ""; // TB_UPLOAD.OID
	private String value = "";
	
	public CommonPrintContentAction() {
		super();
	}
	
	private void loadData() throws ServiceException, Exception {
		byte[] data = UploadSupportUtils.getDataBytes(this.oid);
		this.value = new String(data, Constants.BASE_ENCODING);
	}
	
	public String execute() throws Exception {
		String forward = RESULT_BLANK;
		try {
			if (StringUtils.isBlank(this.oid)) {
				return forward;
			}
			this.loadData();
			forward = RESULT_BLANK_VALUE;
		} catch (ControllerException e) {
			this.setPageMessage(e.getMessage().toString());
		} catch (ServiceException e) {
			this.setPageMessage(e.getMessage().toString());
		} catch (Exception e) {
			e.printStackTrace();
			this.setPageMessage(e.getMessage().toString());
		}
		return forward;				
	}	
	
	public String getOid() {
		return oid;
	}

	public void setOid(String oid) {
		this.oid = oid;
	}

	public String getValue() {
		if (null == this.value) {
			return "";
		}
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}
	
}

@@ -1355,16 +1355,87 @@
 Utils;%0A%0A
+/**%0A * %E9%80%99%E5%80%8B controller action %E4%B8%BB%E8%A6%81%E6%98%AF%E9%85%8D%E5%90%88 ApiWebService , %E8%AE%80%E5%8F%96%E8%BC%B8%E5%87%BA%E7%9A%84 url %E9%A1%AF%E7%A4%BA%E5%A0%B1%E8%A1%A8%E7%B5%90%E6%9E%9C%0A */%0A
 @Control
@@ -1971,16 +1971,133 @@
 );%0A%09%7D%0A%09%0A
+%09/**%0A%09 * core.printContentAction.action%0A%09 * bsc.printContentAction.action%0A%09 * qcharts.printContentAction.action%0A%09 */%0A
 %09public 

Update CommonPrintContentAction.java