本文整理汇总了Java中org.restlet.data.Status类的典型用法代码示例。如果您正苦于以下问题:Java Status类的具体用法?Java Status怎么用?Java Status使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Status类属于org.restlet.data包,在下文中一共展示了Status类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateScore
import org.restlet.data.Status; //导入依赖的package包/类
@Put
public Status updateScore(UpdateScoreEntity entity) throws SQLException {
if (entity == null) throw new BadEntityException("ENTITY_NOT_FOUND");
if (mEvents.getEvent(mEventId) == null) throw new NotFoundException("EVENT_NOT_FOUND");
if (!mEvents.roundExists(mEventId, mRoundId)) throw new NotFoundException("ROUND_NOT_FOUND");
if (mEvents.getRegistered(mEventId, mUserId) == null) throw new NotFoundException("USER_NOT_REGISTERED");
if (mEvents.getScore(mRoundId, mUserId) != null) mEvents.updateScore(mRoundId, mUserId, entity.score);
else mEvents.addScore(mRoundId, mUserId, entity.score);
try {
mRabbitMQManager.basicPublish("Pub", "", null, new TopicPacket("event-score-v1." + mEventId, new UpdateScoreMessage(mEventId, mRoundId, mUserId, entity.score)));
} catch (IOException e) {
Server.LOGGER.log(Level.SEVERE, "Cannot send publish to RabbitMQ", e);
}
return Status.SUCCESS_OK;
}
示例2: updateEvent
import org.restlet.data.Status; //导入依赖的package包/类
@Put
public Status updateEvent(UpdateEventEntity entity) throws SQLException {
ValidationUtils.verifyGroup(getRequest(), ApiV1.ADMIN);
ValidationErrors err = new ValidationErrors();
if (entity == null) throw new BadEntityException("ENTITY_NOT_FOUND");
err.verifyFieldEmptyness("name", entity.name, 3, 200);
err.verifyFieldEmptyness("description", entity.description, 3, 2048);
err.checkErrors("EVENT_UPDATE_ERROR");
EventBean bean = mEvents.getEvent(mEventId);
if (bean == null) throw new NotFoundException("EVENT_NOT_FOUND");
bean.setCurrent(entity.current);
bean.setDescription(entity.description);
bean.setName(entity.name);
bean.setReservedToAffiliates(entity.reserved_to_affiliates);
bean.setReservedToPartners(entity.reserved_to_partners);
bean.setStatus(entity.status);
bean.setMinimumViews(entity.minimum_views);
bean.setMinimumFollowers(entity.minimum_followers);
mEvents.update(bean);
return Status.SUCCESS_OK;
}
示例3: updatePariticipationStatus
import org.restlet.data.Status; //导入依赖的package包/类
@Put
public Status updatePariticipationStatus(EmailValidationBean bean) throws SQLException {
if (bean == null) throw new BadEntityException("EVENT_NOT_FOUND");
ValidationErrors err = new ValidationErrors();
err.verifyFieldEmptyness("key", bean.key, 5, 36);
err.checkErrors("INVALID_KEY");
AccountBean acc = (AccountBean) getRequest().getAttributes().get("account");
UserStatus status = mEvents.getUserStatusFromEmailKey(mEventId, acc.getTwitchId(), bean.key);
if (status == null) throw new NotFoundException("UNKNOWN_KEY");
if (status != UserStatus.AWAITING_FOR_EMAIL_VALIDATION) throw new ConflictException("BAD_STATUS");
mEvents.updateUser(mEventId, acc.getTwitchId(), UserStatus.VALIDATED);
try {
EventBean event = mEvents.getEvent(mEventId);
MimeMessage message = mEmailsService.generateMime("Validez votre compte!",
mValidatedEmail.replaceAll("\\{EVENT_NAME\\}", event.getName())
.replaceAll("\\{EVENT_ID\\}", event.getId() + ""), "text/html", acc.getEmail());
mEmailsService.sendEmail(message);
} catch (MessagingException e) {
Main.LOGGER.log(Level.SEVERE, "Cannot send email.", e);
}
return Status.SUCCESS_OK;
}
示例4: request
import org.restlet.data.Status; //导入依赖的package包/类
@Get
public String request() throws JSONException {
JSONObject json = new JSONObject();
json.put("starttime", TestServer.serverPreferences.getStartTimestamp());
json.put("version", TestServer.TEST_SERVER_VERSION_MAJOR + "." + TestServer.TEST_SERVER_VERSION_MINOR + "." + TestServer.TEST_SERVER_VERSION_PATCH);
if (TestServerConsole.errorReportMap.size() > 0) {
setStatus(Status.SERVER_ERROR_INTERNAL);
JSONArray errors = new JSONArray();
for (ErrorReport er : TestServerConsole.errorReportMap.values()) {
errors.put(er.toJson());
}
json.put("errors", errors);
}
return json.toString();
}
示例5: handleApiQuery
import org.restlet.data.Status; //导入依赖的package包/类
@Get("json")
public CumulativeTimeBucket handleApiQuery() {
IPktInProcessingTimeService pktinProcTime =
(IPktInProcessingTimeService)getContext().getAttributes().
get(IPktInProcessingTimeService.class.getCanonicalName());
setStatus(Status.SUCCESS_OK, "OK");
// If the user is requesting this they must think that it is enabled,
// so lets enable it to prevent from erroring out
if (!pktinProcTime.isEnabled()){
pktinProcTime.setEnabled(true);
logger.warn("Requesting performance monitor data when performance monitor is disabled. Turning it on");
}
// Allocate output object
if (pktinProcTime.isEnabled()) {
CumulativeTimeBucket ctb = pktinProcTime.getCtb();
ctb.computeAverages();
return ctb;
}
return null;
}
示例6: retrieve
import org.restlet.data.Status; //导入依赖的package包/类
@Get("json")
public String retrieve() {
IPktInProcessingTimeService pktinProcTime =
(IPktInProcessingTimeService)getContext().getAttributes().
get(IPktInProcessingTimeService.class.getCanonicalName());
String param = ((String)getRequestAttributes().get("perfmonstate")).toLowerCase();
if (param.equals("reset")) {
// We cannot reset something that is disabled, so enable it first.
if(!pktinProcTime.isEnabled()){
pktinProcTime.setEnabled(true);
}
pktinProcTime.getCtb().reset();
} else {
if (param.equals("enable") || param.equals("true")) {
pktinProcTime.setEnabled(true);
} else if (param.equals("disable") || param.equals("false")) {
pktinProcTime.setEnabled(false);
}
}
setStatus(Status.SUCCESS_OK, "OK");
return "{ \"enabled\" : " + pktinProcTime.isEnabled() + " }";
}
示例7: addHost
import org.restlet.data.Status; //导入依赖的package包/类
@Put
public String addHost(String postData) {
IVirtualNetworkService vns =
(IVirtualNetworkService)getContext().getAttributes().
get(IVirtualNetworkService.class.getCanonicalName());
HostDefinition host = new HostDefinition();
host.port = (String) getRequestAttributes().get("port");
host.guid = (String) getRequestAttributes().get("network");
try {
jsonToHostDefinition(postData, host);
} catch (IOException e) {
log.error("Could not parse JSON {}", e.getMessage());
}
vns.addHost(MacAddress.of(host.mac), host.guid, host.port);
setStatus(Status.SUCCESS_OK);
return "{\"status\":\"ok\"}";
}
示例8: ListStaticFlowEntries
import org.restlet.data.Status; //导入依赖的package包/类
@Get("json")
public OFFlowModMap ListStaticFlowEntries() {
IStaticFlowEntryPusherService sfpService =
(IStaticFlowEntryPusherService)getContext().getAttributes().
get(IStaticFlowEntryPusherService.class.getCanonicalName());
String param = (String) getRequestAttributes().get("switch");
if (log.isDebugEnabled())
log.debug("Listing all static flow entires for switch: " + param);
if (param.toLowerCase().equals("all")) {
return new OFFlowModMap(sfpService.getFlows());
} else {
try {
Map<String, Map<String, OFFlowMod>> retMap = new HashMap<String, Map<String, OFFlowMod>>();
retMap.put(param, sfpService.getFlows(DatapathId.of(param)));
return new OFFlowModMap(retMap);
} catch (NumberFormatException e){
setStatus(Status.CLIENT_ERROR_BAD_REQUEST, ControllerSwitchesResource.DPID_ERROR);
}
}
return null;
}
示例9: ClearStaticFlowEntries
import org.restlet.data.Status; //导入依赖的package包/类
@Get("json")
public String ClearStaticFlowEntries() {
IStaticFlowEntryPusherService sfpService =
(IStaticFlowEntryPusherService)getContext().getAttributes().
get(IStaticFlowEntryPusherService.class.getCanonicalName());
String param = (String) getRequestAttributes().get("switch");
if (log.isDebugEnabled())
log.debug("Clearing all static flow entires for switch: " + param);
if (param.toLowerCase().equals("all")) {
sfpService.deleteAllFlows();
return "{\"status\":\"Deleted all flows.\"}";
} else {
try {
sfpService.deleteFlowsForSwitch(DatapathId.of(param));
return "{\"status\":\"Deleted all flows for switch " + param + ".\"}";
} catch (NumberFormatException e){
setStatus(Status.CLIENT_ERROR_BAD_REQUEST,
ControllerSwitchesResource.DPID_ERROR);
return "'{\"status\":\"Could not delete flows requested! See controller log for details.\"}'";
}
}
}
示例10: handlePost
import org.restlet.data.Status; //导入依赖的package包/类
@Post
public String handlePost(String fmJson) {
IFirewallService firewall = getFirewallService();
String newMask;
try {
newMask = jsonExtractSubnetMask(fmJson);
} catch (IOException e) {
log.error("Error parsing new subnet mask: " + fmJson, e);
setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
return "{\"status\" : \"Error! Could not parse new subnet mask, see log for details.\"}";
}
firewall.setSubnetMask(newMask);
setStatus(Status.SUCCESS_OK);
return ("{\"status\" : \"subnet mask set\"}");
}
示例11: getRepresentation
import org.restlet.data.Status; //导入依赖的package包/类
@Get("csv")
public Object getRepresentation() {
if (ds == null) {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return null;
}
if (!ds.getStatus().isInitialized()) {
getResponse().setStatus(Status.SUCCESS_ACCEPTED);
return "Initializing...";
}
Form queryForm = getRequest().getOriginalRef().getQueryAsForm();
char delimiter = queryForm.getFirstValue("delimiter", ",").charAt(0);
return new CsvRepresentation(getStats(), true, delimiter);
}
示例12: put
import org.restlet.data.Status; //导入依赖的package包/类
@Override
@Put("json")
public Representation put(Representation entity) {
try {
String jsonRequest = entity.getText();
TopicPartition topicPartitionInfo = TopicPartition.init(jsonRequest);
if (_autoTopicWhitelistingManager != null) {
_autoTopicWhitelistingManager.removeFromBlacklist(topicPartitionInfo.getTopic());
}
if (_helixMirrorMakerManager.isTopicExisted(topicPartitionInfo.getTopic())) {
_helixMirrorMakerManager.expandTopicInMirrorMaker(topicPartitionInfo);
return new StringRepresentation(
String.format("Successfully expand topic: %s", topicPartitionInfo));
} else {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation(String.format(
"Failed to expand topic, topic: %s is not existed!", topicPartitionInfo.getTopic()));
}
} catch (IOException e) {
LOGGER.error("Got error during processing Put request", e);
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
return new StringRepresentation(
String.format("Failed to expand topic, with exception: %s", e));
}
}
示例13: postFormData
import org.restlet.data.Status; //导入依赖的package包/类
@Post
public void postFormData(final Representation entity) {
ExtensionTokenManager tokenManager = getTokenManager();
if (tokenManager.authenticationRequired()) {
getResponse().setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
} else {
Form form = new Form(entity);
final String emailAddress = form.getFirstValue(FORM_INPUT_EMAIL_ADDRESS);
if (StringUtils.isNotBlank(emailAddress)) {
TestEmailNotifier testNotifier = (TestEmailNotifier) getContext().getAttributes()
.get(EmailExtensionConstants.CONTEXT_ATTRIBUTE_KEY_TEST_NOTIFIER);
testNotifier.setEmailAddress(emailAddress);
testNotifier.run();
testNotifier.setEmailAddress("");
}
}
}
示例14: getTestForm
import org.restlet.data.Status; //导入依赖的package包/类
@Get
public FileRepresentation getTestForm() {
ExtensionTokenManager tokenManager = this.getTokenManager();
if (tokenManager.authenticationRequired()) {
getResponse().setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
return null;
} else {
try {
File webDir = getWebDirectory();
File file = new File(webDir, TEST_FORM_HTML);
FileRepresentation htmlForm = new FileRepresentation(file, MediaType.TEXT_HTML);
return htmlForm;
} catch (Exception ex) {
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
return null;
}
}
}
示例15: authenticate
import org.restlet.data.Status; //导入依赖的package包/类
@Get
public void authenticate() {
// Use state if provided
final String next = getRequest().getResourceRef().getQueryAsForm(true).getFirstValue("next");
final StateUrlProcessor state = new StateUrlProcessor(getQueryValue("state"));
if (state.getReturnUrl().isPresent() && next != null) {
state.setReturnUrl(next);
} else if (getRequest().getReferrerRef() != null) {
state.setReturnUrl(getRequest().getReferrerRef().toString());
}
final ExtensionTokenManager tokenManager = getTokenManager();
if (tokenManager != null) {
logger.info("Authenticate method called to obtain authorization url");
final Reference authUrl = new Reference(tokenManager.getOAuthAuthorizationUrl(Optional.of(state)));
getResponse().redirectSeeOther(authUrl);
} else {
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
}
}