Tabnine Logo
XWikiAttachmentStoreInterface.loadAttachmentContent
Code IndexAdd Tabnine to your IDE (free)

How to use
loadAttachmentContent
method
in
com.xpn.xwiki.store.XWikiAttachmentStoreInterface

Best Java code snippets using com.xpn.xwiki.store.XWikiAttachmentStoreInterface.loadAttachmentContent (Showing top 6 results out of 315)

origin: com.xpn.xwiki.platform/xwiki-core

public void loadContent(XWikiContext context) throws XWikiException
{
  if (this.attachment_content == null) {
    try {
      context.getWiki().getAttachmentStore().loadAttachmentContent(this, context, true);
    } catch (Exception ex) {
      LOG.warn(String.format("Failed to load content for attachment [%s@%s]. "
        + "This attachment is broken, please consider re-uploading it. " + "Internal error: %s",
        getFilename(), (this.doc != null) ? this.doc.getFullName() : "<unknown>", ex.getMessage()));
    }
  }
}
origin: phenotips/phenotips

@Override
public XWikiAttachment next()
{
  Object[] item = this.data.next();
  try {
    XWikiDocument doc =
      new XWikiDocument(HibernateAttachmentsReader.this.resolver.resolve(String.valueOf(item[0])));
    XWikiAttachment att = new XWikiAttachment(doc, String.valueOf(item[1]));
    HibernateAttachmentsReader.this.store.loadAttachmentContent(att,
      HibernateAttachmentsReader.this.context.get(), true);
    HibernateAttachmentsReader.this.archiveStore.loadArchive(att,
      HibernateAttachmentsReader.this.context.get(), true);
    HibernateAttachmentsReader.this.logger.debug("Loaded [{}] from the database", att.getReference());
    return att;
  } catch (Exception ex) {
    HibernateAttachmentsReader.this.logger.error("Failed to read attachment from the database store: {}",
      ex.getMessage(), ex);
  }
  return null;
}
origin: org.phenotips/storage-migrators-attachments-database

@Override
public XWikiAttachment next()
{
  Object[] item = this.data.next();
  try {
    XWikiDocument doc =
      new XWikiDocument(HibernateAttachmentsReader.this.resolver.resolve(String.valueOf(item[0])));
    XWikiAttachment att = new XWikiAttachment(doc, String.valueOf(item[1]));
    HibernateAttachmentsReader.this.store.loadAttachmentContent(att,
      HibernateAttachmentsReader.this.context.get(), true);
    HibernateAttachmentsReader.this.archiveStore.loadArchive(att,
      HibernateAttachmentsReader.this.context.get(), true);
    HibernateAttachmentsReader.this.logger.debug("Loaded [{}] from the database", att.getReference());
    return att;
  } catch (Exception ex) {
    HibernateAttachmentsReader.this.logger.error("Failed to read attachment from the database store: {}",
      ex.getMessage(), ex);
  }
  return null;
}
origin: phenotips/phenotips

  @Override
  public boolean storeEntity(XWikiAttachment entity)
  {
    if (entity == null) {
      return true;
    }
    XWikiAttachment existing =
      new XWikiAttachment(entity.getDoc(), entity.getFilename());
    try {
      this.store.loadAttachmentContent(existing, this.context.get(), false);
      // If loading succeeded, then the attachment already exists on the filesystem;
      // keep using the existing attachment version and discard the database one
      this.logger.debug("Skipped importing already existing attachment [{}]", entity.getReference());
      return true;
    } catch (XWikiException e) {
      // No such attachment on the filesystem, continue storing it
    }
    try {
      this.store.saveAttachmentContent(entity, false, this.context.get(), false);
      // The archive is also automatically stored by the call above, no need to explicitly store the archive
      this.logger.debug("Imported attachment [{}] into the filesystem store", entity.getReference());
      return true;
    } catch (XWikiException ex) {
      this.logger.error("Failed to store attachment into the filesystem store: {}", ex.getMessage(), ex);
      return false;
    }
  }
}
origin: org.phenotips/storage-migrators-attachments-filesystem

  @Override
  public boolean storeEntity(XWikiAttachment entity)
  {
    if (entity == null) {
      return true;
    }
    XWikiAttachment existing =
      new XWikiAttachment(entity.getDoc(), entity.getFilename());
    try {
      this.store.loadAttachmentContent(existing, this.context.get(), false);
      // If loading succeeded, then the attachment already exists on the filesystem;
      // keep using the existing attachment version and discard the database one
      this.logger.debug("Skipped importing already existing attachment [{}]", entity.getReference());
      return true;
    } catch (XWikiException e) {
      // No such attachment on the filesystem, continue storing it
    }
    try {
      this.store.saveAttachmentContent(entity, false, this.context.get(), false);
      // The archive is also automatically stored by the call above, no need to explicitly store the archive
      this.logger.debug("Imported attachment [{}] into the filesystem store", entity.getReference());
      return true;
    } catch (XWikiException ex) {
      this.logger.error("Failed to store attachment into the filesystem store: {}", ex.getMessage(), ex);
      return false;
    }
  }
}
origin: com.xpn.xwiki.platform/xwiki-core

public void loadAttachmentContent(XWikiAttachment attachment, XWikiContext context) throws XWikiException
{
  String database = context.getDatabase();
  try {
    // We might need to switch database to
    // get the translated content
    if (getDatabase() != null) {
      context.setDatabase(getDatabase());
    }
    context.getWiki().getAttachmentStore().loadAttachmentContent(attachment, context, true);
  } finally {
    if (database != null) {
      context.setDatabase(database);
    }
  }
}
com.xpn.xwiki.storeXWikiAttachmentStoreInterfaceloadAttachmentContent

Popular methods of XWikiAttachmentStoreInterface

  • saveAttachmentContent
  • deleteXWikiAttachment
  • saveAttachmentsContent

Popular in Java

  • Making http requests using okhttp
  • runOnUiThread (Activity)
  • getResourceAsStream (ClassLoader)
  • onCreateOptionsMenu (Activity)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now