예제 #1
0
    public int compare(Template o1, Template o2) {
      try {
        Identifier id1 = APILocator.getIdentifierAPI().find(o1.getIdentifier());
        if (id1.getHostId() == null) id1 = null;
        Identifier id2 = APILocator.getIdentifierAPI().find(o2.getIdentifier());
        if (id2.getHostId() == null) id2 = null;
        if (id1 != null
            && id2 != null
            && id1.getHostId().equals(baseHostId)
            && id2.getHostId().equals(baseHostId)) {
          return o1.getTitle().compareTo(o2.getTitle());
        }
        if (id1 != null && id1.getHostId().equals(baseHostId)) {
          return -1;
        }
        if (id2 != null && id2.getHostId().equals(baseHostId)) {
          return 1;
        }
        return id1 == null || id2 == null || id1.getHostId().equals(id2.getHostId())
            ? o1.getTitle().compareTo(o2.getTitle())
            : id1.getHostId().compareTo(id2.getHostId());

      } catch (DotDataException e) {

      }
      return 0;
    }
예제 #2
0
  /**
   * This method will save the newFile as the new working version for the given identifier and data
   * if the given file is new it will copy the permissions from the folder and if the file given is
   * set to live = true it will publish it
   *
   * @param newFile New File to save
   * @param data New data to store
   * @param folder Parent folder to be assigned to the new file
   * @param identifier Identifier of the asset
   * @param user User how is making the modification if null no user id will be set as the last
   *     modified user
   * @return
   * @throws Exception
   */
  public File getWorkingFileByFileName(String fileName, Folder folder) throws DotDataException {

    Identifier id = APILocator.getIdentifierAPI().find(folder);

    HibernateUtil hu = new HibernateUtil(File.class);
    hu.setSQLQuery(workingFileByName);
    hu.setParam(id.getPath());
    hu.setParam(id.getHostId());
    hu.setParam(fileName);

    return (File) hu.load();
  }