001/*
002 * Copyright 2013 Box, Inc. All rights reserved.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.nuxeo.box.api.marshalling.dao;
017
018import com.fasterxml.jackson.annotation.JsonProperty;
019
020import java.util.Map;
021
022/**
023 * Version of a file.
024 */
025public class BoxLock extends BoxTypedObject {
026
027    public static final String FIELD_CREATED_BY = "created_by";
028
029    public static final String FIELD_FILE = "file";
030
031    public static final String FIELD_EXPIRES_AT = "expires_at";
032
033    public static final String FIELD_LOCK_TYPE = "lock_type";
034
035    public static final String FIELD_IS_DOWNLOAD_PREVENTED = "is_download_prevented";
036
037    public static final String FIELD_SERVICE_ACTION = "service_action";
038
039    /**
040     * Constructor.
041     */
042    public BoxLock() {
043        setType(BoxResourceType.LOCK.toString());
044    }
045
046    /**
047     * Copy constructor, this does deep copy for all the fields.
048     *
049     * @param obj
050     */
051    public BoxLock(BoxLock obj) {
052        super(obj);
053    }
054
055    /**
056     * Instantiate the object from a map. Each entry in the map reflects to a field.
057     *
058     * @param map
059     */
060    public BoxLock(Map<String, Object> map) {
061        super(map);
062    }
063
064    @JsonProperty(FIELD_CREATED_BY)
065    public BoxUser getCreatedBy() {
066        return (BoxUser) getValue(FIELD_CREATED_BY);
067    }
068
069    @JsonProperty(FIELD_CREATED_BY)
070    public void setCreatedBy(BoxUser createdBy) {
071        put(FIELD_CREATED_BY, createdBy);
072    }
073
074    @JsonProperty(FIELD_FILE)
075    public BoxItem getFile() {
076        return (BoxItem) getValue(FIELD_FILE);
077    }
078
079    @JsonProperty(FIELD_FILE)
080    public void setFile(BoxItem file) {
081        put(FIELD_FILE, file);
082    }
083
084    @JsonProperty(FIELD_EXPIRES_AT)
085    public String getExpiresAt() {
086        return (String) getValue(FIELD_EXPIRES_AT);
087    }
088
089    @JsonProperty(FIELD_EXPIRES_AT)
090    public void setExpiresAt(String expiresAt) {
091        put(FIELD_EXPIRES_AT, expiresAt);
092    }
093
094    @JsonProperty(FIELD_LOCK_TYPE)
095    public String getLockType() {
096        return (String) getValue(FIELD_LOCK_TYPE);
097    }
098
099    @JsonProperty(FIELD_LOCK_TYPE)
100    public void setLockType(String lockType) {
101        put(FIELD_LOCK_TYPE, lockType);
102    }
103
104    @JsonProperty(FIELD_IS_DOWNLOAD_PREVENTED)
105    public Boolean isDownloadPrevented() {
106        return (Boolean) getValue(FIELD_IS_DOWNLOAD_PREVENTED);
107    }
108
109    @JsonProperty(FIELD_IS_DOWNLOAD_PREVENTED)
110    public void setDownloadPrevented(Boolean lockType) {
111        put(FIELD_IS_DOWNLOAD_PREVENTED, lockType);
112    }
113
114    @JsonProperty(FIELD_SERVICE_ACTION)
115    public BoxServiceAction getServiceAction() {
116        return (BoxServiceAction) getValue(FIELD_SERVICE_ACTION);
117    }
118
119    @JsonProperty(FIELD_SERVICE_ACTION)
120    public void setServiceAction(BoxServiceAction serviceAction) {
121        put(FIELD_SERVICE_ACTION, serviceAction);
122    }
123
124}