org.apache.commons.lang.builder.ReflectionToStringBuilder Java Examples

The following examples show how to use org.apache.commons.lang.builder.ReflectionToStringBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BusinessObjectBase.java    From rice with Educational Community License v2.0 6 votes vote down vote up
@Override
public String toString() {
       class BusinessObjectToStringBuilder extends ReflectionToStringBuilder {

           private BusinessObjectToStringBuilder(Object object) {
               super(object);
           }

           @Override
           public boolean accept(Field field) {
               return String.class.isAssignableFrom(field.getType())
                       || ClassUtils.isPrimitiveOrWrapper(field.getType());
           }

       }

       return new BusinessObjectToStringBuilder(this).toString();
   }
 
Example #2
Source File: AbstractPipe.java    From iaf with Apache License 2.0 6 votes vote down vote up
/**
 * The <code>toString()</code> method retrieves its value
 * by reflection, so overriding this method is mostly not
 * usefull.
 * @see ToStringBuilder#reflectionToString
 *
 **/
@Override
public String toString() {
	try {
		return (new ReflectionToStringBuilder(this) {
			@Override
			protected boolean accept(Field f) {
				//TODO create a blacklist or whitelist
				return super.accept(f) && !f.getName().contains("appConstants");
			}
		}).toString();
	} catch (Throwable t) {
		log.warn("exception getting string representation of pipe ["+getName()+"]", t);
	}
	return null;
}
 
Example #3
Source File: PrintUtility.java    From datawave with Apache License 2.0 6 votes vote down vote up
public static String getPrintableValue(final Value value) {
    if ((value != null) && (value.getSize() > 0)) {
        try {
            final Uid.List uidList = Uid.List.parseFrom(value.get());
            
            return (uidList.getUIDList().toString());
        } catch (final InvalidProtocolBufferException e1) {
            try {
                return (ReflectionToStringBuilder.toString(EdgeValue.decode(value), ToStringStyle.SHORT_PREFIX_STYLE));
            } catch (final Exception e2) {
                try {
                    final ExtendedHyperLogLogPlus ehllp = new ExtendedHyperLogLogPlus(value);
                    
                    return (String.valueOf(ehllp.getCardinality()));
                } catch (final Exception e3) {
                    logger.error("Could not deserialize protobuff" + e2);
                }
            }
        }
    }
    
    return ("");
}
 
Example #4
Source File: PuppetClient.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
protected CommandResult execute(List<String> commands) {
    if (log.isDebugEnabled()) {
        log.debug(commands);
    }

    // タイムアウトしないようにする
    long timeout = Long.MAX_VALUE;

    CommandResult result = CommandUtils.execute(commands, timeout);

    if (log.isDebugEnabled()) {
        log.debug(ReflectionToStringBuilder.toString(result));
    }

    return result;
}
 
Example #5
Source File: DnsStrategy.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void addCanonicalName(String fqdn, String canonicalName) {
    List<String> commands = createCommands();
    List<String> stdins = createAddCanonicalName(fqdn, canonicalName);

    CommandResult result = execute(commands, stdins);

    if (result.getExitValue() != 0) {
        // CNAMEレコードの追加に失敗
        AutoException exception = new AutoException("ECOMMON-000205", fqdn, canonicalName);
        exception.addDetailInfo(
                "result=" + ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));
        throw exception;
    }

    // CNAMEの確認はしない(参照先ホスト名を解決できない場合もあるため)
}
 
Example #6
Source File: NiftyProcessClient.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
public InstanceDto waitInstance(String instanceId) {
    // インスタンスの処理待ち
    String[] stableStatus = new String[] { "running", "stopped" };
    // TODO: ニフティクラウドAPIの経過観察(インスタンスのステータス warning はAPIリファレンスに記載されていない)
    String[] unstableStatus = new String[] { "pending", "warning" };//

    InstanceDto instance;
    while (true) {
        instance = describeInstance(instanceId);
        String status = instance.getState().getName();

        if (ArrayUtils.contains(stableStatus, status)) {
            break;
        }

        if (!ArrayUtils.contains(unstableStatus, status)) {
            // 予期しないステータス
            AutoException exception = new AutoException("EPROCESS-000604", instanceId, status);
            exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(instance));
            throw exception;
        }
    }

    return instance;
}
 
