List of usage examples for com.google.gson GsonBuilder setPrettyPrinting
public GsonBuilder setPrettyPrinting()
From source file:org.restcomm.connect.http.IncomingPhoneNumbersEndpoint.java
License:Open Source License
@PostConstruct public void init() throws ObjectInstantiationException { final DaoManager storage = (DaoManager) context.getAttribute(DaoManager.class.getName()); configuration = (Configuration) context.getAttribute(Configuration.class.getName()); super.init(configuration.subset("runtime-settings")); dao = storage.getIncomingPhoneNumbersDao(); accountsDao = storage.getAccountsDao(); /*/*from w w w. ja v a 2s.c o m*/ phoneNumberProvisioningManager = (PhoneNumberProvisioningManager) context.getAttribute("PhoneNumberProvisioningManager"); if(phoneNumberProvisioningManager == null) { final String phoneNumberProvisioningManagerClass = configuration.getString("phone-number-provisioning[@class]"); Configuration phoneNumberProvisioningConfiguration = configuration.subset("phone-number-provisioning"); Configuration telestaxProxyConfiguration = configuration.subset("runtime-settings").subset("telestax-proxy"); phoneNumberProvisioningManager = (PhoneNumberProvisioningManager) new ObjectFactory(getClass().getClassLoader()) .getObjectInstance(phoneNumberProvisioningManagerClass); ContainerConfiguration containerConfiguration = new ContainerConfiguration(getOutboundInterfaces()); phoneNumberProvisioningManager.init(phoneNumberProvisioningConfiguration, telestaxProxyConfiguration, containerConfiguration); context.setAttribute("phoneNumberProvisioningManager", phoneNumberProvisioningManager); } */ // get manager from context or create it if it does not exist phoneNumberProvisioningManager = new PhoneNumberProvisioningManagerProvider(configuration, context).get(); Configuration callbackUrlsConfiguration = configuration.subset("phone-number-provisioning") .subset("callback-urls"); phoneNumberParameters = new PhoneNumberParameters(callbackUrlsConfiguration.getString("voice[@url]"), callbackUrlsConfiguration.getString("voice[@method]"), false, callbackUrlsConfiguration.getString("sms[@url]"), callbackUrlsConfiguration.getString("sms[@method]"), callbackUrlsConfiguration.getString("fax[@url]"), callbackUrlsConfiguration.getString("fax[@method]"), callbackUrlsConfiguration.getString("ussd[@url]"), callbackUrlsConfiguration.getString("ussd[@method]")); final IncomingPhoneNumberConverter converter = new IncomingPhoneNumberConverter(configuration); listConverter = new IncomingPhoneNumberListConverter(configuration); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls(); builder.registerTypeAdapter(IncomingPhoneNumber.class, converter); builder.registerTypeAdapter(IncomingPhoneNumberList.class, listConverter); builder.setPrettyPrinting(); gson = builder.create(); xstream = new XStream(); xstream.alias("RestcommResponse", RestCommResponse.class); xstream.registerConverter(converter); xstream.registerConverter(listConverter); xstream.registerConverter(new AvailableCountriesConverter(configuration)); xstream.registerConverter(new RestCommResponseConverter(configuration)); }
From source file:org.restcomm.connect.http.NotificationsEndpoint.java
License:Open Source License
@PostConstruct public void init() { final DaoManager storage = (DaoManager) context.getAttribute(DaoManager.class.getName()); configuration = (Configuration) context.getAttribute(Configuration.class.getName()); configuration = configuration.subset("runtime-settings"); super.init(configuration); dao = storage.getNotificationsDao(); final NotificationConverter converter = new NotificationConverter(configuration); listConverter = new NotificationListConverter(configuration); final GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(Notification.class, converter); builder.registerTypeAdapter(NotificationList.class, listConverter); builder.setPrettyPrinting(); gson = builder.create();/*from w ww. j a va 2s . co m*/ xstream = new XStream(); xstream.alias("RestcommResponse", RestCommResponse.class); xstream.registerConverter(converter); xstream.registerConverter(new NotificationListConverter(configuration)); xstream.registerConverter(new RestCommResponseConverter(configuration)); xstream.registerConverter(listConverter); instanceId = RestcommConfiguration.getInstance().getMain().getInstanceId(); }
From source file:org.restcomm.connect.http.OrganizationsEndpoint.java
License:Open Source License
private void registerConverters() { final OrganizationConverter converter = new OrganizationConverter(configuration); listConverter = new OrganizationListConverter(configuration); final ClientConverter clientConverter = new ClientConverter(configuration); final ClientListConverter clientListConverter = new ClientListConverter(configuration); final GsonBuilder builder = new GsonBuilder(); builder.serializeNulls();/*from ww w . j av a 2 s . c o m*/ builder.registerTypeAdapter(Organization.class, converter); builder.registerTypeAdapter(Client.class, converter); builder.setPrettyPrinting(); gson = builder.create(); xstream = new XStream(); xstream.alias("RestcommResponse", RestCommResponse.class); xstream.registerConverter(converter); xstream.registerConverter(listConverter); xstream.registerConverter(clientConverter); xstream.registerConverter(clientListConverter); xstream.registerConverter(new RestCommResponseConverter(configuration)); }
From source file:org.restcomm.connect.http.OutgoingCallerIdsEndpoint.java
License:Open Source License
@PostConstruct public void init() { final DaoManager storage = (DaoManager) context.getAttribute(DaoManager.class.getName()); configuration = (Configuration) context.getAttribute(Configuration.class.getName()); configuration = configuration.subset("runtime-settings"); super.init(configuration); dao = storage.getOutgoingCallerIdsDao(); final OutgoingCallerIdConverter converter = new OutgoingCallerIdConverter(configuration); final GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(OutgoingCallerId.class, converter); builder.setPrettyPrinting(); gson = builder.create();/*from w w w. ja v a 2s . c o m*/ xstream = new XStream(); xstream.alias("RestcommResponse", RestCommResponse.class); xstream.registerConverter(converter); xstream.registerConverter(new OutgoingCallerIdListConverter(configuration)); xstream.registerConverter(new RestCommResponseConverter(configuration)); }
From source file:org.restcomm.connect.http.RecordingsEndpoint.java
License:Open Source License
@PostConstruct public void init() { final DaoManager storage = (DaoManager) context.getAttribute(DaoManager.class.getName()); configuration = (Configuration) context.getAttribute(Configuration.class.getName()); Configuration amazonS3Configuration = configuration.subset("amazon-s3"); configuration = configuration.subset("runtime-settings"); super.init(configuration); dao = storage.getRecordingsDao();/*from w w w . j av a 2 s.co m*/ final RecordingConverter converter = new RecordingConverter(configuration); listConverter = new RecordingListConverter(configuration); final GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(Recording.class, converter); builder.registerTypeAdapter(RecordingList.class, listConverter); builder.setPrettyPrinting(); gson = builder.create(); xstream = new XStream(); xstream.alias("RestcommResponse", RestCommResponse.class); xstream.registerConverter(converter); xstream.registerConverter(new RecordingListConverter(configuration)); xstream.registerConverter(new RestCommResponseConverter(configuration)); if (!amazonS3Configuration.isEmpty()) { // Do not fail with NPE is amazonS3Configuration is not present for older install boolean amazonS3Enabled = amazonS3Configuration.getBoolean("enabled"); if (amazonS3Enabled) { final String accessKey = amazonS3Configuration.getString("access-key"); final String securityKey = amazonS3Configuration.getString("security-key"); final String bucketName = amazonS3Configuration.getString("bucket-name"); final String bucketFolder = amazonS3Configuration.getString("folder"); final boolean reducedRedundancy = amazonS3Configuration.getBoolean("reduced-redundancy"); final int minutesToRetainPublicUrl = amazonS3Configuration.getInt("minutes-to-retain-public-url", 10); final boolean removeOriginalFile = amazonS3Configuration.getBoolean("remove-original-file"); final String bucketRegion = amazonS3Configuration.getString("bucket-region"); final boolean testing = amazonS3Configuration.getBoolean("testing", false); final String testingUrl = amazonS3Configuration.getString("testing-url", null); s3AccessTool = new S3AccessTool(accessKey, securityKey, bucketName, bucketFolder, reducedRedundancy, minutesToRetainPublicUrl, removeOriginalFile, bucketRegion, testing, testingUrl); securityLevel = RecordingSecurityLevel .valueOf(amazonS3Configuration.getString("security-level", "secure").toUpperCase()); converter.setSecurityLevel(securityLevel); } } xstream.registerConverter(listConverter); instanceId = RestcommConfiguration.getInstance().getMain().getInstanceId(); }
From source file:org.restcomm.connect.http.SmsMessagesEndpoint.java
License:Open Source License
@PostConstruct public void init() { final DaoManager storage = (DaoManager) context.getAttribute(DaoManager.class.getName()); configuration = (Configuration) context.getAttribute(Configuration.class.getName()); configuration = configuration.subset("runtime-settings"); dao = storage.getSmsMessagesDao();/*ww w . j ava2 s . co m*/ aggregator = (ActorRef) context.getAttribute("org.restcomm.connect.sms.SmsService"); system = (ActorSystem) context.getAttribute(ActorSystem.class.getName()); super.init(configuration); final SmsMessageConverter converter = new SmsMessageConverter(configuration); listConverter = new SmsMessageListConverter(configuration); final GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(SmsMessage.class, converter); builder.registerTypeAdapter(SmsMessageList.class, listConverter); builder.setPrettyPrinting(); gson = builder.create(); xstream = new XStream(); xstream.alias("RestcommResponse", RestCommResponse.class); xstream.registerConverter(converter); xstream.registerConverter(new SmsMessageListConverter(configuration)); xstream.registerConverter(new RestCommResponseConverter(configuration)); xstream.registerConverter(listConverter); instanceId = RestcommConfiguration.getInstance().getMain().getInstanceId(); normalizePhoneNumbers = configuration.getBoolean("normalize-numbers-for-outbound-calls"); }
From source file:org.restcomm.connect.http.TranscriptionsEndpoint.java
License:Open Source License
@PostConstruct public void init() { final DaoManager storage = (DaoManager) context.getAttribute(DaoManager.class.getName()); configuration = (Configuration) context.getAttribute(Configuration.class.getName()); configuration = configuration.subset("runtime-settings"); super.init(configuration); dao = storage.getTranscriptionsDao(); final TranscriptionConverter converter = new TranscriptionConverter(configuration); listConverter = new TranscriptionListConverter(configuration); final GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(Transcription.class, converter); builder.registerTypeAdapter(TranscriptionList.class, listConverter); builder.setPrettyPrinting(); gson = builder.create();//from w ww .j av a 2 s .com xstream = new XStream(); xstream.alias("RestcommResponse", RestCommResponse.class); xstream.registerConverter(converter); xstream.registerConverter(new TranscriptionListConverter(configuration)); xstream.registerConverter(new RestCommResponseConverter(configuration)); xstream.registerConverter(listConverter); instanceId = RestcommConfiguration.getInstance().getMain().getInstanceId(); }
From source file:org.restcomm.connect.http.UsageEndpoint.java
License:Open Source License
@PostConstruct public void init() { final DaoManager storage = (DaoManager) context.getAttribute(DaoManager.class.getName()); configuration = (Configuration) context.getAttribute(Configuration.class.getName()); configuration = configuration.subset("runtime-settings"); super.init(configuration); dao = storage.getUsageDao();// w ww. jav a 2 s .co m final UsageConverter converter = new UsageConverter(configuration); final GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(Usage.class, converter); builder.setPrettyPrinting(); gson = builder.disableHtmlEscaping().create(); xstream = new XStream(); xstream.alias("RestcommResponse", RestCommResponse.class); xstream.registerConverter(converter); xstream.registerConverter(new UsageListConverter(configuration)); xstream.registerConverter(new RestCommResponseConverter(configuration)); }
From source file:org.restcomm.sbc.rest.AccountsEndpoint.java
License:Open Source License
@PostConstruct private void init() { configuration = (Configuration) context.getAttribute(Configuration.class.getName()); configuration = configuration.subset("runtime-settings"); super.init(configuration); final AccountConverter converter = new AccountConverter(configuration); final GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(Account.class, converter); builder.setPrettyPrinting(); gson = builder.create();/*from w w w. j a va 2s .co m*/ xstream = new XStream(); xstream.alias("RestcommResponse", RestCommResponse.class); xstream.registerConverter(converter); xstream.registerConverter(new AccountListConverter(configuration)); xstream.registerConverter(new RestCommResponseConverter(configuration)); // Make sure there is an authenticated account present when this endpoint is used checkAuthenticatedAccount(); }
From source file:org.restcomm.sbc.rest.UsageEndpoint.java
License:Open Source License
@PostConstruct public void init() { final DaoManager storage = (DaoManager) context.getAttribute(DaoManager.class.getName()); configuration = (Configuration) context.getAttribute(Configuration.class.getName()); configuration = configuration.subset("runtime-settings"); super.init(configuration); dao = storage.getUsageDao();//from w w w .j a v a 2 s .c o m final UsageConverter converter = new UsageConverter(configuration); final GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(Usage.class, converter); builder.setPrettyPrinting(); gson = builder.create(); xstream = new XStream(); xstream.alias("RestcommResponse", RestCommResponse.class); xstream.registerConverter(converter); xstream.registerConverter(new UsageListConverter(configuration)); xstream.registerConverter(new RestCommResponseConverter(configuration)); }