public Entry updateOrCreateSource(User user,String id,String url,String title,Long modTime,Long createTime,boolean isAdmin,Errors errors){
  if (user == null) {
    Errors.add(errors,errorMessages.errorUserIsNull());
    return null;
  }
  if (url == null) {
    Errors.add(errors,errorMessages.errorUrlIsNull());
    return null;
  }
  Entry source=getEntryByUserIdAndUrl(user.getId(),url);
  if (source == null) {
    if (url.isEmpty()) {
      Errors.add(errors,errorMessages.errorUrlIsEmpty());
      return null;
    }
    if (title == null) {
      Errors.add(errors,errorMessages.errorTitleIsNull());
      return null;
    }
    if (title.isEmpty()) {
      Errors.add(errors,errorMessages.errorTitleIsEmpty());
      return null;
    }
    if (modTime == null) {
      Errors.add(errors,errorMessages.errorModTimeIsNull());
      return null;
    }
    if (createTime == null) {
      Errors.add(errors,errorMessages.errorCreateTimeIsNull());
      return null;
    }
    if (id != null && !idGenerator.isIdWellFormed(id)) {
      Errors.add(errors,errorMessages.errorIdIsInvalid());
      return null;
    }
    if (createTime.longValue() > modTime.longValue()) {
      modTime=createTime;
    }
    if (url != null) {
      url=cleanUpText(url);
    }
    if (title != null) {
      title=cleanUpText(title);
    }
    source=new Entry();
    source.setDb(db);
    if (id == null) {
      id=idGenerator.getAnotherId();
    }
    source.setId(id);
    source.setSourceUrl(url);
    source.setSourceTitle(title);
    source.setCreateTime(createTime);
    source.setType(Constants.source);
    source.setUserId(user.getId());
    db.persistEntry(source);
  }
 else   if (!canUserModifyEntry(user,source,isAdmin)) {
    Errors.add(errors,errorMessages.errorUserIsNotEntitledToModifyTheSource());
    return null;
  }
  source.setModTime(modTime);
  return source;
}

public Entry updateOrCreateSource ( User user , String id , String url , String title , Long modTime , Long createTime , boolean isAdmin , Errors errors ) { if ( user == null ) { Errors . add ( errors , errorMessages . errorUserIsNull ( ) ) ; return null ; } if ( url == null ) { Errors . add ( errors , errorMessages . errorUrlIsNull ( ) ) ; return null ; } Entry source = getEntryByUserIdAndUrl ( user . getId ( ) , url ) ; if ( source == null ) { if ( url . isEmpty ( ) ) { Errors . add ( errors , errorMessages . errorUrlIsEmpty ( ) ) ; return null ; } if ( title == null ) { Errors . add ( errors , errorMessages . errorTitleIsNull ( ) ) ; return null ; } if ( title . isEmpty ( ) ) { Errors . add ( errors , errorMessages . errorTitleIsEmpty ( ) ) ; return null ; } if ( modTime == null ) { Errors . add ( errors , errorMessages . errorModTimeIsNull ( ) ) ; return null ; } if ( createTime == null ) { Errors . add ( errors , errorMessages . errorCreateTimeIsNull ( ) ) ; return null ; } if ( id != null && ! idGenerator . isIdWellFormed ( id ) ) { Errors . add ( errors , errorMessages . errorIdIsInvalid ( ) ) ; return null ; } if ( createTime . longValue ( ) > modTime . longValue ( ) ) { modTime = createTime ; } if ( url != null ) { url = cleanUpText ( url ) ; } if ( title != null ) { title = cleanUpText ( title ) ; } source = new Entry ( ) ; source . setDb ( db ) ; if ( id == null ) { id = idGenerator . getAnotherId ( ) ; } source . setId ( id ) ; source . setSourceUrl ( url ) ; source . setSourceTitle ( title ) ; source . setCreateTime ( createTime ) ; source . setType ( Constants . source ) ; source . setUserId ( user . getId ( ) ) ; db . persistEntry ( source ) ; } else if ( ! canUserModifyEntry ( user , source , isAdmin ) ) { Errors . add ( errors , errorMessages . errorUserIsNotEntitledToModifyTheSource ( ) ) ; return null ; } source . setModTime ( modTime ) ; return source ; }
api method . returns an entry for the source indexed by the user and the url . this method creates it if it didn ' t already exist .
