本文整理汇总了Java中org.oscm.app.iaas.i18n.Messages类的典型用法代码示例。如果您正苦于以下问题:Java Messages类的具体用法?Java Messages怎么用?Java Messages使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Messages类属于org.oscm.app.iaas.i18n包,在下文中一共展示了Messages类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendMailAboutModification
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
/**
* Sends a notification email about a modification operation.
*
* @param instanceId
* @param paramHandler
* @throws APPlatformException
*/
private void sendMailAboutModification(String instanceId,
PropertyHandler paramHandler) throws APPlatformException {
String mail = paramHandler.getMailForNotification();
if (mail != null) {
Operation operationState = paramHandler.getOperation();
if (operationState.isModification()) {
String locale = paramHandler.getCustomerLocale();
String subject = Messages.get(locale,
"mail_notify_about_modification.subject",
new Object[] { instanceId });
String text = Messages.get(locale,
"mail_notify_about_modification.text",
new Object[] { instanceId });
platformService.sendMail(Collections.singletonList(mail),
subject, text);
}
}
}
示例2: validateInstanceName
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
public void validateInstanceName(PropertyHandler paramHandler)
throws APPlatformException {
String regex = paramHandler.getInstanceNamePattern();
String instanceName = paramHandler.getInstanceName();
if (isNullOrEmpty(instanceName)) {
throw new APPlatformException(Messages.getAll("error_invalid_name",
new Object[] { instanceName }));
}
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(instanceName);
if (!m.matches()) {
logger.error("Validation error on instance name: [" + instanceName
+ "/" + regex + "]");
throw new APPlatformException(Messages.getAll("error_invalid_name",
new Object[] { instanceName }));
}
}
示例3: recoverInline
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
/**
* Make sure we don't attempt to recover inline; if the parser successfully
* recovers, it won't throw an exception.
*/
@Override
public Token recoverInline(Parser recognizer) throws RecognitionException {
InputMismatchException e = new InputMismatchException(recognizer);
String policies = recognizer.getInputStream().getText();
StringTokenizer tk = new StringTokenizer(policies, ";");
String policy = "";
int idx = 0;
while (tk.hasMoreElements()) {
policy = (String) tk.nextElement();
idx += policy.length();
if (idx >= e.getOffendingToken().getStartIndex()) {
break;
}
}
String message = Messages.get(Messages.DEFAULT_LOCALE,
"error_invalid_firewallconfig", new Object[] {
e.getOffendingToken().getText(), policy });
throw new RuntimeException(message);
}
示例4: getSuspendException
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
@Test
public void getSuspendException() {
// given
RORException rorException = spy(new RORException(EXCEPTIONMESSAGE));
Throwable cause = new Throwable();
String localizedMessage = Messages.get("en", EXCEPTIONMESSAGETYPE,
cause.getClass().getName());
doReturn(cause).when(rorException).getCause();
// when
SuspendException suspendException = rorVServerCommunication
.getSuspendException(rorException, EXCEPTIONMESSAGETYPE);
// then
assertEquals(localizedMessage,
suspendException.getLocalizedMessage("en"));
assertEquals(cause, suspendException.getCause());
}
示例5: getNonErrorVServerStatus_StopError
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
@Test(expected = SuspendException.class)
public void getNonErrorVServerStatus_StopError() throws Exception {
// given
String SERVER_ID = "SERVER1";
String INSTANCENAME = "INSTANCENAME1";
paramHandler.setVserverId(SERVER_ID);
doReturn(INSTANCENAME).when(paramHandler).getInstanceName();
doReturn(VServerStatus.STOP_ERROR).when(lServerClient).getStatus();
// when
try {
rorVServerCommunication.getNonErrorVServerStatus(paramHandler);
}
// then
catch (SuspendException se) {
assertEquals(Messages.get("en", "error_failed_to_stop_vserver",
new Object[] { SERVER_ID, INSTANCENAME }),
se.getLocalizedMessage("en"));
assertEquals(
Messages.getAll("error_failed_to_stop_vserver",
new Object[] { SERVER_ID, INSTANCENAME }).size(),
se.getLocalizedMessages().size());
throw se;
}
}
示例6: getNonErrorVServerStatus_StartError
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
@Test(expected = SuspendException.class)
public void getNonErrorVServerStatus_StartError() throws Exception {
// given
String SERVER_ID = "SERVER1";
String INSTANCENAME = "INSTANCENAME1";
paramHandler.setVserverId(SERVER_ID);
doReturn(INSTANCENAME).when(paramHandler).getInstanceName();
doReturn(VServerStatus.START_ERROR).when(lServerClient).getStatus();
// when
try {
rorVServerCommunication.getNonErrorVServerStatus(paramHandler);
}
// then
catch (SuspendException se) {
assertEquals(Messages.get("en", "error_failed_to_start_vserver",
new Object[] { SERVER_ID, INSTANCENAME }),
se.getLocalizedMessage("en"));
assertEquals(
Messages.getAll("error_failed_to_start_vserver",
new Object[] { SERVER_ID, INSTANCENAME }).size(),
se.getLocalizedMessages().size());
throw se;
}
}
示例7: getNonErrorVServerStatus_UnexpectedStop
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
@Test(expected = SuspendException.class)
public void getNonErrorVServerStatus_UnexpectedStop() throws Exception {
// given
String SERVER_ID = "SERVER1";
String INSTANCENAME = "INSTANCENAME1";
paramHandler.setVserverId(SERVER_ID);
doReturn(INSTANCENAME).when(paramHandler).getInstanceName();
doReturn(VServerStatus.UNEXPECTED_STOP).when(lServerClient).getStatus();
// when
try {
rorVServerCommunication.getNonErrorVServerStatus(paramHandler);
}
// then
catch (SuspendException se) {
assertEquals(Messages.get("en", "error_unexpected_stop_vserver",
new Object[] { SERVER_ID, INSTANCENAME }),
se.getLocalizedMessage("en"));
assertEquals(
Messages.getAll("error_unexpected_stop_vserver",
new Object[] { SERVER_ID, INSTANCENAME }).size(),
se.getLocalizedMessages().size());
throw se;
}
}
示例8: missingPlatformId
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
@Test(expected = SuspendException.class)
public void missingPlatformId() throws Exception {
// given
lPlatformClient = new LPlatformClient(rorClient, null);
// when
try {
lPlatformClient.stopAllServers();
}
// then
catch (SuspendException se) {
assertEquals(Messages.get("en", "error_missing_sysid"),
se.getLocalizedMessage("en"));
throw se;
}
}
示例9: emptyPlatformId
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
@Test(expected = SuspendException.class)
public void emptyPlatformId() throws Exception {
// given
lPlatformClient = new LPlatformClient(rorClient, " ");
// when
try {
lPlatformClient.stopAllServers();
}
// then
catch (SuspendException se) {
assertEquals(Messages.get("en", "error_missing_sysid"),
se.getLocalizedMessage("en"));
throw se;
}
}
示例10: validateClusterDefinition
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
private void validateClusterDefinition() throws ConfigurationException {
if (isClusterDefined()) {
return;
}
if (notNullNorEmpty(getClusterSize())
|| notNullNorEmpty(getMasterTemplateId())
|| notNullNorEmpty(getSlaveTemplateId())) {
throw new ConfigurationException(Messages.getAll(
"error_provider_clusterdef_incomplete", getClusterSize(),
getMasterTemplateId(), getSlaveTemplateId()));
}
}
示例11: getControllerInstanceStatus
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
/**
* Provide information about the state of operation according to current
* task state.
*
* @param controllerId
* id of the controller
* @param instanceId
* id of the instance
* @param paramHandler
* entity which holds all properties of the instance.
* @return InstanceStatus
* @throws Exception
*/
public InstanceStatus getControllerInstanceStatus(String controllerId,
String instanceId, PropertyHandler paramHandler) throws Exception {
if (paramHandler.isInstanceSuspended()) {
return getInstanceStatusForSuspendedInstance();
}
FlowState oldState = paramHandler.getState();
// Check and/or dispatch next provisioning operation
performProvisioningProcessing(controllerId, instanceId, paramHandler);
FlowState state = paramHandler.getState();
if (state == FlowState.FAILED) {
throw new APPlatformException(Messages.getAll("error_operation"));
}
Operation operation = paramHandler.getOperation();
InstanceStatus result = new InstanceStatus();
result.setIsReady((state == FlowState.FINISHED && (operation != null && !operation
.isDeletion())) || state == FlowState.DESTROYED);
result.setRunWithTimer(state != FlowState.MANUAL);
if (state == FlowState.VSERVERS_STOPPING) {
result.setAccessInfo(Messages.get(paramHandler.getCustomerLocale(),
"accessInfo_NOT_AVAILABLE"));
}
if (result.isReady()) {
if (state != FlowState.DESTROYED
&& oldState != FlowState.VSERVERS_STOPPING) {
// add access info as far as applicable
result.setAccessInfo(getConnectionData(instanceId, paramHandler));
}
// notify about modification
sendMailAboutModification(instanceId, paramHandler);
}
return result;
}
示例12: getSuspendException
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
/**
* Creates a SuspendException related to this exception.
*
* @return the SuspendException
*/
public SuspendException getSuspendException() {
if (ResourceType.UNKNOWN.equals(getResouceType())) {
return new SuspendException(Messages.getAll(
"error_resource_missing_unknown_type", new Object[] {
getResouceType(), getResouceId(), getMessage() }));
} else {
return new SuspendException(Messages.getAll(
"error_resource_missing", new Object[] { getResouceType(),
getResouceId() }));
}
}
示例13: validateExistingInstance
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
public void validateExistingInstance(APPlatformService platformService,
String controllerID, PropertyHandler paramHandler)
throws APPlatformException {
String instanceName = paramHandler.getInstanceName();
if (platformService.exists(controllerID, instanceName)) {
logger.error("Other instance with same name already registered: ["
+ instanceName + "]");
throw new APPlatformException(Messages.getAll(
"error_instance_exists", new Object[] { instanceName }));
}
}
示例14: getProvisioningStatusText
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
/**
* Returns a small status text for the current provisioning step.
*
* @param paramHandler
* property handler containing the current status
* @return short status text describing the current status
*/
private List<LocalizedText> getProvisioningStatusText(
PropertyHandler paramHandler) {
List<LocalizedText> messages = Messages.getAll("status_"
+ paramHandler.getState());
for (LocalizedText message : messages) {
if (message.getText() == null
|| (message.getText().startsWith("!") && message.getText()
.endsWith("!"))) {
message.setText(Messages.get(message.getLocale(),
"status_INSTANCE_OVERALL"));
}
}
return messages;
}
示例15: recover
import org.oscm.app.iaas.i18n.Messages; //导入依赖的package包/类
/**
* Instead of recovering from exception e, rethrow it wrapped in a generic
* RuntimeException so it is not caught by the rule function catches.
* Exception e is the "cause" of the RuntimeException.
*/
@Override
public void recover(Parser recognizer, RecognitionException e) {
String message = Messages.get(Messages.DEFAULT_LOCALE,
"error_invalid_firewallconfig", new Object[] {
e.getOffendingToken().getText(),
e.getInputStream().toString() });
throw new RuntimeException(message);
}