當前位置: 首頁>>代碼示例>>Java>>正文


Java Put類代碼示例

本文整理匯總了Java中org.restlet.resource.Put的典型用法代碼示例。如果您正苦於以下問題:Java Put類的具體用法?Java Put怎麽用?Java Put使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Put類屬於org.restlet.resource包,在下文中一共展示了Put類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Create

import org.restlet.resource.Put; //導入依賴的package包/類
@Put
public String Create(String json) {
	boolean ret;
	ObjectMapper mapper = new ObjectMapper();
		try {
			JsonNode root = mapper.readTree(json);

			String addr = root.get("group_addr").asText();
			IMulticastREST mc = (IMulticastREST)getContext().getAttributes().get(IMulticastREST.class.getCanonicalName());
			ret = mc.createGroup(addr);
		} 
		catch (IOException e) {
			e.printStackTrace();
			return new String("error");
		}

		if (ret)
			return new String("group created");
		else
			return new String("group already existing");
}
 
開發者ID:hexec,項目名稱:floodlight-simple-multicast,代碼行數:22,代碼來源:GroupCreateResource.java

示例2: sendDiscoverPacket

import org.restlet.resource.Put; //導入依賴的package包/類
@Put("json")
public String sendDiscoverPacket() {
    IPathVerificationService pvs =
            (IPathVerificationService) getContext().getAttributes().get(IPathVerificationService.class.getCanonicalName());

    String srcSwitch = (String) getRequestAttributes().get("src_switch");
    String port = (String) getRequestAttributes().get("src_port");
    String dstSwitch = (String) getRequestAttributes().get("dst_switch");

    logger.debug("asking {} to send a discovery packet out port {} with destination {}.", new Object[]{srcSwitch, port, dstSwitch});

    if (dstSwitch == null) {
        DatapathId d = DatapathId.of(srcSwitch);
        int p = Integer.parseInt(port);
        pvs.sendDiscoveryMessage(d, OFPort.of(p));
    } else {
        pvs.sendDiscoveryMessage(DatapathId.of(srcSwitch), OFPort.of(new Integer(port)), DatapathId.of(dstSwitch));
    }
    return null;
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:21,代碼來源:PathDiscover.java

示例3: updateScore

import org.restlet.resource.Put; //導入依賴的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;
}
 
開發者ID:FightForSub,項目名稱:FFS-Api,代碼行數:20,代碼來源:EventRoundUserScoreResource.java

示例4: updateEvent

import org.restlet.resource.Put; //導入依賴的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;
}
 
開發者ID:FightForSub,項目名稱:FFS-Api,代碼行數:26,代碼來源:EventResource.java

示例5: updatePariticipationStatus

import org.restlet.resource.Put; //導入依賴的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;
}
 
開發者ID:FightForSub,項目名稱:FFS-Api,代碼行數:27,代碼來源:EventRegisterResource.java

示例6: addHost

import org.restlet.resource.Put; //導入依賴的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\"}";
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:18,代碼來源:HostResource.java

示例7: createMonitor

