Search in sources :

Example 1 with Post

use of com.pratilipi.api.annotation.Post in project pratilipi by Pratilipi.

the class DeleteTagsApi method addTags.

@Post
public GenericResponse addTags(PostRequest request) throws InsufficientAccessException {
    AccessToken accessToken = AccessTokenFilter.getAccessToken();
    if (accessToken.getUserId() != 5073076857339904L) {
        Logger.getLogger(TagsApi.class.getSimpleName()).log(Level.SEVERE, "AccessToken : " + accessToken.getId());
        Logger.getLogger(TagsApi.class.getSimpleName()).log(Level.SEVERE, "User Id : " + accessToken.getUserId());
        throw new InsufficientAccessException();
    }
    TagDataUtil.removeTags(request.getIds());
    return new GenericResponse();
}
Also used : GenericResponse(com.pratilipi.api.shared.GenericResponse) AccessToken(com.pratilipi.data.type.AccessToken) InsufficientAccessException(com.pratilipi.common.exception.InsufficientAccessException) Post(com.pratilipi.api.annotation.Post)

Example 2 with Post

use of com.pratilipi.api.annotation.Post in project pratilipi by Pratilipi.

the class I18nApi method post.

@Post
public static GenericResponse post(PostRequest request) throws InsufficientAccessException, UnexpectedServerException {
    if (!UserAccessUtil.hasUserAccess(AccessTokenFilter.getAccessToken().getUserId(), request.language, AccessType.I18N_UPDATE))
        throw new InsufficientAccessException();
    DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
    List<I18n> i18nList = new ArrayList<>();
    for (Entry<String, String> entry : request.keyValues.entrySet()) {
        I18n i18n = dataAccessor.getI18n(entry.getKey());
        if (i18n == null)
            i18n = dataAccessor.newI18n(entry.getKey());
        // Resetting the group if its already set
        i18n.setGroup(request.group);
        i18n.setI18nString(request.language, entry.getValue());
        i18nList.add(i18n);
    }
    i18nList = dataAccessor.createOrUpdateI18nList(i18nList);
    return new GenericResponse();
}
Also used : GenericResponse(com.pratilipi.api.shared.GenericResponse) DataAccessor(com.pratilipi.data.DataAccessor) ArrayList(java.util.ArrayList) InsufficientAccessException(com.pratilipi.common.exception.InsufficientAccessException) I18n(com.pratilipi.data.type.I18n) Post(com.pratilipi.api.annotation.Post)

Example 3 with Post

use of com.pratilipi.api.annotation.Post in project pratilipi by Pratilipi.

the class AuthorImageApi method post.

@Post
public GenericResponse post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException, UnexpectedServerException {
    BlobEntry blobEntry = DataAccessorFactory.getBlobAccessor().newBlob(request.getName());
    blobEntry.setData(request.getData());
    blobEntry.setMimeType(request.getMimeType());
    blobEntry.setMetaName(request.getName());
    String profileImageUrl = AuthorDataUtil.saveAuthorImage(request.authorId, blobEntry);
    return new Response(profileImageUrl);
}
Also used : GenericFileDownloadResponse(com.pratilipi.api.shared.GenericFileDownloadResponse) GenericResponse(com.pratilipi.api.shared.GenericResponse) BlobEntry(com.pratilipi.data.type.BlobEntry) Post(com.pratilipi.api.annotation.Post)

Example 4 with Post

use of com.pratilipi.api.annotation.Post in project pratilipi by Pratilipi.

the class PratilipiContentImageApi method post.

@Post
public PostResponse post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException, UnexpectedServerException {
    BlobEntry blobEntry = DataAccessorFactory.getBlobAccessor().newBlob(request.getName());
    blobEntry.setData(request.getData());
    blobEntry.setMimeType(request.getMimeType());
    blobEntry.setMetaName(request.getName());
    String imageName = PratilipiDocUtil.saveContentImage(request.pratilipiId, blobEntry);
    return new PostResponse(imageName);
}
Also used : BlobEntry(com.pratilipi.data.type.BlobEntry) Post(com.pratilipi.api.annotation.Post)

Example 5 with Post

use of com.pratilipi.api.annotation.Post in project pratilipi by Pratilipi.

the class PratilipiContentV1Api method post.

@Post
public GenericResponse post(PostRequest request) throws InvalidArgumentException, InsufficientAccessException, UnexpectedServerException {
    PratilipiDocUtil.saveContentPage(request.pratilipiId, request.chapterNo, request.chapterTitle, request.pageNo == null ? 1 : request.pageNo, request.content);
    Task task = TaskQueueFactory.newTask().setUrl("/pratilipi/process").addParam("pratilipiId", request.pratilipiId.toString()).addParam("processContentDoc", "true");
    TaskQueueFactory.getPratilipiTaskQueue().add(task);
    return new GenericResponse();
}
Also used : Task(com.pratilipi.taskqueue.Task) GenericResponse(com.pratilipi.api.shared.GenericResponse) Post(com.pratilipi.api.annotation.Post)

Aggregations

Post (com.pratilipi.api.annotation.Post)32 GenericResponse (com.pratilipi.api.shared.GenericResponse)22 Task (com.pratilipi.taskqueue.Task)15 DataAccessor (com.pratilipi.data.DataAccessor)6 UserData (com.pratilipi.data.client.UserData)6 Gson (com.google.gson.Gson)5 InvalidArgumentException (com.pratilipi.common.exception.InvalidArgumentException)5 BlobEntry (com.pratilipi.data.type.BlobEntry)5 InsufficientAccessException (com.pratilipi.common.exception.InsufficientAccessException)3 Author (com.pratilipi.data.type.Author)3 Page (com.pratilipi.data.type.Page)3 Pratilipi (com.pratilipi.data.type.Pratilipi)3 Date (java.util.Date)3 JsonObject (com.google.gson.JsonObject)2 GenericFileDownloadResponse (com.pratilipi.api.shared.GenericFileDownloadResponse)2 UnexpectedServerException (com.pratilipi.common.exception.UnexpectedServerException)2 AuthorData (com.pratilipi.data.client.AuthorData)2 UserAuthorData (com.pratilipi.data.client.UserAuthorData)2 AccessToken (com.pratilipi.data.type.AccessToken)2 ArrayList (java.util.ArrayList)2