re base code
[sdc.git] / catalog-dao / src / main / java / org / openecomp / sdc / be / resources / data / ESArtifactData.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.resources.data;
22
23 import com.datastax.driver.mapping.annotations.Column;
24 import com.datastax.driver.mapping.annotations.PartitionKey;
25 import com.datastax.driver.mapping.annotations.Table;
26
27 import java.nio.ByteBuffer;
28
29 @Table(keyspace = "sdcartifact", name = "resources")
30 public class ESArtifactData {
31         public static final String RRESOURCE_ID_FIELD = "resourceId";
32
33         public static final String SERVICE_NAME_FIELD = "serviceName";
34         public static final String SERVICE_VERSION_FIELD = "serviceVersion";
35         public static final String ARTIFACT_NAME_FIELD = "artifactName";
36
37         public final static String delim = ":";
38
39         @PartitionKey
40         @Column(name = "id")
41         private String id;
42
43         /*
44          * Base64 encoded Artifact file data
45          */
46
47         @Column
48         private ByteBuffer data;
49
50         // private byte[] data;
51
52         public ESArtifactData() {
53
54         }
55
56         public ESArtifactData(String id) {
57
58                 this.id = id;
59         }
60
61         public ESArtifactData(String artifactId, byte[] data) {
62                 super();
63                 this.id = artifactId;
64                 if (data != null) {
65                         this.data = ByteBuffer.wrap(data.clone());
66                         // this.data = data.clone();
67                 }
68
69         }
70
71         public byte[] getDataAsArray() {
72                 // return data;
73                 if (data != null) {
74                         return data.array();
75                 }
76                 return null;
77         }
78
79         public void setDataAsArray(byte[] data) {
80                 if (data != null) {
81                         // this.data = data.clone();
82                         this.data = ByteBuffer.wrap(data.clone());
83                 }
84         }
85
86         public ByteBuffer getData() {
87                 // return data;
88                 return data;
89         }
90
91         public void setData(ByteBuffer data) {
92                 if (data != null) {
93                         // this.data = data.clone();
94                         this.data = data.duplicate();
95                 }
96         }
97
98         public String getId() {
99                 return id;
100         }
101
102         public void setId(String id) {
103                 this.id = id;
104         }
105
106 }