Java tutorial
/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.services.service; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.io.unsync.UnsyncByteArrayInputStream; import com.liferay.portal.kernel.io.unsync.UnsyncByteArrayOutputStream; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.util.ClassLoaderObjectInputStream; import com.liferay.portal.kernel.util.PropsUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.model.BaseModel; import com.services.model.AgencyClp; import com.services.model.BookingStatusClp; import com.services.model.BusClp; import com.services.model.BusEmployeeClp; import com.services.model.BusReservationClp; import com.services.model.BusRouteClp; import com.services.model.BusRouteTimingsClp; import com.services.model.CouponClp; import com.services.model.LocationClp; import com.services.model.UserCouponClp; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; /** * @author Ankur Srivastava */ public class ClpSerializer { public static String getServletContextName() { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } synchronized (ClpSerializer.class) { if (Validator.isNotNull(_servletContextName)) { return _servletContextName; } try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps"); Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class }); String portletPropsServletContextName = (String) getMethod.invoke(null, "booking-portlet-deployment-context"); if (Validator.isNotNull(portletPropsServletContextName)) { _servletContextName = portletPropsServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portlet properties"); } } if (Validator.isNull(_servletContextName)) { try { String propsUtilServletContextName = PropsUtil.get("booking-portlet-deployment-context"); if (Validator.isNotNull(propsUtilServletContextName)) { _servletContextName = propsUtilServletContextName; } } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to locate deployment context from portal properties"); } } } if (Validator.isNull(_servletContextName)) { _servletContextName = "booking-portlet"; } return _servletContextName; } } public static Object translateInput(BaseModel<?> oldModel) { Class<?> oldModelClass = oldModel.getClass(); String oldModelClassName = oldModelClass.getName(); if (oldModelClassName.equals(AgencyClp.class.getName())) { return translateInputAgency(oldModel); } if (oldModelClassName.equals(BookingStatusClp.class.getName())) { return translateInputBookingStatus(oldModel); } if (oldModelClassName.equals(BusClp.class.getName())) { return translateInputBus(oldModel); } if (oldModelClassName.equals(BusEmployeeClp.class.getName())) { return translateInputBusEmployee(oldModel); } if (oldModelClassName.equals(BusReservationClp.class.getName())) { return translateInputBusReservation(oldModel); } if (oldModelClassName.equals(BusRouteClp.class.getName())) { return translateInputBusRoute(oldModel); } if (oldModelClassName.equals(BusRouteTimingsClp.class.getName())) { return translateInputBusRouteTimings(oldModel); } if (oldModelClassName.equals(CouponClp.class.getName())) { return translateInputCoupon(oldModel); } if (oldModelClassName.equals(LocationClp.class.getName())) { return translateInputLocation(oldModel); } if (oldModelClassName.equals(UserCouponClp.class.getName())) { return translateInputUserCoupon(oldModel); } return oldModel; } public static Object translateInput(List<Object> oldList) { List<Object> newList = new ArrayList<Object>(oldList.size()); for (int i = 0; i < oldList.size(); i++) { Object curObj = oldList.get(i); newList.add(translateInput(curObj)); } return newList; } public static Object translateInputAgency(BaseModel<?> oldModel) { AgencyClp oldClpModel = (AgencyClp) oldModel; BaseModel<?> newModel = oldClpModel.getAgencyRemoteModel(); newModel.setModelAttributes(oldClpModel.getModelAttributes()); return newModel; } public static Object translateInputBookingStatus(BaseModel<?> oldModel) { BookingStatusClp oldClpModel = (BookingStatusClp) oldModel; BaseModel<?> newModel = oldClpModel.getBookingStatusRemoteModel(); newModel.setModelAttributes(oldClpModel.getModelAttributes()); return newModel; } public static Object translateInputBus(BaseModel<?> oldModel) { BusClp oldClpModel = (BusClp) oldModel; BaseModel<?> newModel = oldClpModel.getBusRemoteModel(); newModel.setModelAttributes(oldClpModel.getModelAttributes()); return newModel; } public static Object translateInputBusEmployee(BaseModel<?> oldModel) { BusEmployeeClp oldClpModel = (BusEmployeeClp) oldModel; BaseModel<?> newModel = oldClpModel.getBusEmployeeRemoteModel(); newModel.setModelAttributes(oldClpModel.getModelAttributes()); return newModel; } public static Object translateInputBusReservation(BaseModel<?> oldModel) { BusReservationClp oldClpModel = (BusReservationClp) oldModel; BaseModel<?> newModel = oldClpModel.getBusReservationRemoteModel(); newModel.setModelAttributes(oldClpModel.getModelAttributes()); return newModel; } public static Object translateInputBusRoute(BaseModel<?> oldModel) { BusRouteClp oldClpModel = (BusRouteClp) oldModel; BaseModel<?> newModel = oldClpModel.getBusRouteRemoteModel(); newModel.setModelAttributes(oldClpModel.getModelAttributes()); return newModel; } public static Object translateInputBusRouteTimings(BaseModel<?> oldModel) { BusRouteTimingsClp oldClpModel = (BusRouteTimingsClp) oldModel; BaseModel<?> newModel = oldClpModel.getBusRouteTimingsRemoteModel(); newModel.setModelAttributes(oldClpModel.getModelAttributes()); return newModel; } public static Object translateInputCoupon(BaseModel<?> oldModel) { CouponClp oldClpModel = (CouponClp) oldModel; BaseModel<?> newModel = oldClpModel.getCouponRemoteModel(); newModel.setModelAttributes(oldClpModel.getModelAttributes()); return newModel; } public static Object translateInputLocation(BaseModel<?> oldModel) { LocationClp oldClpModel = (LocationClp) oldModel; BaseModel<?> newModel = oldClpModel.getLocationRemoteModel(); newModel.setModelAttributes(oldClpModel.getModelAttributes()); return newModel; } public static Object translateInputUserCoupon(BaseModel<?> oldModel) { UserCouponClp oldClpModel = (UserCouponClp) oldModel; BaseModel<?> newModel = oldClpModel.getUserCouponRemoteModel(); newModel.setModelAttributes(oldClpModel.getModelAttributes()); return newModel; } public static Object translateInput(Object obj) { if (obj instanceof BaseModel<?>) { return translateInput((BaseModel<?>) obj); } else if (obj instanceof List<?>) { return translateInput((List<Object>) obj); } else { return obj; } } public static Object translateOutput(BaseModel<?> oldModel) { Class<?> oldModelClass = oldModel.getClass(); String oldModelClassName = oldModelClass.getName(); if (oldModelClassName.equals("com.services.model.impl.AgencyImpl")) { return translateOutputAgency(oldModel); } else if (oldModelClassName.endsWith("Clp")) { try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Method getClpSerializerClassMethod = oldModelClass.getMethod("getClpSerializerClass"); Class<?> oldClpSerializerClass = (Class<?>) getClpSerializerClassMethod.invoke(oldModel); Class<?> newClpSerializerClass = classLoader.loadClass(oldClpSerializerClass.getName()); Method translateOutputMethod = newClpSerializerClass.getMethod("translateOutput", BaseModel.class); Class<?> oldModelModelClass = oldModel.getModelClass(); Method getRemoteModelMethod = oldModelClass .getMethod("get" + oldModelModelClass.getSimpleName() + "RemoteModel"); Object oldRemoteModel = getRemoteModelMethod.invoke(oldModel); BaseModel<?> newModel = (BaseModel<?>) translateOutputMethod.invoke(null, oldRemoteModel); return newModel; } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to translate " + oldModelClassName, t); } } } if (oldModelClassName.equals("com.services.model.impl.BookingStatusImpl")) { return translateOutputBookingStatus(oldModel); } else if (oldModelClassName.endsWith("Clp")) { try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Method getClpSerializerClassMethod = oldModelClass.getMethod("getClpSerializerClass"); Class<?> oldClpSerializerClass = (Class<?>) getClpSerializerClassMethod.invoke(oldModel); Class<?> newClpSerializerClass = classLoader.loadClass(oldClpSerializerClass.getName()); Method translateOutputMethod = newClpSerializerClass.getMethod("translateOutput", BaseModel.class); Class<?> oldModelModelClass = oldModel.getModelClass(); Method getRemoteModelMethod = oldModelClass .getMethod("get" + oldModelModelClass.getSimpleName() + "RemoteModel"); Object oldRemoteModel = getRemoteModelMethod.invoke(oldModel); BaseModel<?> newModel = (BaseModel<?>) translateOutputMethod.invoke(null, oldRemoteModel); return newModel; } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to translate " + oldModelClassName, t); } } } if (oldModelClassName.equals("com.services.model.impl.BusImpl")) { return translateOutputBus(oldModel); } else if (oldModelClassName.endsWith("Clp")) { try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Method getClpSerializerClassMethod = oldModelClass.getMethod("getClpSerializerClass"); Class<?> oldClpSerializerClass = (Class<?>) getClpSerializerClassMethod.invoke(oldModel); Class<?> newClpSerializerClass = classLoader.loadClass(oldClpSerializerClass.getName()); Method translateOutputMethod = newClpSerializerClass.getMethod("translateOutput", BaseModel.class); Class<?> oldModelModelClass = oldModel.getModelClass(); Method getRemoteModelMethod = oldModelClass .getMethod("get" + oldModelModelClass.getSimpleName() + "RemoteModel"); Object oldRemoteModel = getRemoteModelMethod.invoke(oldModel); BaseModel<?> newModel = (BaseModel<?>) translateOutputMethod.invoke(null, oldRemoteModel); return newModel; } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to translate " + oldModelClassName, t); } } } if (oldModelClassName.equals("com.services.model.impl.BusEmployeeImpl")) { return translateOutputBusEmployee(oldModel); } else if (oldModelClassName.endsWith("Clp")) { try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Method getClpSerializerClassMethod = oldModelClass.getMethod("getClpSerializerClass"); Class<?> oldClpSerializerClass = (Class<?>) getClpSerializerClassMethod.invoke(oldModel); Class<?> newClpSerializerClass = classLoader.loadClass(oldClpSerializerClass.getName()); Method translateOutputMethod = newClpSerializerClass.getMethod("translateOutput", BaseModel.class); Class<?> oldModelModelClass = oldModel.getModelClass(); Method getRemoteModelMethod = oldModelClass .getMethod("get" + oldModelModelClass.getSimpleName() + "RemoteModel"); Object oldRemoteModel = getRemoteModelMethod.invoke(oldModel); BaseModel<?> newModel = (BaseModel<?>) translateOutputMethod.invoke(null, oldRemoteModel); return newModel; } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to translate " + oldModelClassName, t); } } } if (oldModelClassName.equals("com.services.model.impl.BusReservationImpl")) { return translateOutputBusReservation(oldModel); } else if (oldModelClassName.endsWith("Clp")) { try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Method getClpSerializerClassMethod = oldModelClass.getMethod("getClpSerializerClass"); Class<?> oldClpSerializerClass = (Class<?>) getClpSerializerClassMethod.invoke(oldModel); Class<?> newClpSerializerClass = classLoader.loadClass(oldClpSerializerClass.getName()); Method translateOutputMethod = newClpSerializerClass.getMethod("translateOutput", BaseModel.class); Class<?> oldModelModelClass = oldModel.getModelClass(); Method getRemoteModelMethod = oldModelClass .getMethod("get" + oldModelModelClass.getSimpleName() + "RemoteModel"); Object oldRemoteModel = getRemoteModelMethod.invoke(oldModel); BaseModel<?> newModel = (BaseModel<?>) translateOutputMethod.invoke(null, oldRemoteModel); return newModel; } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to translate " + oldModelClassName, t); } } } if (oldModelClassName.equals("com.services.model.impl.BusRouteImpl")) { return translateOutputBusRoute(oldModel); } else if (oldModelClassName.endsWith("Clp")) { try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Method getClpSerializerClassMethod = oldModelClass.getMethod("getClpSerializerClass"); Class<?> oldClpSerializerClass = (Class<?>) getClpSerializerClassMethod.invoke(oldModel); Class<?> newClpSerializerClass = classLoader.loadClass(oldClpSerializerClass.getName()); Method translateOutputMethod = newClpSerializerClass.getMethod("translateOutput", BaseModel.class); Class<?> oldModelModelClass = oldModel.getModelClass(); Method getRemoteModelMethod = oldModelClass .getMethod("get" + oldModelModelClass.getSimpleName() + "RemoteModel"); Object oldRemoteModel = getRemoteModelMethod.invoke(oldModel); BaseModel<?> newModel = (BaseModel<?>) translateOutputMethod.invoke(null, oldRemoteModel); return newModel; } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to translate " + oldModelClassName, t); } } } if (oldModelClassName.equals("com.services.model.impl.BusRouteTimingsImpl")) { return translateOutputBusRouteTimings(oldModel); } else if (oldModelClassName.endsWith("Clp")) { try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Method getClpSerializerClassMethod = oldModelClass.getMethod("getClpSerializerClass"); Class<?> oldClpSerializerClass = (Class<?>) getClpSerializerClassMethod.invoke(oldModel); Class<?> newClpSerializerClass = classLoader.loadClass(oldClpSerializerClass.getName()); Method translateOutputMethod = newClpSerializerClass.getMethod("translateOutput", BaseModel.class); Class<?> oldModelModelClass = oldModel.getModelClass(); Method getRemoteModelMethod = oldModelClass .getMethod("get" + oldModelModelClass.getSimpleName() + "RemoteModel"); Object oldRemoteModel = getRemoteModelMethod.invoke(oldModel); BaseModel<?> newModel = (BaseModel<?>) translateOutputMethod.invoke(null, oldRemoteModel); return newModel; } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to translate " + oldModelClassName, t); } } } if (oldModelClassName.equals("com.services.model.impl.CouponImpl")) { return translateOutputCoupon(oldModel); } else if (oldModelClassName.endsWith("Clp")) { try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Method getClpSerializerClassMethod = oldModelClass.getMethod("getClpSerializerClass"); Class<?> oldClpSerializerClass = (Class<?>) getClpSerializerClassMethod.invoke(oldModel); Class<?> newClpSerializerClass = classLoader.loadClass(oldClpSerializerClass.getName()); Method translateOutputMethod = newClpSerializerClass.getMethod("translateOutput", BaseModel.class); Class<?> oldModelModelClass = oldModel.getModelClass(); Method getRemoteModelMethod = oldModelClass .getMethod("get" + oldModelModelClass.getSimpleName() + "RemoteModel"); Object oldRemoteModel = getRemoteModelMethod.invoke(oldModel); BaseModel<?> newModel = (BaseModel<?>) translateOutputMethod.invoke(null, oldRemoteModel); return newModel; } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to translate " + oldModelClassName, t); } } } if (oldModelClassName.equals("com.services.model.impl.LocationImpl")) { return translateOutputLocation(oldModel); } else if (oldModelClassName.endsWith("Clp")) { try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Method getClpSerializerClassMethod = oldModelClass.getMethod("getClpSerializerClass"); Class<?> oldClpSerializerClass = (Class<?>) getClpSerializerClassMethod.invoke(oldModel); Class<?> newClpSerializerClass = classLoader.loadClass(oldClpSerializerClass.getName()); Method translateOutputMethod = newClpSerializerClass.getMethod("translateOutput", BaseModel.class); Class<?> oldModelModelClass = oldModel.getModelClass(); Method getRemoteModelMethod = oldModelClass .getMethod("get" + oldModelModelClass.getSimpleName() + "RemoteModel"); Object oldRemoteModel = getRemoteModelMethod.invoke(oldModel); BaseModel<?> newModel = (BaseModel<?>) translateOutputMethod.invoke(null, oldRemoteModel); return newModel; } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to translate " + oldModelClassName, t); } } } if (oldModelClassName.equals("com.services.model.impl.UserCouponImpl")) { return translateOutputUserCoupon(oldModel); } else if (oldModelClassName.endsWith("Clp")) { try { ClassLoader classLoader = ClpSerializer.class.getClassLoader(); Method getClpSerializerClassMethod = oldModelClass.getMethod("getClpSerializerClass"); Class<?> oldClpSerializerClass = (Class<?>) getClpSerializerClassMethod.invoke(oldModel); Class<?> newClpSerializerClass = classLoader.loadClass(oldClpSerializerClass.getName()); Method translateOutputMethod = newClpSerializerClass.getMethod("translateOutput", BaseModel.class); Class<?> oldModelModelClass = oldModel.getModelClass(); Method getRemoteModelMethod = oldModelClass .getMethod("get" + oldModelModelClass.getSimpleName() + "RemoteModel"); Object oldRemoteModel = getRemoteModelMethod.invoke(oldModel); BaseModel<?> newModel = (BaseModel<?>) translateOutputMethod.invoke(null, oldRemoteModel); return newModel; } catch (Throwable t) { if (_log.isInfoEnabled()) { _log.info("Unable to translate " + oldModelClassName, t); } } } return oldModel; } public static Object translateOutput(List<Object> oldList) { List<Object> newList = new ArrayList<Object>(oldList.size()); for (int i = 0; i < oldList.size(); i++) { Object curObj = oldList.get(i); newList.add(translateOutput(curObj)); } return newList; } public static Object translateOutput(Object obj) { if (obj instanceof BaseModel<?>) { return translateOutput((BaseModel<?>) obj); } else if (obj instanceof List<?>) { return translateOutput((List<Object>) obj); } else { return obj; } } public static Throwable translateThrowable(Throwable throwable) { if (_useReflectionToTranslateThrowable) { try { UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(unsyncByteArrayOutputStream); objectOutputStream.writeObject(throwable); objectOutputStream.flush(); objectOutputStream.close(); UnsyncByteArrayInputStream unsyncByteArrayInputStream = new UnsyncByteArrayInputStream( unsyncByteArrayOutputStream.unsafeGetByteArray(), 0, unsyncByteArrayOutputStream.size()); Thread currentThread = Thread.currentThread(); ClassLoader contextClassLoader = currentThread.getContextClassLoader(); ObjectInputStream objectInputStream = new ClassLoaderObjectInputStream(unsyncByteArrayInputStream, contextClassLoader); throwable = (Throwable) objectInputStream.readObject(); objectInputStream.close(); return throwable; } catch (SecurityException se) { if (_log.isInfoEnabled()) { _log.info("Do not use reflection to translate throwable"); } _useReflectionToTranslateThrowable = false; } catch (Throwable throwable2) { _log.error(throwable2, throwable2); return throwable2; } } Class<?> clazz = throwable.getClass(); String className = clazz.getName(); if (className.equals(PortalException.class.getName())) { return new PortalException(); } if (className.equals(SystemException.class.getName())) { return new SystemException(); } if (className.equals("com.services.NoSuchAgencyException")) { return new com.services.NoSuchAgencyException(); } if (className.equals("com.services.NoSuchBookingStatusException")) { return new com.services.NoSuchBookingStatusException(); } if (className.equals("com.services.NoSuchBusException")) { return new com.services.NoSuchBusException(); } if (className.equals("com.services.NoSuchBusEmployeeException")) { return new com.services.NoSuchBusEmployeeException(); } if (className.equals("com.services.NoSuchBusReservationException")) { return new com.services.NoSuchBusReservationException(); } if (className.equals("com.services.NoSuchBusRouteException")) { return new com.services.NoSuchBusRouteException(); } if (className.equals("com.services.NoSuchBusRouteTimingsException")) { return new com.services.NoSuchBusRouteTimingsException(); } if (className.equals("com.services.NoSuchCouponException")) { return new com.services.NoSuchCouponException(); } if (className.equals("com.services.NoSuchLocationException")) { return new com.services.NoSuchLocationException(); } if (className.equals("com.services.NoSuchUserCouponException")) { return new com.services.NoSuchUserCouponException(); } return throwable; } public static Object translateOutputAgency(BaseModel<?> oldModel) { AgencyClp newModel = new AgencyClp(); newModel.setModelAttributes(oldModel.getModelAttributes()); newModel.setAgencyRemoteModel(oldModel); return newModel; } public static Object translateOutputBookingStatus(BaseModel<?> oldModel) { BookingStatusClp newModel = new BookingStatusClp(); newModel.setModelAttributes(oldModel.getModelAttributes()); newModel.setBookingStatusRemoteModel(oldModel); return newModel; } public static Object translateOutputBus(BaseModel<?> oldModel) { BusClp newModel = new BusClp(); newModel.setModelAttributes(oldModel.getModelAttributes()); newModel.setBusRemoteModel(oldModel); return newModel; } public static Object translateOutputBusEmployee(BaseModel<?> oldModel) { BusEmployeeClp newModel = new BusEmployeeClp(); newModel.setModelAttributes(oldModel.getModelAttributes()); newModel.setBusEmployeeRemoteModel(oldModel); return newModel; } public static Object translateOutputBusReservation(BaseModel<?> oldModel) { BusReservationClp newModel = new BusReservationClp(); newModel.setModelAttributes(oldModel.getModelAttributes()); newModel.setBusReservationRemoteModel(oldModel); return newModel; } public static Object translateOutputBusRoute(BaseModel<?> oldModel) { BusRouteClp newModel = new BusRouteClp(); newModel.setModelAttributes(oldModel.getModelAttributes()); newModel.setBusRouteRemoteModel(oldModel); return newModel; } public static Object translateOutputBusRouteTimings(BaseModel<?> oldModel) { BusRouteTimingsClp newModel = new BusRouteTimingsClp(); newModel.setModelAttributes(oldModel.getModelAttributes()); newModel.setBusRouteTimingsRemoteModel(oldModel); return newModel; } public static Object translateOutputCoupon(BaseModel<?> oldModel) { CouponClp newModel = new CouponClp(); newModel.setModelAttributes(oldModel.getModelAttributes()); newModel.setCouponRemoteModel(oldModel); return newModel; } public static Object translateOutputLocation(BaseModel<?> oldModel) { LocationClp newModel = new LocationClp(); newModel.setModelAttributes(oldModel.getModelAttributes()); newModel.setLocationRemoteModel(oldModel); return newModel; } public static Object translateOutputUserCoupon(BaseModel<?> oldModel) { UserCouponClp newModel = new UserCouponClp(); newModel.setModelAttributes(oldModel.getModelAttributes()); newModel.setUserCouponRemoteModel(oldModel); return newModel; } private static Log _log = LogFactoryUtil.getLog(ClpSerializer.class); private static String _servletContextName; private static boolean _useReflectionToTranslateThrowable = true; }