Example #7
Source File: NiftyProcessClient.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
protected VolumeDto waitVolume(String volumeId) {
    // Volumeの処理待ち
    String[] stableStatus = new String[] { "available", "in-use" };
    String[] unstableStatus = new String[] { "creating" };
    VolumeDto volume = null;
    while (true) {
        volume = describeVolume(volumeId);
        String status;
        status = volume.getStatus();

        if (ArrayUtils.contains(stableStatus, status)) {
            break;
        }

        if (!ArrayUtils.contains(unstableStatus, status)) {
            // 予期しないステータス
            AutoException exception = new AutoException("EPROCESS-000620", volumeId, status);
            exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(volume));
            throw exception;
        }
    }

    return volume;
}
 
Example #8
Source File: ImportedExpensePendingEntryServiceImpl.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @see org.kuali.kfs.module.tem.batch.service.ImportedExpensePendingEntryService#buildDebitPendingEntry(org.kuali.kfs.module.tem.businessobject.AgencyStagingData, org.kuali.kfs.module.tem.businessobject.TripAccountingInformation, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper, java.lang.String, org.kuali.rice.kns.util.KualiDecimal, boolean)
 */
@Override
public List<GeneralLedgerPendingEntry> buildDebitPendingEntry(AgencyStagingData agencyData, TripAccountingInformation info, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, String objectCode, KualiDecimal amount, boolean generateOffset){

    List<GeneralLedgerPendingEntry> entryList = new ArrayList<GeneralLedgerPendingEntry>();

    GeneralLedgerPendingEntry pendingEntry = buildGeneralLedgerPendingEntry(agencyData, info, sequenceHelper, info.getTripChartCode(), objectCode, amount, KFSConstants.GL_DEBIT_CODE);
    if(ObjectUtils.isNotNull(pendingEntry )) {
        pendingEntry.setAccountNumber(info.getTripAccountNumber());
        pendingEntry.setSubAccountNumber(StringUtils.defaultIfEmpty(info.getTripSubAccountNumber(), GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber()));

        LOG.info("Created DEBIT GLPE: " + pendingEntry.getDocumentNumber() + " for AGENCY Import Expense: " + agencyData.getId() + " TripId: " + agencyData.getTripId()
            + "\n\n" + ReflectionToStringBuilder.reflectionToString(pendingEntry, ToStringStyle.MULTI_LINE_STYLE));

        //add to list if entry was created successfully
        entryList.add(pendingEntry);
        //handling offset
        if (generateOffset){
            generateOffsetPendingEntry(entryList, sequenceHelper, pendingEntry);
        }
    }
    return entryList;
}
 
Example #9
Source File: ImportedExpensePendingEntryServiceImpl.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @see org.kuali.kfs.module.tem.batch.service.ImportedExpensePendingEntryService#buildCreditPendingEntry(org.kuali.kfs.module.tem.businessobject.AgencyStagingData, org.kuali.kfs.module.tem.businessobject.TripAccountingInformation, org.kuali.kfs.sys.businessobject.GeneralLedgerPendingEntrySequenceHelper, java.lang.String, org.kuali.rice.kns.util.KualiDecimal, boolean)
 */
