Adds the cp attachment file entry to the database. Also notifies the appropriate model listeners.

@param cpAttachmentFileEntry the cp attachment file entry
@return the cp attachment file entry that was added
160035
public static com.liferay.commerce.product.model.CPAttachmentFileEntry addCPAttachmentFileEntry(
		com.liferay.commerce.product.model.CPAttachmentFileEntry cpAttachmentFileEntry) {
		return getService().addCPAttachmentFileEntry(cpAttachmentFileEntry);
	}
26188
def action_add(self):
        

        form = self.request.form
        parent = api.get_parent(self.context)
        attachment_file = form.get('AttachmentFile_file', None)
        AttachmentType = form.get('AttachmentType', '')
        AttachmentKeys = form.get('AttachmentKeys', '')
        ReportOption = form.get('ReportOption', 'r')

        # nothing to do if the attachment file is missing
        if attachment_file is None:
            logger.warn("AttachmentView.action_add_attachment: Attachment file is missing")
            return

        # create attachment
        attachment = self.create_attachment(
            parent,
            attachment_file,
            AttachmentType=AttachmentType,
            AttachmentKeys=AttachmentKeys,
            ReportOption=ReportOption)

        # append the new UID to the end of the current order
        self.set_attachments_order(api.get_uid(attachment))

        # handle analysis attachment
        analysis_uid = form.get("Analysis", None)
        if analysis_uid:
            analysis = api.get_object_by_uid(analysis_uid)
            others = analysis.getAttachment()
            attachments = []
            for other in others:
                attachments.append(other.UID())
            attachments.append(attachment.UID())
            analysis.setAttachment(attachments)
            # The metadata for getAttachmentUIDs need to get updated,
            # otherwise the attachments are not displayed
            # https://github.com/senaite/bika.lims/issues/521
            analysis.reindexObject()

        else:
            others = self.context.getAttachment()
            attachments = []
            for other in others:
                attachments.append(other.UID())
            attachments.append(attachment.UID())

            self.context.setAttachment(attachments)

        if self.request['HTTP_REFERER'].endswith('manage_results'):
            self.request.response.redirect('{}/manage_results'.format(
                self.context.absolute_url()))
        else:
            self.request.response.redirect(self.context.absolute_url())
1122009
@Override
    public CFolderContent listFolder( final CPath cpath )
            throws CStorageException
    {
        CMFolder cmRoot = loadFoldersStructure();
        CMFolder cmFolder = cmRoot.getFolder( cpath );

        if ( cmFolder == null ) {

            CMFolder cmParentFolder = cmRoot.getFolder( cpath.getParent() );

            if ( cmParentFolder != null ) {
                CMBlob cmBlob;

                try {
                    cmBlob = getBlobByName( cmParentFolder, cpath.getBaseName() );
                } catch ( ParseException e ) {
                    throw new CStorageException( "Can't parse blob at " + cpath, e );
                }

                if ( cmBlob != null ) {
                    throw new CInvalidFileTypeException( cpath, false );
                }
            }

            return null;
        }

        List<CMBlob> cmBlobs = null;

        try {
            cmBlobs = listBlobs( cmFolder );
        } catch ( ParseException e ) {
            throw new CStorageException( e.getMessage(), e );
        }

        Map<CPath, CFile> map = new HashMap<CPath, CFile>();

        // Adding folders
        for ( CMFolder childFolder : cmFolder ) {
            CFile cFile = childFolder.toCFolder();
            map.put( cFile.getPath(), cFile );
        }

        // Adding blobs
        for ( CMBlob cmBLob : cmBlobs ) {
            CBlob cBlob = cmBLob.toCBlob();
            map.put( cBlob.getPath(), cBlob );
        }

        return new CFolderContent( map );
    }
604066
def addattachment(self, page, filename):
    """"""
    mime_type = mimetypes.guess_type(filename, strict=False)[0]
    if not mime_type:
      raise ConfluenceError('Failed to detect MIME type of %s' % filename)

    try:
      with open(filename, 'rb') as f:
        file_data = f.read()

      attachment = dict(fileName=basename(filename), contentType=mime_type)
      return self._api_entrypoint.addAttachment(self._session_token,
                                                page['id'],
                                                attachment,
                                                Binary(file_data))
    except (IOError, OSError) as e:
      log.error('Failed to read data from file %s: %s' % (filename, str(e)))
      return None
    except XMLRPCError:
      log.error('Failed to add file attachment %s to page: %s' %
          (filename, page.get('title', '[unknown title]')))
      return None
