List of usage examples for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE
ToStringStyle MULTI_LINE_STYLE
To view the source code for org.apache.commons.lang.builder ToStringStyle MULTI_LINE_STYLE.
Click Source Link
From source file:com.gemini.provision.security.openstack.SecurityProviderOpenStackImpl.java
@Override public ProvisioningProviderResponseType deleteSecurityGroup(GeminiTenant tenant, GeminiEnvironment env, GeminiSecurityGroup securityGroup) { //authenticate the session with the OpenStack installation OSClient os = OSFactory.builder().endpoint(env.getEndPoint()) .credentials(env.getAdminUserName(), env.getAdminPassword()).tenantName(tenant.getName()) .authenticate();/*w w w. ja v a 2s. c o m*/ if (os == null) { Logger.error("Failed to authenticate Tenant: {}", ToStringBuilder.reflectionToString(tenant, ToStringStyle.MULTI_LINE_STYLE)); return ProvisioningProviderResponseType.CLOUD_AUTH_FAILURE; } SecurityGroup osSecGrp; try { osSecGrp = os.networking().securitygroup().get(securityGroup.getCloudID()); } catch (NullPointerException | ClientResponseException ex) { Logger.error( "Could not retrieve security group information in OpenStack. tenant: {} env: {} security group: {}", tenant.getName(), env.getName(), securityGroup.getName()); return ProvisioningProviderResponseType.CLOUD_EXCEPTION; } if (osSecGrp == null) { Logger.error("Security Group does not exist: tenant: {} env: {} security group: {}", tenant.getName(), env.getName(), securityGroup.getName()); return ProvisioningProviderResponseType.OBJECT_NOT_FOUND; } //looks like there no way to update a security group, we have to delete and re-create ActionResponse a = os.networking().securitygroup().delete(osSecGrp.getId()); if (!a.isSuccess()) { Logger.error( "Security Group update - could not delete the security group: tenant: {} env: {} security group: {} Error Message: {}", tenant.getName(), env.getName(), securityGroup.getName(), a.getFault()); return ProvisioningProviderResponseType.CLOUD_FAILURE; } //remove this security group from the environment env.deleteSecurityGroup(securityGroup); //now remove the deleted security group's name from the servers that use the deleted security group // env.getApplications() // .stream() // .map(GeminiApplication::getNetworks) // .flatMap(List::stream) // .map(GeminiNetwork::getSubnets) // .flatMap(List::stream) // .map(GeminiSubnet::getAllocationPools) // .flatMap(List::stream) // .map(GeminiSubnetAllocationPool::getServers) // .flatMap(List::stream) // .forEach(s -> s.deleteSecGroupName(securityGroup.getName())); Logger.debug("Successfully deleted security group Tenant: {} Env: {} security group {}", tenant.getName(), env.getName(), securityGroup.getName()); return ProvisioningProviderResponseType.SUCCESS; }
From source file:com.opengamma.engine.view.ViewDefinition.java
@Override public String toString() { if (s_logger.isDebugEnabled()) { return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE, false); } else {//from w ww . j av a 2 s .c o m return "ViewDefinition[" + getName() + "]"; } }
From source file:net.jenet.Host.java
@Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("address", address) .append("peers", peers).toString(); }
From source file:com.jaxio.celerio.model.Attribute.java
@Override public String toString() { return getName() + " " + ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); }
From source file:jext2.DataBlockAccess.java
@Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) .append("lastAllocLogicalBlock", lastAllocLogicalBlock) .append("lastAllocPhysicalBlock", lastAllocPhysicalBlock).append("hierarchyLock", hierarchyLock) .toString();//from www . j a v a 2 s .co m }
From source file:com.gemini.provision.network.openstack.NetworkProviderOpenStackImpl.java
@Override public ProvisioningProviderResponseType updateSubnet(GeminiTenant tenant, GeminiEnvironment env, GeminiSubnet subnet) {/*from w w w .j a v a 2 s . c om*/ //authenticate the session with the OpenStack installation OSClient os = OSFactory.builder().endpoint(env.getEndPoint()) .credentials(env.getAdminUserName(), env.getAdminPassword()).tenantName(tenant.getName()) .authenticate(); if (os == null) { Logger.error("Failed to authenticate Tenant: {}", ToStringBuilder.reflectionToString(tenant, ToStringStyle.MULTI_LINE_STYLE)); return null; } // Get a subnet by ID Subnet s = os.networking().subnet().get(subnet.getCloudID()); if (s == null) { Logger.error("Failed to update subnet - doesn't exist. Tenant: {} Environment: {} Sbunet: {}", tenant.getName(), env.getName(), ToStringBuilder.reflectionToString(subnet, ToStringStyle.MULTI_LINE_STYLE)); return ProvisioningProviderResponseType.OBJECT_NOT_FOUND; } //update the subnet Subnet updatedSubnet; try { updatedSubnet = os.networking().subnet().update(s.toBuilder().tenantId(tenant.getTenantID()) .cidr(subnet.getCidr()).name(subnet.getName()) .gateway(InetAddresses.toAddrString(subnet.getGateway())) .networkId(subnet.getParent().getCloudID()).enableDHCP(subnet.isEnableDHCP()) .ipVersion(subnet.getNetworkType() == IPAddressType.IPv6 ? IPVersionType.V6 : IPVersionType.V4) .build()); } catch (ClientResponseException ex) { Logger.error("Cloud exception: status code {}", ex.getStatusCode()); return ProvisioningProviderResponseType.CLOUD_EXCEPTION; } //TODO: Need to get detailed error codes for the call above. Research the StatusCode class if (updatedSubnet == null) { Logger.error( "Failed to update subnet, Cloud provider failure. Tenant: {} Environment: {} Parent Network: {} Subnet: {} ", tenant.getName(), env.getName(), subnet.getParent().getName(), subnet.getName()); return ProvisioningProviderResponseType.CLOUD_FAILURE; } //add the list of subnets (this will be an update the subnet just created) List<GeminiSubnetAllocationPool> pools = subnet.getAllocationPools(); pools.stream().forEach(p -> { if (os.networking().subnet().update(updatedSubnet.toBuilder() .addPool(p.getStart().getHostAddress(), p.getEnd().getHostAddress()).build()) == null) { Logger.error( "Failed to create subnet allocation pool, Tenant: {} Environment: {} Parent Network: {} Subnet: {} Allocation Pool {} {}", tenant.getName(), env.getName(), subnet.getParent().getName(), subnet.getName(), p.getStart().getHostAddress(), p.getEnd().getHostAddress()); } }); Logger.debug("Successfully updated the subnet. Tenant: {} Environment: {} Parent Network: {} Subnet: {}", tenant.getName(), env.getName(), subnet.getParent().getName(), subnet.getName()); return ProvisioningProviderResponseType.SUCCESS; }
From source file:com.gemini.provision.security.openstack.SecurityProviderOpenStackImpl.java
/** * Get the security group rule details based on the cloud id provided in the * securityRule object./*from w ww.j a va2 s.c om*/ * * @param tenant * @param env * @param securityGroup - the parent security group * @param securityRule - the rule whose information needs to be retrieved, * the cloud ID must be provided. * @return SUCCESS - if all goes well AUTH_FAILURE - if the authentication * failed with the information in the tenant object EXCEPTION - if the cloud * raised an exception OBJECT_NOT_FOUND - if the rule with ID provided is * not found */ @Override public ProvisioningProviderResponseType getSecurityGroupRule(GeminiTenant tenant, GeminiEnvironment env, GeminiSecurityGroup securityGroup, GeminiSecurityGroupRule securityRule) { //authenticate the session with the OpenStack installation OSClient os = OSFactory.builder().endpoint(env.getEndPoint()) .credentials(env.getAdminUserName(), env.getAdminPassword()).tenantName(tenant.getName()) .authenticate(); if (os == null) { Logger.error("Failed to authenticate Tenant: {}", ToStringBuilder.reflectionToString(tenant, ToStringStyle.MULTI_LINE_STYLE)); return ProvisioningProviderResponseType.CLOUD_AUTH_FAILURE; } SecurityGroupRule osSecGrpRule; try { osSecGrpRule = os.networking().securityrule().get(securityRule.getCloudID()); } catch (NullPointerException | ClientResponseException ex) { Logger.error( "Cloud Exception: Could not retrieve security group rule information in OpenStack. tenant: {} env: {} security group: {} security rule ID: {}", tenant.getName(), env.getName(), securityGroup.getName(), securityRule.getCloudID()); return ProvisioningProviderResponseType.CLOUD_EXCEPTION; } if (osSecGrpRule == null) { Logger.error( "Security rule not found: Could not find security group rule information in OpenStack. tenant: {} env: {} security group: {} security rule ID: {}", tenant.getName(), env.getName(), securityGroup.getName(), securityRule.getCloudID()); return ProvisioningProviderResponseType.OBJECT_NOT_FOUND; } //now copy the information into the gemini security rule object securityRule.setProvisioned(true); securityRule .setDirection(GeminiSecurityGroupRuleDirection.valueOf(osSecGrpRule.getDirection().toUpperCase())); securityRule.setIpAddressType(IPAddressType.valueOf(osSecGrpRule.getEtherType())); securityRule.setParent(securityGroup); securityRule.setPortRangeMin(osSecGrpRule.getPortRangeMin()); securityRule.setPortRangeMax(osSecGrpRule.getPortRangeMax()); securityRule.setProtocol(Protocol.valueOf(osSecGrpRule.getProtocol())); securityRule.setRemoteGroupId(osSecGrpRule.getRemoteGroupId()); securityRule.setRemoteIpPrefix(osSecGrpRule.getRemoteIpPrefix()); Logger.debug( "Successfully retrieved security groups rule Tenant: {} Env: {} security group {} security rule {}", tenant.getName(), env.getName(), securityGroup.getName(), securityRule.getName()); return ProvisioningProviderResponseType.SUCCESS; }
From source file:com.ah.be.admin.restoredb.AhRestoreDBImpl.java
public static void getVhmEmails() { // only needed for HMOL and single VHM move/upgrade, fix bug 32249 /*/* w w w . ja v a2s . c o m*/ * before restore user customization settings, check if need to retrieve VHM user emails from Portal * customization settings include data in below 4 tables: * hm_table_column_new * hm_table_size_new * hm_autorefresh_settings_new * hm_user_settings */ // get VHM BO HmDomain domain = AhRestoreNewMapTools.getHmDomainMap().isEmpty() ? null : (AhRestoreNewMapTools.getHmDomainMap().values()).iterator().next(); if (domain != null) { String vhmId = domain.getVhmID(); VHMCustomerInfo vhminfo = getVhmInfos(vhmId); AhRestoreDBTools.logRestoreMsg("Retrieve VHM (" + vhmId + ") info from Portal " + (vhminfo == null ? "failed." : "suceed.") + " (first time retrieval)"); // 3 times retry for (int i = 0; vhminfo == null && i < 3; i++) { vhminfo = getVhmInfos(vhmId); AhRestoreDBTools.logRestoreMsg("Retrieve VHM (" + vhmId + ") info from Portal " + (vhminfo == null ? "failed." : "suceed.") + "(retry retrieval, times:" + (i + 1) + ")"); } AhRestoreDBTools.logRestoreMsg( "VHM info : " + ToStringBuilder.reflectionToString(vhminfo, ToStringStyle.MULTI_LINE_STYLE)); if (vhminfo != null) { // if VHM got CID, use user get from Portal as filter if (!StringUtils.isEmpty(vhminfo.getCustomerId())) { // clear user email AhRestoreNewMapTools.clearVhmEmails(); AhRestoreNewMapTools.addVhmEmails(vhminfo.getPrimaryUsers()); AhRestoreNewMapTools.addVhmEmails(vhminfo.getNonPrimaryUsers()); } else { // got no CID, use email list saved when restore hm_user on HMOL } } else { // make sure restore all customization settings, clear email list saved when restore hm_user AhRestoreNewMapTools.clearVhmEmails(); AhRestoreDBTools.logRestoreErrorMsg("Retrieve VHM (" + vhmId + ") info from Portal failed after 3 times retry. Restore all customization settings from source HMOL."); } } else { // make sure restore all customization settings, clear email list saved when restore hm_user AhRestoreNewMapTools.clearVhmEmails(); AhRestoreDBTools.logRestoreErrorMsg( "Cannot start Retrieving VHM info from Portal due to get VHM record from HMOL DB failed. Restore all customization settings from source HMOL."); } }
From source file:com.likethecolor.alchemy.api.entity.ConceptAlchemyEntityTest.java
@Test public void testToString_Formatted() { final ToStringStyle style = ToStringStyle.MULTI_LINE_STYLE; final String census = "http://census.org/resource/Israel"; final String ciaFactbook = "http://www4.wiwiss.fu-berlin.de/factbook/resource/Israel"; final String concept = "Country"; final String crunchbase = "http://crunchbase.com/resource/Israel"; final String dbPedia = "http://dbpedia.org/resource/Israel"; final String freebase = "http://rdf.freebase.com/ns/guid.9202a8c04000641f800000000001e2be"; final Double latitude = 31.0D; final Double longitude = 35.0D; final String geo = latitude + " " + longitude; final String geonames = "http://geonames.com/Israel"; final String musicBrainz = "http://musicbrainz.com/Israel"; final String opencyc = "http://sw.opencyc.org/concept/Mx4rvViP55wpEbGdrcN5Y29ycA"; final Double score = 0.294534D; final String semanticCrunchbase = "http://semanticcrunchbase.com/concept/Mx4rvViP55wpEbGdrcN5Y29ycA"; final String website = "http://www.knesset.gov.il/"; final String yago = "http://mpii.de/yago/resource/Israel"; final ConceptAlchemyEntity entity = new ConceptAlchemyEntity(concept, score); entity.setCensus(census);//from ww w . ja va2 s .co m entity.setCIAFactbook(ciaFactbook); entity.setCrunchbase(crunchbase); entity.setDBPedia(dbPedia); entity.setFreebase(freebase); entity.setGeo(geo); entity.setGeonames(geonames); entity.setMusicBrainz(musicBrainz); entity.setOpencyc(opencyc); entity.setSemanticCrunchbase(semanticCrunchbase); entity.setWebsite(website); entity.setYago(yago); final String expectedString = new ToStringBuilder(entity, style).append("census", census) .append("cia factbook", ciaFactbook).append("concept", concept).append("crunchbase", crunchbase) .append("dbpedia", dbPedia).append("freebase", freebase).append("geo", geo) .append("geonames", geonames).append("latitude", latitude).append("longitude", longitude) .append("music brainz", musicBrainz).append("opencyc", opencyc).append("score", score) .append("semantic crunchbase", semanticCrunchbase).append("website", website).append("yago", yago) .toString(); final String actualString = entity.toString(style); assertEquals(expectedString, actualString); }
From source file:com.gemini.provision.network.openstack.NetworkProviderOpenStackImpl.java
@Override public ProvisioningProviderResponseType deleteSubnet(GeminiTenant tenant, GeminiEnvironment env, GeminiSubnet subnet) {/*from ww w .j ava2 s . c o m*/ //authenticate the session with the OpenStack installation OSClient os = OSFactory.builder().endpoint(env.getEndPoint()) .credentials(env.getAdminUserName(), env.getAdminPassword()).tenantName(tenant.getName()) .authenticate(); if (os == null) { Logger.error("Failed to authenticate Tenant: {}", ToStringBuilder.reflectionToString(tenant, ToStringStyle.MULTI_LINE_STYLE)); return null; } // Get a subnet by ID Subnet s = os.networking().subnet().get(subnet.getCloudID()); if (s == null) { Logger.error("Failed to delete network - does not exist. Tenant: {} Environment: {} Network: {}", tenant.getName(), env.getName(), ToStringBuilder.reflectionToString(subnet, ToStringStyle.MULTI_LINE_STYLE)); return ProvisioningProviderResponseType.OBJECT_NOT_FOUND; } if (os.networking().subnet().delete(subnet.getCloudID()).isSuccess()) { Logger.debug("Successfully deleted network - Tenant: {} Environment: {} Network: {}", tenant.getName(), env.getName(), ToStringBuilder.reflectionToString(subnet, ToStringStyle.MULTI_LINE_STYLE)); return ProvisioningProviderResponseType.SUCCESS; } else { Logger.error( "Failed to delete network, cloud provider failure - Tenant: {} Environment: {} Network: {}", tenant.getName(), env.getName(), ToStringBuilder.reflectionToString(subnet, ToStringStyle.MULTI_LINE_STYLE)); return ProvisioningProviderResponseType.CLOUD_FAILURE; } }