@Override
public List<GeneralLedgerPendingEntry> buildServiceFeeCreditPendingEntry(AgencyStagingData agencyData, TripAccountingInformation info, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, AgencyServiceFee serviceFee, KualiDecimal amount, boolean generateOffset){
    List<GeneralLedgerPendingEntry> entryList = new ArrayList<GeneralLedgerPendingEntry>();

    GeneralLedgerPendingEntry pendingEntry = buildGeneralLedgerPendingEntry(agencyData, info, sequenceHelper, serviceFee.getCreditChartCode(), serviceFee.getCreditObjectCode(), amount, KFSConstants.GL_CREDIT_CODE);
    if(ObjectUtils.isNotNull(pendingEntry )) {
        pendingEntry.setAccountNumber(serviceFee.getCreditAccountNumber());
        pendingEntry.setSubAccountNumber(GENERAL_LEDGER_PENDING_ENTRY_CODE.getBlankSubAccountNumber());
    }

    LOG.info("Created ServiceFee CREDIT GLPE: " + pendingEntry.getDocumentNumber() + " for AGENCY Import Expense: " + agencyData.getId() + " TripId: " + agencyData.getTripId()
            + "\n\n" + ReflectionToStringBuilder.reflectionToString(pendingEntry, ToStringStyle.MULTI_LINE_STYLE));

    //add to list if entry was created successfully
    if (ObjectUtils.isNotNull(pendingEntry)) {
        entryList.add(pendingEntry);
        //handling offset
        if (generateOffset){
            generateOffsetPendingEntry(entryList, sequenceHelper, pendingEntry);
        }
    }
    return entryList;
}
 
Example #10
Source File: VendorTaxChange.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public String toString() {
    class VendorTaxChangeToStringBuilder extends ReflectionToStringBuilder {
        private VendorTaxChangeToStringBuilder(Object object) {
            super(object);
        }

        @Override
        public boolean accept(Field field) {
            if (BusinessObject.class.isAssignableFrom(field.getType())) {
                return false;
            }

            DataDictionaryService dataDictionaryService = SpringContext.getBean(DataDictionaryService.class);
            AttributeSecurity attributeSecurity = dataDictionaryService.getAttributeSecurity(VendorTaxChange.class.getName(), field.getName());
            if (ObjectUtils.isNotNull(attributeSecurity)
                            && (attributeSecurity.isHide() || attributeSecurity.isMask() || attributeSecurity.isPartialMask())) {
                return false;
            }

            return super.accept(field);
        }
    };
    ReflectionToStringBuilder toStringBuilder = new VendorTaxChangeToStringBuilder(this);
    return toStringBuilder.toString();
}
 
Example #11
Source File: VendorHeader.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public String toString() {
    class VendorHeaderToStringBuilder extends ReflectionToStringBuilder {
        private VendorHeaderToStringBuilder(Object object) {
            super(object);
        }

        @Override
        public boolean accept(Field field) {
            if (BusinessObject.class.isAssignableFrom(field.getType())) {
                return false;
            }

            DataDictionaryService dataDictionaryService = SpringContext.getBean(DataDictionaryService.class);
            AttributeSecurity attributeSecurity = dataDictionaryService.getAttributeSecurity(VendorHeader.class.getName(), field.getName());
            if (ObjectUtils.isNotNull(attributeSecurity)
                            && (attributeSecurity.isHide() || attributeSecurity.isMask() || attributeSecurity.isPartialMask())) {
                return false;
            }

            return super.accept(field);
        }
    };
    ReflectionToStringBuilder toStringBuilder = new VendorHeaderToStringBuilder(this);
    return toStringBuilder.toString();
}
 
Example #12
Source File: DataObjectBase.java    From rice with Educational Community License v2.0 6 votes vote down vote up
@Override
public String toString() {
    class DataObjectToStringBuilder extends ReflectionToStringBuilder {
        private DataObjectToStringBuilder(Object object) {
            super(object);
        }

        @Override
        public boolean accept(Field field) {
            if (field.getType().isPrimitive()
                    || field.getType().isEnum()
                    || java.lang.String.class.isAssignableFrom(field.getType())
                    || java.lang.Number.class.isAssignableFrom(field.getType())
                    || java.util.Collection.class.isAssignableFrom(field.getType())) {
                return super.accept(field);
            }
            return false;
        }
    };
    return new DataObjectToStringBuilder(this).toString();
}
 
Example #13
Source File: Application.java    From chassis with Apache License 2.0 5 votes vote down vote up
public Application(Arguments arguments) {
    Preconditions.checkNotNull(arguments);
    this.arguments = arguments;

    logger.debug("Creating Application with arguments {}", ReflectionToStringBuilder.toString(arguments));

    createApplicationContext();
}
 