173197
public void addAttachment(final String name, final DataSource filedata) {
		attachments.add(new AttachmentResource(name, filedata));
	}
388212
public E attachment(File attachment, String name) {
        addBinaryAttachment(attachment, name);
        return getThis();
    }
547825
public AbstractSheet<TRow, TColumn, TCell> setEffectiveAttachmentOptions(EnumSet<AttachmentType> effectiveAttachmentOptions) {
        this.effectiveAttachmentOptions = effectiveAttachmentOptions;
        return this;
    }
856830
public static boolean validateAttachment(Attachment currentAttachment) {
		try {
			currentAttachment.getId();

			if (currentAttachment.getAlternateId() == "null" || currentAttachment.getAlternateId().isEmpty()) {
				return false;
			}
			if (currentAttachment.getCapGroupName() == "null" || currentAttachment.getCapGroupName().isEmpty()) {
				return false;
			}
			if (currentAttachment.getCapGroupSMILES() == "null" || currentAttachment.getCapGroupSMILES().isEmpty()) {
				return false;
			}
			if (currentAttachment.getLabel().equals("null") || currentAttachment.getLabel().equals(" ")) {
				return false;
			}
		} catch (Exception e) {
			return false;
		}
		return true;
	}
1301971
@SuppressWarnings("unchecked")
  public <S> S getAttachment(String name) {
    return (S) attachments.get(name);
  }
585355
public Attachment attachFile(long objectId, InputStream inputStream, String contentType, long contentLength, String fileName) {
        throw new UnsupportedOperationException("Attachments can only be attached to comments, not discussions.");
    }
689228
public GitlabHTTPRequestor withAttachment(String key, File file) {
        if (file != null && key != null) {
            attachments.put(key, file);
        }
        return this;
    }
1115017
def addAttachment(self, title, attachment):
        
        self._attachments[title] = attachment
        self.resizeToContents()
771223
def addAttachment(self, filepath):
        

        proj_id = self.contextId

        fa = self.rtc_obj.getFiledAgainst(self.filedAgainst,
                                          projectarea_id=proj_id)
        fa_id = fa.url.split("/")[-1]

        headers = copy.deepcopy(self.rtc_obj.headers)
        if headers.__contains__("Content-Type"):
            headers.__delitem__("Content-Type")

        filename = os.path.basename(filepath)
        fileh = open(filepath, "rb")
        files = {"attach": (filename, fileh, "application/octet-stream")}

        params = {"projectId": proj_id,
                  "multiple": "true",
                  "category": fa_id}
        req_url = "".join([self.rtc_obj.url,
                           "/service/com.ibm.team.workitem.service.",
                           "internal.rest.IAttachmentRestService/"])
        resp = self.post(req_url,
                         verify=False,
                         headers=headers,
                         proxies=self.rtc_obj.proxies,
                         params=params,
                         files=files)
        raw_data = xmltodict.parse(resp.content)
        json_body = json.loads(raw_data["html"]["body"]["textarea"])
        attachment_info = json_body["files"][0]
        return self._add_attachment_link(attachment_info)
1177817
@Override
	public com.liferay.commerce.model.CPDAvailabilityEstimate addCPDAvailabilityEstimate(
		com.liferay.commerce.model.CPDAvailabilityEstimate cpdAvailabilityEstimate) {
		return _cpdAvailabilityEstimateLocalService.addCPDAvailabilityEstimate(cpdAvailabilityEstimate);
	}
180167
@Override
	public com.liferay.commerce.product.model.CPOptionValue addCPOptionValue(
		com.liferay.commerce.product.model.CPOptionValue cpOptionValue) {
		return _cpOptionValueLocalService.addCPOptionValue(cpOptionValue);
	}
770988
@Override
	public void clearCache(CPAttachmentFileEntry cpAttachmentFileEntry) {
		entityCache.removeResult(CPAttachmentFileEntryModelImpl.ENTITY_CACHE_ENABLED,
			CPAttachmentFileEntryImpl.class,
			cpAttachmentFileEntry.getPrimaryKey());

		finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
		finderCache.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);

		clearUniqueFindersCache((CPAttachmentFileEntryModelImpl)cpAttachmentFileEntry,
			true);
	}
1252981
public void addAttachment(final DataHandler handler, final String filename)
		throws MessagingException
	{
		final BodyPart part = new MimeBodyPart();
		part.setFileName(filename);
		part.setDataHandler(handler);
		addAttachment(part);
	}