BinaryConsoleItem.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.protocol.sdk.properties;

  21. import java.io.ByteArrayOutputStream;

  22. import org.openspcoop2.protocol.sdk.ProtocolException;
  23. import org.openspcoop2.protocol.sdk.constants.ConsoleItemType;

  24. /**
  25.  * BinaryConsoleItem
  26.  *
  27.  * @author Poli Andrea (apoli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public class BinaryConsoleItem extends AbstractConsoleItem<byte[]> {
  32.    
  33.     private String fileName = null;
  34.     private String fileId = null;
  35.     private boolean readOnly = false; // vale solo in change
  36.     private boolean showContent = true; // vale solo in change
  37.     private String noteUpdate = null;
  38.     private boolean lock = false;

  39.     protected BinaryConsoleItem(String id, String label, ConsoleItemType type) throws ProtocolException {
  40.         this(id, label, type, null, null);
  41.     }
  42.    
  43.     protected BinaryConsoleItem(String id, String label, ConsoleItemType type, String fileName, String fileId) throws ProtocolException {
  44.         super(id, label, type);
  45.         this.fileName = fileName;
  46.         this.fileId = fileId;
  47.     }

  48.     public String getFileName() {
  49.         return this.fileName;
  50.     }

  51.     public void setFileName(String fileName) {
  52.         this.fileName = fileName;
  53.     }

  54.     public String getFileId() {
  55.         return this.fileId;
  56.     }

  57.     public void setFileId(String fileId) {
  58.         this.fileId = fileId;
  59.     }
  60.    
  61.     public boolean isReadOnly() {
  62.         return this.readOnly;
  63.     }

  64.     public void setReadOnly(boolean readOnly) {
  65.         this.readOnly = readOnly;
  66.     }
  67.    
  68.     public boolean isShowContent() {
  69.         return this.showContent;
  70.     }

  71.     public void setShowContent(boolean showContent) {
  72.         this.showContent = showContent;
  73.     }

  74.     public String getNoteUpdate() {
  75.         return this.noteUpdate;
  76.     }

  77.     public void setNoteUpdate(String noteUpdate) {
  78.         this.noteUpdate = noteUpdate;
  79.     }

  80.     public void setLock(boolean lock) {
  81.         this.lock = lock;
  82.     }
  83.    
  84.     @Override
  85.     public boolean isLockedType() {
  86.         return this.lock;
  87.     }
  88.    
  89.     @Override
  90.     protected byte[] cloneValue(byte[] value) throws ProtocolException {
  91.         try {
  92.             ByteArrayOutputStream bout = new ByteArrayOutputStream();
  93.             bout.write(value);
  94.             bout.flush();
  95.             bout.close();
  96.             return bout.toByteArray();
  97.         }catch(Exception e) {
  98.             throw new ProtocolException(e.getMessage(),e);
  99.         }
  100.     }

  101. }