use of javax.ws.rs.PUT in project OpenAttestation by OpenAttestation.
the class AbstractJsonapiResource method storeJsonapiCollection.
/**
* Replace an item in the collection. Input Content-Type is
* application/vnd.api+json Output Content-Type is application/vnd.api+json
*
* The input item must be wrapped in a collection. The output item is always
* wrapped in a collection.
*
* @param locator
* @param collection
* @return
*/
@Path("/{id}")
@PUT
@Consumes(DataMediaType.APPLICATION_VND_API_JSON)
@Produces(DataMediaType.APPLICATION_VND_API_JSON)
public C storeJsonapiCollection(@BeanParam L locator, C collection) {
// misnomer, what we really mean is "store one but wrapped ina collection for jsonapi"
log.debug("storeCollection");
ValidationUtil.validate(collection);
List<T> list = collection.getDocuments();
if (list == null || list.isEmpty()) {
throw new WebApplicationException(Response.Status.BAD_REQUEST);
}
T item = list.get(0);
locator.copyTo(item);
if (item == null) {
getRepository().create(item);
} else {
getRepository().store(item);
}
return collection;
}
use of javax.ws.rs.PUT in project OpenAttestation by OpenAttestation.
the class AssetTagCert method revokeAssetTagCertificate.
/**
* This REST API would be called by tag provisioning service whenever a valid asset tag certificate is revoked.
* @param atagObj
* @return
*/
//@RolesAllowed({"AssetTagManagement"})
// @RequiresPermissions({"tag_certificates:store"})
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public String revokeAssetTagCertificate(AssetTagCertRevokeRequest atagObj) {
boolean result;
AssetTagCertBO object = new AssetTagCertBO();
result = object.revokeAssetTagCertificate(atagObj, null);
return Boolean.toString(result);
}
use of javax.ws.rs.PUT in project jersey by jersey.
the class MultiPartResource method ten.
@Path("ten")
@PUT
@Consumes("multipart/mixed")
@Produces("text/plain")
public Response ten(MultiPart mp) {
if (!(mp.getBodyParts().size() == 2)) {
return Response.ok("FAILED: Body part count is " + mp.getBodyParts().size() + " instead of 2").build();
} else if (!(mp.getBodyParts().get(1).getEntity() instanceof BodyPartEntity)) {
return Response.ok("FAILED: Second body part is " + mp.getBodyParts().get(1).getClass().getName() + " instead of BodyPartEntity").build();
}
BodyPartEntity bpe = (BodyPartEntity) mp.getBodyParts().get(1).getEntity();
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream stream = bpe.getInputStream();
byte[] buffer = new byte[2048];
while (true) {
int n = stream.read(buffer);
if (n < 0) {
break;
}
baos.write(buffer, 0, n);
}
if (baos.toByteArray().length > 0) {
return Response.ok("FAILED: Second body part had " + baos.toByteArray().length + " bytes instead of 0").build();
}
return Response.ok("SUCCESS: All tests passed").build();
} catch (IOException e) {
return Response.ok("FAILED: Threw IOException").build();
}
}
use of javax.ws.rs.PUT in project jersey by jersey.
the class BookmarkResource method putBookmark.
@PUT
@Consumes("application/json")
public void putBookmark(JSONObject jsonEntity) throws JSONException {
bookmarkEntity.setLdesc(jsonEntity.getString("ldesc"));
bookmarkEntity.setSdesc(jsonEntity.getString("sdesc"));
bookmarkEntity.setUpdated(new Date());
TransactionManager.manage(utx, new Transactional(em) {
public void transact() {
em.merge(bookmarkEntity);
}
});
}
use of javax.ws.rs.PUT in project jersey by jersey.
the class MessageStreamResource method putMessage.
/**
* Put a new message to the stream.
*
* The message will be broadcast to all registered SSE clients.
*
* @param message message to be broadcast.
*/
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public void putMessage(final Message message) {
LOGGER.info("--> Message received.");
final OutboundEvent event = new OutboundEvent.Builder().id(String.valueOf(nextMessageId.getAndIncrement())).mediaType(MediaType.APPLICATION_JSON_TYPE).data(Message.class, message).build();
broadcaster.broadcast(event);
}
Aggregations