Example #14
Source File: PayeeACHAccount.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * KFSCNTRB-1682: Some of the fields contain confidential information
 * @see org.kuali.rice.krad.bo.BusinessObjectBase#toString()
 */
@Override
public String toString() {
    class PayeeACHAccountToStringBuilder extends ReflectionToStringBuilder {
        private PayeeACHAccountToStringBuilder(Object object) {
            super(object);
        }

        @Override
        public boolean accept(Field field) {
            if (BusinessObject.class.isAssignableFrom(field.getType())) {
                return false;
            }

            DataDictionaryService dataDictionaryService = SpringContext.getBean(DataDictionaryService.class);
            AttributeSecurity attributeSecurity = dataDictionaryService.getAttributeSecurity(PayeeACHAccount.class.getName(), field.getName());
            if ((ObjectUtils.isNotNull(attributeSecurity)
                    && (attributeSecurity.isHide() || attributeSecurity.isMask() || attributeSecurity.isPartialMask()))) {
                return false;
            }

            return super.accept(field);
        }
    };
    ReflectionToStringBuilder toStringBuilder = new PayeeACHAccountToStringBuilder(this);
    return toStringBuilder.toString();
}
 
Example #15
Source File: ImportedExpensePendingEntryServiceImpl.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Generate the offset entry from the given pending entry.  If entry is created successfully, add to the entry list
 *
 * @param entryList
 * @param sequenceHelper
 * @param pendingEntry
 */
private void generateOffsetPendingEntry(List<GeneralLedgerPendingEntry> entryList, GeneralLedgerPendingEntrySequenceHelper sequenceHelper, GeneralLedgerPendingEntry pendingEntry){
    GeneralLedgerPendingEntry offsetEntry = new GeneralLedgerPendingEntry(pendingEntry);
    boolean success = generalLedgerPendingEntryService.populateOffsetGeneralLedgerPendingEntry(universityDateService.getCurrentFiscalYear(), pendingEntry, sequenceHelper, offsetEntry);
    sequenceHelper.increment();
    if (success){
        LOG.info("Created OFFSET GLPE: " + pendingEntry.getDocumentNumber() + "\n" + ReflectionToStringBuilder.reflectionToString(pendingEntry, ToStringStyle.MULTI_LINE_STYLE));
        entryList.add(offsetEntry);
    }
}
 
Example #16
Source File: DnsStrategy.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void deleteReverse(String ipAddress) {
    List<String> commands = createCommands();
    List<String> stdins = createDeleteReverse(ipAddress);

    CommandResult result = execute(commands, stdins);

    if (result.getExitValue() != 0) {
        // 逆引きレコードの削除に失敗
        AutoException exception = new AutoException("ECOMMON-000209", ipAddress);
        exception.addDetailInfo(
                "result=" + ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));
        throw exception;
    }

    // 逆引きの確認
    long timeout = 10000L;
    long startTime = System.currentTimeMillis();
    while (true) {
        String hostName = getHostName(ipAddress);
        if (StringUtils.equals(ipAddress, hostName)) {
            break;
        }
        if (System.currentTimeMillis() - startTime > timeout) {
            // タイムアウト発生時
            throw new AutoException("ECOMMON-000210", ipAddress, hostName);
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ignore) {
        }
    }
}
 
Example #17
Source File: ConfigXml.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Replaces field values with annotation {@link ConfigXmlSecretField} by "******".
 * @param configObject
 * @return String representation of the given object.
 * @see ReflectionToStringBuilder#ReflectionToStringBuilder(Object)
 */
public static String toString(final Object configObject)
{
  return new ReflectionToStringBuilder(configObject) {
    @Override
    protected Object getValue(final Field field) throws IllegalArgumentException, IllegalAccessException
    {
      if (field.isAnnotationPresent(ConfigXmlSecretField.class) == true) {
        return SECRET_PROPERTY_STRING;
      }
      return super.getValue(field);
    };
  }.toString();
}
 
