Package info.bliki.api.creator

Examples of info.bliki.api.creator.ImageData


  }

  public void appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat) {
    try {
      String imageName = imageFormat.getFilename();
      ImageData imageData = fWikiDB.selectImage(imageName);
      if (imageData != null) {
        File file = new File(imageData.getFilename());
        if (file.exists()) {
          super.appendInternalImageLink(hrefImageLink, "file:///" + imageData.getFilename(), imageFormat);
          return;
        }
      }
      String imageNamespace = getImageNamespace();
      String[] listOfTitleStrings = { imageNamespace + ":" + imageName };
      fUser.login();
      List<Page> listOfPages;
      if (imageFormat.getWidth() > 0) {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings, imageFormat.getWidth());
      } else {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings);
      }
      for (Page page : listOfPages) {

        imageData = new ImageData(imageName);

        // download the image to fImageDirectoryName directory
        FileOutputStream os = null;
        try {
          String imageUrl;
          if (imageFormat.getWidth() > 0) {
            imageUrl = page.getImageThumbUrl();
          } else {
            imageUrl = page.getImageUrl();
          }
          String urlImageName = page.getTitle().substring(imageNamespace.length() + 1).replace(' ', '_');
          if (imageUrl!=null) {
            int index = imageUrl.lastIndexOf('/');
            if (index>0) {
              urlImageName = imageUrl.substring(index+1);
            }
          }
          String filename = fImageDirectoryName + urlImageName;
          os = new FileOutputStream(filename);
          page.downloadImageUrl(os, imageUrl);
          imageData.setUrl(imageUrl);
          imageData.setFilename(filename);
          fWikiDB.insertImage(imageData);
          super.appendInternalImageLink(hrefImageLink, "file:///" + filename, imageFormat);
          return;
        } catch (FileNotFoundException e) {
          e.printStackTrace();
View Full Code Here


  }

  public void appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat) {
    try {
      String imageName = imageFormat.getFilename();
      ImageData imageData = fWikiDB.selectImage(imageName);
      if (imageData != null) {
        File file = new File(imageData.getFilename());
        if (file.exists()) {
          super.appendInternalImageLink(hrefImageLink, "file:///" + imageData.getFilename(), imageFormat);
          return;
        }
      }
      String imageNamespace = getImageNamespace();
      String[] listOfTitleStrings = { imageNamespace + ":" + imageName };
      fUser.login();
      List<Page> listOfPages;
      if (imageFormat.getWidth() > 0) {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings, imageFormat.getWidth());
      } else {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings);
      }
      for (Page page : listOfPages) {

        imageData = new ImageData(imageName);

        // download the image to fImageDirectoryName directory
        FileOutputStream os = null;
        try {
          String imageUrl;
          if (imageFormat.getWidth() > 0) {
            imageUrl = page.getImageThumbUrl();
          } else {
            imageUrl = page.getImageUrl();
          }
          String urlImageName = page.getTitle().substring(imageNamespace.length() + 1).replaceAll(" ", "_");
          if (imageUrl!=null) {
            int index = imageUrl.lastIndexOf('/');
            if (index>0) {
              urlImageName = imageUrl.substring(index+1);
            }
          }
          String filename = fImageDirectoryName + urlImageName;
          os = new FileOutputStream(filename);
          page.downloadImageUrl(os, imageUrl);
          imageData.setUrl(imageUrl);
          imageData.setFilename(filename);
          fWikiDB.insertImage(imageData);
          super.appendInternalImageLink(hrefImageLink, "file:///" + filename, imageFormat);
          return;
        } catch (FileNotFoundException e) {
          e.printStackTrace();
View Full Code Here

  }

  public void appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat) {
    try {
      String imageName = imageFormat.getFilename();
      ImageData imageData = fWikiDB.selectImage(imageName);
      if (imageData != null) {
        File file = new File(imageData.getFilename());
        if (file.exists()) {
          super.appendInternalImageLink(hrefImageLink, "file:///" + imageData.getFilename(), imageFormat);
          return;
        }
      }
      String imageNamespace = getImageNamespace();
      String[] listOfTitleStrings = { imageNamespace + ":" + imageName };
      fUser.login();
      List<Page> listOfPages;
      if (imageFormat.getWidth() > 0) {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings, imageFormat.getWidth());
      } else {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings);
      }
      for (Page page : listOfPages) {

        imageData = new ImageData(imageName);

        // download the image to fImageDirectoryName directory
        FileOutputStream os = null;
        try {
          String imageUrl;
          if (imageFormat.getWidth() > 0) {
            imageUrl = page.getImageThumbUrl();
          } else {
            imageUrl = page.getImageUrl();
          }
          String urlImageName = page.getTitle().substring(imageNamespace.length() + 1).replace(' ', '_');
          if (imageUrl != null) {
            int index = imageUrl.lastIndexOf('/');
            if (index > 0) {
              urlImageName = imageUrl.substring(index + 1);
            }
          }
          if (fImageDirectoryName != null) {
            String filename = fImageDirectoryName + urlImageName;
            os = new FileOutputStream(filename);
            page.downloadImageUrl(os, imageUrl);
            imageData.setUrl(imageUrl);
            imageData.setFilename(filename);
            fWikiDB.insertImage(imageData);
            super.appendInternalImageLink(hrefImageLink, "file:///" + filename, imageFormat);
          }
          return;
        } catch (FileNotFoundException e) {
View Full Code Here

  }

  public void appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat) {
    try {
      String imageName = imageFormat.getFilename();
      ImageData imageData = fWikiDB.selectImage(imageName);
      if (imageData != null) {
        File file = new File(imageData.getFilename());
        if (file.exists()) {
          super.appendInternalImageLink(hrefImageLink, "file:///" + imageData.getFilename(), imageFormat);
          return;
        }
      }
      String imageNamespace = getImageNamespace();
      setDefaultThumbWidth(imageFormat);
      String[] listOfTitleStrings = { imageNamespace + ":" + imageName };
      fUser.login();
      List<Page> listOfPages;
      if (imageFormat.getWidth() > 0) {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings, imageFormat.getWidth());
      } else {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings);
      }
      if (listOfPages.size() > 0) {
        Page page = listOfPages.get(0);
        imageData = new ImageData(imageName);

        // download the image to fImageDirectoryName directory
        FileOutputStream os = null;
        try {
          String imageUrl;
          if (imageFormat.getWidth() > 0) {
            imageUrl = page.getImageThumbUrl();
          } else {
            imageUrl = page.getImageUrl();
          }

          String urlImageName = Encoder.encodeTitleLocalUrl(page.getTitle());
          if (imageUrl != null) {
            int index = imageUrl.lastIndexOf('/');
            if (index > 0) {
              urlImageName = Encoder.encodeTitleLocalUrl(imageUrl.substring(index + 1));
            }
          }
          if (fImageDirectoryName != null) {
            String filename = fImageDirectoryName + urlImageName;
            os = new FileOutputStream(filename);
            page.downloadImageUrl(os, imageUrl);
            imageData.setUrl(imageUrl);
            imageData.setFilename(filename);
            fWikiDB.insertImage(imageData);
            super.appendInternalImageLink(hrefImageLink, "file:///" + filename, imageFormat);
          }
          return;
        } catch (FileNotFoundException e) {
View Full Code Here

  }

  public void appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat) {
    try {
      String imageName = imageFormat.getFilename();
      ImageData imageData = fWikiDB.selectImage(imageName);
      if (imageData != null) {
        File file = new File(imageData.getFilename());
        if (file.exists()) {
          super.appendInternalImageLink(hrefImageLink, "file:///" + imageData.getFilename(), imageFormat);
          return;
        }
      }
      String imageNameURL = Encoder.encodeTitleLocalUrl(imageName);
      super.appendInternalImageLink(hrefImageLink, "file:///" + fImageDirectoryName + imageNameURL, imageFormat);
View Full Code Here

  }

  public void appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat) {
    try {
      String imageName = imageFormat.getFilename();
      ImageData imageData = fWikiDB.selectImage(imageName);
      if (imageData != null) {
        File file = new File(imageData.getFilename());
        if (file.exists()) {
          super.appendInternalImageLink(hrefImageLink, "file:///" + imageData.getFilename(), imageFormat);
          return;
        }
      }
      String imageNameURL = Encoder.encodeTitleLocalUrl(imageName);
      super.appendInternalImageLink(hrefImageLink, "file:///" + fImageDirectoryName + imageNameURL, imageFormat);
View Full Code Here

  }

  public void appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat) {
    try {
      String imageName = imageFormat.getFilename();
      ImageData imageData = fWikiDB.selectImage(imageName);
      if (imageData != null) {
        File file = new File(imageData.getFilename());
        if (file.exists()) {
          super.appendInternalImageLink(hrefImageLink, "file:///" + imageData.getFilename(), imageFormat);
          return;
        }
      }
      String imageNamespace = getImageNamespace();
      setDefaultThumbWidth(imageFormat);
      String[] listOfTitleStrings = { imageNamespace + ":" + imageName };
      fUser.login();
      List<Page> listOfPages;
      if (imageFormat.getWidth() > 0) {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings, imageFormat.getWidth());
      } else {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings);
      }
      if (listOfPages.size() > 0) {
        Page page = listOfPages.get(0);
        imageData = new ImageData(imageName);

        // download the image to fImageDirectoryName directory
        FileOutputStream os = null;
        try {
          String imageUrl;
          if (imageFormat.getWidth() > 0) {
            imageUrl = page.getImageThumbUrl();
          } else {
            imageUrl = page.getImageUrl();
          }

          String urlImageName = Encoder.encodeTitleLocalUrl(page.getTitle());
          if (imageUrl != null) {
            int index = imageUrl.lastIndexOf('/');
            if (index > 0) {
              urlImageName = Encoder.encodeTitleLocalUrl(imageUrl.substring(index + 1));
            }
          }
          if (fImageDirectoryName != null) {
            String filename = fImageDirectoryName + urlImageName;
            File file = new File(filename);
            if (!file.exists()) {
              // if the file doesn't exist try to download from Wikipedia
              os = new FileOutputStream(filename);
              page.downloadImageUrl(os, imageUrl);
            }
            imageData.setUrl(imageUrl);
            imageData.setFilename(filename);
            fWikiDB.insertImage(imageData);
            super.appendInternalImageLink(hrefImageLink, "file:///" + filename, imageFormat);
          }
          return;
        } catch (FileNotFoundException e) {
View Full Code Here

  }

  public void appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat) {
    try {
      String imageName = imageFormat.getFilename();
      ImageData imageData = fWikiDB.selectImage(imageName);
      if (imageData != null) {
        File file = new File(imageData.getFilename());
        if (file.exists()) {
          super.appendInternalImageLink(hrefImageLink, "file:///" + imageData.getFilename(), imageFormat);
          return;
        }
      }
      String imageNamespace = getImageNamespace();
      String[] listOfTitleStrings = { imageNamespace + ":" + imageName };
      fUser.login();
      List<Page> listOfPages;
      if (imageFormat.getWidth() > 0) {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings, imageFormat.getWidth());
      } else {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings);
      }
      for (Page page : listOfPages) {

        imageData = new ImageData(imageName);

        // download the image to fImageDirectoryName directory
        FileOutputStream os = null;
        try {
          String imageUrl;
          if (imageFormat.getWidth() > 0) {
            imageUrl = page.getImageThumbUrl();
          } else {
            imageUrl = page.getImageUrl();
          }
          String urlImageName = page.getTitle().substring(imageNamespace.length() + 1).replace(' ', '_');
          if (imageUrl != null) {
            int index = imageUrl.lastIndexOf('/');
            if (index > 0) {
              urlImageName = imageUrl.substring(index + 1);
            }
          }
          if (fImageDirectoryName != null) {
            String filename = fImageDirectoryName + urlImageName;
            os = new FileOutputStream(filename);
            page.downloadImageUrl(os, imageUrl);
            imageData.setUrl(imageUrl);
            imageData.setFilename(filename);
            fWikiDB.insertImage(imageData);
            super.appendInternalImageLink(hrefImageLink, "file:///" + filename, imageFormat);
          }
          return;
        } catch (FileNotFoundException e) {
View Full Code Here

  }

  public void appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat) {
    try {
      String imageName = imageFormat.getFilename();
      ImageData imageData = fWikiDB.selectImage(imageName);
      if (imageData != null) {
        File file = new File(imageData.getFilename());
        if (file.exists()) {
          super.appendInternalImageLink(hrefImageLink, "file:///" + imageData.getFilename(), imageFormat);
          return;
        }
      }
      String imageNamespace = getImageNamespace();
      String[] listOfTitleStrings = { imageNamespace + ":" + imageName };
      fUser.login();
      List<Page> listOfPages;
      if (imageFormat.getSize() > 0) {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings, imageFormat.getSize());
      } else {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings);
      }
      for (Page page : listOfPages) {

        imageData = new ImageData(imageName);

        // download the image to fImageDirectoryName directory
        FileOutputStream os = null;
        try {
          String imageUrl;
          if (imageFormat.getSize() > 0) {
            imageUrl = page.getImageThumbUrl();
          } else {
            imageUrl = page.getImageUrl();
          }
          String urlImageName = page.getTitle().substring(imageNamespace.length() + 1).replaceAll(" ", "_");
          if (imageUrl!=null) {
            int index = imageUrl.lastIndexOf('/');
            if (index>0) {
              urlImageName = imageUrl.substring(index+1);
            }
          }
          String filename = fImageDirectoryName + urlImageName;
          os = new FileOutputStream(filename);
          page.downloadImageUrl(os, imageUrl);
          imageData.setUrl(imageUrl);
          imageData.setFilename(filename);
          fWikiDB.insertImage(imageData);
          super.appendInternalImageLink(hrefImageLink, "file:///" + filename, imageFormat);
          return;
        } catch (FileNotFoundException e) {
          e.printStackTrace();
View Full Code Here

  }

  public void appendInternalImageLink(String hrefImageLink, String srcImageLink, ImageFormat imageFormat) {
    try {
      String imageName = imageFormat.getFilename();
      ImageData imageData = fWikiDB.selectImage(imageName);
      if (imageData != null) {
        File file = new File(imageData.getFilename());
        if (file.exists()) {
          super.appendInternalImageLink(hrefImageLink, "file:///" + imageData.getFilename(), imageFormat);
          return;
        }
      }
      String imageNamespace = getImageNamespace();
      String[] listOfTitleStrings = { imageNamespace + ":" + imageName };
      fUser.login();
      List<Page> listOfPages;
      if (imageFormat.getWidth() > 0) {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings, imageFormat.getWidth());
      } else {
        listOfPages = fUser.queryImageinfo(listOfTitleStrings);
      }
      for (Page page : listOfPages) {

        imageData = new ImageData(imageName);

        // download the image to fImageDirectoryName directory
        FileOutputStream os = null;
        try {
          String imageUrl;
          if (imageFormat.getWidth() > 0) {
            imageUrl = page.getImageThumbUrl();
          } else {
            imageUrl = page.getImageUrl();
          }
          String urlImageName = page.getTitle().substring(imageNamespace.length() + 1).replace(' ', '_');
          if (imageUrl != null) {
            int index = imageUrl.lastIndexOf('/');
            if (index > 0) {
              urlImageName = imageUrl.substring(index + 1);
            }
          }
          String filename = fImageDirectoryName + urlImageName;
          os = new FileOutputStream(filename);
          page.downloadImageUrl(os, imageUrl);
          imageData.setUrl(imageUrl);
          imageData.setFilename(filename);
          fWikiDB.insertImage(imageData);
          super.appendInternalImageLink(hrefImageLink, "file:///" + filename, imageFormat);
          return;
        } catch (FileNotFoundException e) {
          e.printStackTrace();
View Full Code Here

TOP

Related Classes of info.bliki.api.creator.ImageData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.