2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.actions;
24 import java.io.PrintStream;
26 import org.onap.aaf.auth.env.AuthzTrans;
27 import org.onap.aaf.auth.layer.Result;
28 import org.onap.aaf.auth.org.Organization;
30 public class EmailPrint extends Email {
32 private static final int LINE_LENGTH = 100;
34 public EmailPrint(String... defaultCC) {
39 * @see org.onap.aaf.auth.actions.Email#exec(org.onap.aaf.auth.org.test.Organization, java.lang.StringBuilder)
42 protected Result<Void> exec(AuthzTrans trans, Organization org, StringBuilder msg) {
43 PrintStream out = System.out;
46 for(String s: toList) {
47 if(first) {first = false;}
48 else {out.print(',');}
55 for(String s: ccList) {
56 if(first) {first = false;}
57 else {out.print(',');}
62 out.print("Subject: ");
67 for(int start=0, end=LINE_LENGTH;go;start=end,end=Math.min(msg.length(), start+LINE_LENGTH)) {
68 int ret = msg.indexOf("\n",start+1);
71 out.println(msg.substring(start,end));
81 if(end==start+LINE_LENGTH) {
83 ret = msg.lastIndexOf(" ", end);
84 if(ret>start && ret<end) {
87 out.println(msg.substring(start,end));
89 out.print(msg.substring(start,end));
92 go = end<msg.length();