Example #18
Source File: DnsStrategy.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void addForward(String fqdn, String ipAddress) {
    List<String> commands = createCommands();
    List<String> stdins = createAddForward(fqdn, ipAddress);

    CommandResult result = execute(commands, stdins);

    if (result.getExitValue() != 0) {
        // 正引きレコードの追加に失敗
        AutoException exception = new AutoException("ECOMMON-000201", fqdn, ipAddress);
        exception.addDetailInfo(
                "result=" + ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));
        throw exception;
    }

    // 正引きの確認
    long timeout = 10000L;
    long startTime = System.currentTimeMillis();
    while (true) {
        String hostAddress = getHostAddress(fqdn);
        if (StringUtils.equals(ipAddress, hostAddress)) {
            break;
        }
        if (System.currentTimeMillis() - startTime > timeout) {
            // タイムアウト発生時
            throw new AutoException("ECOMMON-000202", fqdn, ipAddress, hostAddress);
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ignore) {
        }
    }
}
 
Example #19
Source File: DumpFilter.java    From spacewalk with GNU General Public License v2.0 5 votes vote down vote up
private void logAttributes(HttpServletRequest req) {
    Enumeration items = req.getAttributeNames();
    while (items.hasMoreElements()) {
        String name = (String) items.nextElement();
        Object obj = req.getAttribute(name);
        if (obj != null) {
            log.debug("Attribute: name [" + name + "] value [" +
                ReflectionToStringBuilder.toString(obj) + "]");
        }
        else {
            log.debug("Attribute: name [" + name + "] value [null]");
        }
    }
}
 
Example #20
Source File: NiftyProcessClient.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
public VolumeDto waitDetachVolume(String volumeId, String instanceId) {
    // TODO: ニフティクラウドAPIの経過観察(アタッチ情報がすぐに更新されない問題に暫定的に対応)
    VolumeDto volume = null;
    long timeout = 600 * 1000L;
    long startTime = System.currentTimeMillis();
    while (true) {
        volume = waitVolume(volumeId);
        if ("available".equals(volume.getStatus())) {
            break;
        }
        if (System.currentTimeMillis() - startTime > timeout) {
            // タイムアウト発生時、デタッチにに失敗したものとする
            throw new AutoException("EPROCESS-000625", instanceId, volumeId, volume.getStatus());
        }
    }

    if (!"available".equals(volume.getStatus())) {
        // デタッチ失敗時
        AutoException exception = new AutoException("EPROCESS-000625", instanceId, volumeId, volume.getStatus());
        exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(volume));
        throw exception;
    }

    // ログ出力
    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100526", volumeId, instanceId));
    }

    return volume;
}
 
Example #21
Source File: ReportAnalyzerTest.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
@Test
@Ignore
public void testGetMetricsResources() {
    Map<String, Object> report = reportLoader.loadReport("test", "test.yaml");
    List<MetricsResource> metricsResources = reportAnalyzer.getMetricsResources(report);

    for (MetricsResource metricsResource : metricsResources) {
        log.trace(ReflectionToStringBuilder.toString(metricsResource, ToStringStyle.SHORT_PREFIX_STYLE));
    }

    assertEquals(8, metricsResources.size());
}
 
Example #22
Source File: UserController.java    From imooc-security with Apache License 2.0 5 votes vote down vote up
@GetMapping()
@JsonView(User.UserSimpleView.class)
@ApiOperation(value = "查询用户")
public List<User> query(UserQueryCondition condition, @PageableDefault(page=2,size=20,sort="age,asc") Pageable pageable){
    System.out.println(ReflectionToStringBuilder.toString(condition, ToStringStyle.MULTI_LINE_STYLE));
    System.out.println(pageable.getPageSize());
    System.out.println(pageable.getPageNumber());
    System.out.println(pageable.getSort());
    List<User> users = new ArrayList<>();
    users.add(new User());
    users.add(new User());
    users.add(new User());
    return users;
}
 