import org.restlet.resource.Put; //導入依賴的package包/類
@Put
@Post
public LBMonitor createMonitor(String postData) {

    LBMonitor monitor=null;
    try {
        monitor=jsonToMonitor(postData);
    } catch (IOException e) {
        log.error("Could not parse JSON {}", e.getMessage());
    }
    
    ILoadBalancerService lbs =
            (ILoadBalancerService)getContext().getAttributes().
                get(ILoadBalancerService.class.getCanonicalName());
    
    String monitorId = (String) getRequestAttributes().get("monitor");
    if (monitorId != null)
        return lbs.updateMonitor(monitor);
    else
        return lbs.createMonitor(monitor);
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:22,代碼來源:MonitorsResource.java

示例8: createVip

import org.restlet.resource.Put; //導入依賴的package包/類
@Put
@Post
public LBVip createVip(String postData) {

    LBVip vip=null;
    try {
        vip=jsonToVip(postData);
    } catch (IOException e) {
        log.error("Could not parse JSON {}", e.getMessage());
    }
    
    ILoadBalancerService lbs =
            (ILoadBalancerService)getContext().getAttributes().
                get(ILoadBalancerService.class.getCanonicalName());
    
    String vipId = (String) getRequestAttributes().get("vip");
    if (vipId != null)
        return lbs.updateVip(vip);
    else
        return lbs.createVip(vip);
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:22,代碼來源:VipsResource.java

示例9: createPool

import org.restlet.resource.Put; //導入依賴的package包/類
@Put
@Post
public LBPool createPool(String postData) {        

    LBPool pool=null;
    try {
        pool=jsonToPool(postData);
    } catch (IOException e) {
        log.error("Could not parse JSON {}", e.getMessage());
    }
    
    ILoadBalancerService lbs =
            (ILoadBalancerService)getContext().getAttributes().
                get(ILoadBalancerService.class.getCanonicalName());
    
    String poolId = (String) getRequestAttributes().get("pool");
    if (poolId != null)
        return lbs.updatePool(pool);
    else        
        return lbs.createPool(pool);
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:22,代碼來源:PoolsResource.java

示例10: createMember

import org.restlet.resource.Put; //導入依賴的package包/類
@Put
@Post
public LBMember createMember(String postData) {        

    LBMember member=null;
    try {
        member=jsonToMember(postData);
    } catch (IOException e) {
        log.error("Could not parse JSON {}", e.getMessage());
    }
    
    ILoadBalancerService lbs =
            (ILoadBalancerService)getContext().getAttributes().
                get(ILoadBalancerService.class.getCanonicalName());
    
    String memberId = (String) getRequestAttributes().get("member");
    if (memberId != null)
        return lbs.updateMember(member);
    else        
        return lbs.createMember(member);
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:22,代碼來源:MembersResource.java

示例11: config

import org.restlet.resource.Put; //導入依賴的package包/類
@Post
@Put
public Object config() {
	IStatisticsService statisticsService = (IStatisticsService) getContext().getAttributes().get(IStatisticsService.class.getCanonicalName());

	if (getReference().getPath().contains(SwitchStatisticsWebRoutable.ENABLE_STR)) {
		statisticsService.collectStatistics(true);
		return Collections.singletonMap("statistics-collection", "enabled");
	}
	
	if (getReference().getPath().contains(SwitchStatisticsWebRoutable.DISABLE_STR)) {
		statisticsService.collectStatistics(false);
		return Collections.singletonMap("statistics-collection", "disabled");
	}

	return Collections.singletonMap("ERROR", "Unimplemented configuration option");
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:18,代碼來源:ConfigResource.java

示例12: addHost

import org.restlet.resource.Put; //導入依賴的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.valueOf(host.mac), host.guid, host.port);
    setStatus(Status.SUCCESS_OK);
    return "{\"status\":\"ok\"}";
}
 
開發者ID:JianqingJiang,項目名稱:QoS-floodlight,代碼行數:18,代碼來源:HostResource.java

示例13: handlePut

import org.restlet.resource.Put; //導入依賴的package包/類
@Put("json")
public Representation handlePut(Representation entity) {

    String path = getReference().getPath();

    String dbname = getDatabaseName(path);

    String pathWithFirstAndLastSlashRemoved = path.replaceAll("^/", "").replaceAll("/$", "");

    if (pathWithFirstAndLastSlashRemoved.equals(dbname)) {
        // must be a PUT /target request
        return handleCreateTargetPut(dbname);
    }
    else if (!dbNameExists(dbname)) {
        return databaseNotFound();
    }
    else if (path.contains("/_local/")) {
        return handleLocalPut(dbname);
    } else {
    	getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
    	return new StringRepresentation("{\"message\": \"Server error for request: " + getMethod() + " " + path + "\"}", MediaType.TEXT_PLAIN);
    }
}
 
開發者ID:ibm-watson-data-lab,項目名稱:sync-android-p2p,代碼行數:24,代碼來源:HttpListener.java

示例14: put

import org.restlet.resource.Put; //導入依賴的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));
  }
}
 
開發者ID:uber,項目名稱:uReplicator,代碼行數:26,代碼來源:TopicManagementRestletResource.java


注:本文中的org.restlet.resource.Put類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。