Example #23
Source File: AwsCommonProcess.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
public Volume waitVolume(AwsProcessClient awsProcessClient, String volumeId) {
    // ボリュームの処理待ち
    Volume volume;
    while (true) {
        try {
            Thread.sleep(1000L * awsProcessClient.getDescribeInterval());
        } catch (InterruptedException ignore) {
        }

        volume = describeVolume(awsProcessClient, volumeId);
        VolumeState state;
        try {
            state = VolumeState.fromValue(volume.getState());
        } catch (IllegalArgumentException e) {
            // 予期しないステータス
            AutoException exception = new AutoException("EPROCESS-000112", volume, volume.getState());
            exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(volume));
            throw exception;
        }

        // 安定状態のステータスになったら終了
        if (state == VolumeState.Available || state == VolumeState.InUse || state == VolumeState.Deleted
                || state == VolumeState.Error) {
            break;
        }
    }

    return volume;
}
 
Example #24
Source File: ClassUtils.java    From iaf with Apache License 2.0 5 votes vote down vote up
public static String reflectionToString(final Object o, final String fieldnameEnd) {
	String result=(new ReflectionToStringBuilder(o) {
			protected boolean accept(Field f) {
				if (super.accept(f)) {
					if (trace) log.debug(nameOf(o)+" field ["+f.getName()+"]");
					return fieldnameEnd==null || f.getName().endsWith(fieldnameEnd);
				}
				return false;
			}
		}).toString();
	return result;
}
 
Example #25
Source File: PuppetClient.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
protected void touchFile(String file) {
    List<String> commands = new ArrayList<String>();
    commands.add("/bin/touch");
    commands.add(file);
    CommandResult result = execute(commands);
    if (result.getExitValue() != 0) {
        // ファイルのtouchに失敗
        AutoException exception = new AutoException("EPUPPET-000004", file);
        exception.addDetailInfo(
                "result=" + ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));
        throw exception;
    }
}
 
Example #26
Source File: ProcessScriptHook.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void execute(String hookName, Object... args) {
    String scriptDir = Config.getProperty("hook.scriptDir");
    File scriptFile = new File(scriptDir, hookName + scriptExt);

    // スクリプトファイルが存在しなければ何もしない
    if (!scriptFile.exists()) {
        return;
    }

    List<String> commands = new ArrayList<String>();
    commands.add(scriptFile.getAbsolutePath());
    if (args != null) {
        for (Object arg : args) {
            String str = (arg == null) ? "" : arg.toString();
            commands.add(str);
        }
    }

    try {
        // フック処理のスクリプト実行
        CommandResult result = CommandUtils.execute(commands, 60 * 1000L);

        if (result.getExitValue() != 0) {
            // フック処理のスクリプト実行に失敗
            AutoException exception = new AutoException("EPROCESS-000701", hookName);
            exception.addDetailInfo("commands=" + commands);
            exception.addDetailInfo(
                    "result=" + ReflectionToStringBuilder.toString(result, ToStringStyle.SHORT_PREFIX_STYLE));
            throw exception;
        }
    } catch (Exception e) {
        // XXX: フック処理におけるエラーはPCCの範囲外であるため、エラーが発生しても例外をスローしない
        log.error(e.getMessage(), e);
    }
}
 
Example #27
Source File: AwsInstanceProcess.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
public void waitRun(AwsProcessClient awsProcessClient, Long instanceNo) {
    AwsInstance awsInstance = awsInstanceDao.read(instanceNo);
    String instanceId = awsInstance.getInstanceId();

    // インスタンスの作成待ち
    com.amazonaws.services.ec2.model.Instance instance = awsCommonProcess.waitInstance(awsProcessClient,
            instanceId);

    if (!instance.getState().getName().equals(InstanceStateName.Running.toString())) {
        // インスタンス作成失敗時
        AutoException exception = new AutoException("EPROCESS-000106", instanceId, instance.getState().getName());
        exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(instance));
        throw exception;
    }

    // ログ出力
    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100116", instanceId));
    }

    // イベントログ出力
    Instance instance2 = instanceDao.read(instanceNo);
    processLogger.debug(null, instance2, "AwsInstanceCreateFinish",
            new Object[] { awsProcessClient.getPlatform().getPlatformName(), instanceId });

    // データベース更新
    awsInstance.setAvailabilityZone(instance.getPlacement().getAvailabilityZone());
    awsInstance.setStatus(instance.getState().getName());
    awsInstance.setDnsName(instance.getPublicDnsName());
    awsInstance.setPrivateDnsName(instance.getPrivateDnsName());
    awsInstance.setIpAddress(instance.getPublicIpAddress());
    awsInstance.setPrivateIpAddress(instance.getPrivateIpAddress());
    awsInstanceDao.update(awsInstance);
}
 
Example #28
Source File: AwsInstanceProcess.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
public void waitStop(AwsProcessClient awsProcessClient, Long instanceNo) {
    AwsInstance awsInstance = awsInstanceDao.read(instanceNo);
    String instanceId = awsInstance.getInstanceId();

    // インスタンスの停止待ち
    com.amazonaws.services.ec2.model.Instance instance = awsCommonProcess.waitInstance(awsProcessClient,
            instanceId);

    if (!instance.getState().getName().equals(InstanceStateName.Stopped.toString())) {
        // インスタンス停止失敗時
        AutoException exception = new AutoException("EPROCESS-000129", instanceId, instance.getState().getName());
        exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(instance));
        throw exception;
    }

    // ログ出力
    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100114", instanceId));
    }

    // イベントログ出力
    Instance instance2 = instanceDao.read(instanceNo);
    processLogger.debug(null, instance2, "AwsInstanceStopFinish",
            new Object[] { awsProcessClient.getPlatform().getPlatformName(), instanceId });

    // データベース更新
    awsInstance.setAvailabilityZone(instance.getPlacement().getAvailabilityZone());
    awsInstance.setStatus(instance.getState().getName());
    awsInstance.setDnsName(instance.getPublicDnsName());
    awsInstance.setPrivateDnsName(instance.getPrivateDnsName());
    awsInstance.setIpAddress(instance.getPublicIpAddress());
    awsInstance.setPrivateIpAddress(instance.getPrivateIpAddress());
    awsInstanceDao.update(awsInstance);
}
 
Example #29
Source File: AwsInstanceProcess.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
public void waitStart(AwsProcessClient awsProcessClient, Long instanceNo) {
    AwsInstance awsInstance = awsInstanceDao.read(instanceNo);
    String instanceId = awsInstance.getInstanceId();

    // インスタンスの起動待ち
    com.amazonaws.services.ec2.model.Instance instance = awsCommonProcess.waitInstance(awsProcessClient,
            instanceId);

    if (!instance.getState().getName().equals(InstanceStateName.Running.toString())) {
        // インスタンス起動失敗時
        AutoException exception = new AutoException("EPROCESS-000126", instanceId, instance.getState().getName());
        exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(instance));
        throw exception;
    }

    // ログ出力
    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100112", instanceId));
    }

    // イベントログ出力
    Instance instance2 = instanceDao.read(instanceNo);
    processLogger.debug(null, instance2, "AwsInstanceStartFinish",
            new Object[] { awsProcessClient.getPlatform().getPlatformName(), instanceId });

    // データベース更新
    awsInstance.setAvailabilityZone(instance.getPlacement().getAvailabilityZone());
    awsInstance.setStatus(instance.getState().getName());
    awsInstance.setDnsName(instance.getPublicDnsName());
    awsInstance.setPrivateDnsName(instance.getPrivateDnsName());
    awsInstance.setIpAddress(instance.getPublicIpAddress());
    awsInstance.setPrivateIpAddress(instance.getPrivateIpAddress());
    awsInstanceDao.update(awsInstance);
}
 
Example #30
Source File: SapSystem.java    From iaf with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
	//return ToStringBuilder.reflectionToString(this);
	return (new ReflectionToStringBuilder(this) {
		@Override
		protected boolean accept(Field f) {
			return super.accept(f) && !f.getName().equals("passwd");
		}
	}).toString();	}