当前位置: 首页>>代码示例>>Java>>正文


Java PersistenceException类代码示例

本文整理汇总了Java中blackboard.persist.PersistenceException的典型用法代码示例。如果您正苦于以下问题:Java PersistenceException类的具体用法?Java PersistenceException怎么用?Java PersistenceException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PersistenceException类属于blackboard.persist包,在下文中一共展示了PersistenceException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showConfigSettings

import blackboard.persist.PersistenceException; //导入依赖的package包/类
/**
    * Show /admin/config.jsp page.
    */
   private void showConfigSettings(HttpServletRequest request, HttpServletResponse response)
    throws InitializationException, BbServiceException, PersistenceException, IOException, ServletException {

// Get the LAMS2 Building Block properties from Blackboard (if set)
Properties properties = LamsPluginUtil.getProperties();

String lamsServerUrl = properties.getProperty(LamsPluginUtil.PROP_LAMS_URL, "http://");
request.setAttribute("lamsServerUrl", lamsServerUrl);

String lamsServerId = properties.getProperty(LamsPluginUtil.PROP_LAMS_SERVER_ID, "");
request.setAttribute("lamsServerId", lamsServerId);

String secretKey = properties.getProperty(LamsPluginUtil.PROP_LAMS_SECRET_KEY, "");
request.setAttribute("secretKey", secretKey);

String lamsServerTimeRefreshInterval = properties.getProperty(LamsPluginUtil.PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL);
request.setAttribute("lamsServerTimeRefreshInterval", lamsServerTimeRefreshInterval);

request.getRequestDispatcher("/admin/config.jsp").forward(request, response);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:ConfigServlet.java

示例2: saveConfigSettings

import blackboard.persist.PersistenceException; //导入依赖的package包/类
/**
    * Saves modified configuration settings.
    */
   private void saveConfigSettings(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException, PersistenceException, ParseException, ValidationException,
    ParserConfigurationException, SAXException {

// Get the properties object
Properties properties = LamsPluginUtil.getProperties();

// Get the LAMS2 Building Block properties from the request
String lamsServerUrl = request.getParameter("lamsServerUrl");
String lamsServerId = request.getParameter("lamsServerId");
String lamsSecretKey = request.getParameter("lamsSecretKey");
String lamsServerTimeRefreshInterval = request.getParameter("lamsServerTimeRefreshInterval");

// Save the properties to Blackboard
properties.setProperty(LamsPluginUtil.PROP_LAMS_URL, lamsServerUrl);
properties.setProperty(LamsPluginUtil.PROP_LAMS_SECRET_KEY, lamsSecretKey);
properties.setProperty(LamsPluginUtil.PROP_LAMS_SERVER_ID, lamsServerId);
properties.setProperty(LamsPluginUtil.PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL, lamsServerTimeRefreshInterval);

// Persist the properties object
LamsPluginUtil.setProperties(properties);

request.getRequestDispatcher("/admin/configSuccess.jsp").forward(request, response);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:ConfigServlet.java

示例3: start

import blackboard.persist.PersistenceException; //导入依赖的package包/类
/**
    * Starts preview lesson on LAMS server. Launches it.
    */
   private void start(HttpServletRequest request, HttpServletResponse response, Context ctx) throws IOException, ServletException, PersistenceException, ParseException, ValidationException, ParserConfigurationException, SAXException {

   	BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();

//store newly created LAMS lesson
User user = ctx.getUser();
BlackboardUtil.storeBlackboardContent(request, response, user);

// constuct strReturnUrl
String courseIdStr = request.getParameter("course_id");
String contentIdStr = request.getParameter("content_id");
// internal Blackboard IDs for the course and parent content item
Id courseId = bbPm.generateId(Course.DATA_TYPE, courseIdStr);
Id folderId = bbPm.generateId(CourseDocument.DATA_TYPE, contentIdStr);
String returnUrl = PlugInUtil.getEditableContentReturnURL(folderId, courseId);
request.setAttribute("returnUrl", returnUrl);

request.getRequestDispatcher("/modules/startLessonSuccess.jsp").forward(request, response);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:LessonManagerServlet.java

示例4: showModifyLessonPage

import blackboard.persist.PersistenceException; //导入依赖的package包/类
private void showModifyLessonPage(HttpServletRequest request, HttpServletResponse response, Context ctx)
    throws InitializationException, BbServiceException, PersistenceException, IOException, ServletException {

// retrive the LAMS lesson
BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();
Container bbContainer = bbPm.getContainer();
Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, request.getParameter("content_id"));
ContentDbLoader courseDocumentLoader = (ContentDbLoader) bbPm.getLoader(ContentDbLoader.TYPE);
Content bbContent = (Content) courseDocumentLoader.loadById(contentId);

// get LAMS lessons's properties
Calendar startDate = bbContent.getStartDate();
Calendar endDate = bbContent.getEndDate();
FormattedText description = bbContent.getBody();

request.setAttribute("bbContent", bbContent);
request.setAttribute("startDate", startDate);
request.setAttribute("endDate", endDate);
request.setAttribute("description", description);

request.getRequestDispatcher("/modules/modify.jsp").forward(request, response);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:LessonManagerServlet.java

示例5: delete

import blackboard.persist.PersistenceException; //导入依赖的package包/类
private void delete(HttpServletRequest request, HttpServletResponse response, Context ctx)
    throws InitializationException, BbServiceException, PersistenceException, IOException, ServletException, ParserConfigurationException, SAXException {

//remove Lineitem object from Blackboard DB
String _content_id = request.getParameter("content_id");
String _course_id = request.getParameter("course_id");
LineitemUtil.removeLineitem(_content_id, _course_id);

// remove internalContentId -> externalContentId key->value pair (it's used for GradebookServlet)
PortalExtraInfo pei = PortalUtil.loadPortalExtraInfo(null, null, "LamsStorage");
ExtraInfo ei = pei.getExtraInfo();
ei.clearEntry(_content_id);
PortalUtil.savePortalExtraInfo(pei);

//remove lesson from LAMS server
BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();
Container bbContainer = bbPm.getContainer();
ContentDbLoader courseDocumentLoader = ContentDbLoader.Default.getInstance();
Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, _content_id);
Content bbContent = courseDocumentLoader.loadById(contentId);
String lsId = bbContent.getLinkRef();
String userName = ctx.getUser().getUserName();
Boolean isDeletedSuccessfully = LamsSecurityUtil.deleteLesson(userName, lsId);

System.out.println("Lesson (bbContentId:" + _content_id + ") successfully deleted by userName:" + userName);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:LessonManagerServlet.java

示例6: getCourseTeacher

import blackboard.persist.PersistenceException; //导入依赖的package包/类
/**
    * Returns one random teacher from the specified course.
    * 
    * @param courseId
    *            BB course id
    * @return teacher
    * @throws PersistenceException
    */
   public static User getCourseTeacher(PkId courseId) throws PersistenceException {
// find the main teacher
CourseMembershipDbLoader courseMemLoader = CourseMembershipDbLoader.Default.getInstance();
List<CourseMembership> monitorCourseMemberships = courseMemLoader.loadByCourseIdAndRole(courseId,
	CourseMembership.Role.INSTRUCTOR, null, true);
if (monitorCourseMemberships.isEmpty()) {
    List<CourseMembership> teachingAssistantCourseMemberships = courseMemLoader
	    .loadByCourseIdAndRole(courseId, CourseMembership.Role.TEACHING_ASSISTANT, null, true);
    monitorCourseMemberships.addAll(teachingAssistantCourseMemberships);
    if (monitorCourseMemberships.isEmpty()) {
	List<CourseMembership> courseBuilderCourseMemberships = courseMemLoader
		.loadByCourseIdAndRole(courseId, CourseMembership.Role.COURSE_BUILDER, null, true);
	monitorCourseMemberships.addAll(courseBuilderCourseMemberships);
    }
}
// validate teacher existence
if (monitorCourseMemberships.isEmpty()) {
    throw new RuntimeException("There are no monitors in the course courseId=" + courseId);
}
User teacher = monitorCourseMemberships.get(0).getUser();

return teacher;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:BlackboardUtil.java

示例7: removeLineitem

import blackboard.persist.PersistenceException; //导入依赖的package包/类
/**
    * Removes lineitem. Throws exception if lineitem is not found.
    * 
    * @param _content_id
    * @param _course_id
    * @throws PersistenceException
    * @throws ServletException
    */
   public static void removeLineitem(String _content_id, String _course_id)
    throws PersistenceException, ServletException {
BbPersistenceManager bbPm = PersistenceServiceFactory.getInstance().getDbPersistenceManager();
Container bbContainer = bbPm.getContainer();
ContentDbLoader courseDocumentLoader = ContentDbLoader.Default.getInstance();
LineitemDbPersister linePersister = LineitemDbPersister.Default.getInstance();

Id contentId = new PkId(bbContainer, CourseDocument.DATA_TYPE, _content_id);
Content bbContent = courseDocumentLoader.loadById(contentId);
//check isGradecenter option is ON and thus there should exist associated lineitem object
if (!bbContent.getIsDescribed()) {
    return;
}

Id lineitemId = getLineitem(_content_id, _course_id, true);
linePersister.deleteById(lineitemId);

//Remove bbContentId -> lineitemid pair from the storage
PortalExtraInfo pei = PortalUtil.loadPortalExtraInfo(null, null, LAMS_LINEITEM_STORAGE);
ExtraInfo ei = pei.getExtraInfo();
ei.clearEntry(_content_id);
PortalUtil.savePortalExtraInfo(pei);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:LineitemUtil.java

示例8: updateScoreBasedOnLamsResponse

import blackboard.persist.PersistenceException; //导入依赖的package包/类
/**
    * Updates and persists currentScore in the DB.
    * 
    * @param lesson
    * @param learnerResult
    * @param currentScore provided score must be initialized (can't be null)
    * @throws PersistenceException 
    * @throws ValidationException 
    */
   public static double updateScoreBasedOnLamsResponse(Node lesson, Node learnerResult, Score currentScore)
    throws PersistenceException, ValidationException {
ScoreDbPersister scorePersister = ScoreDbPersister.Default.getInstance();

Long lessonMaxPossibleMark = new Long(
	lesson.getAttributes().getNamedItem("lessonMaxPossibleMark").getNodeValue());
String userTotalMarkStr = learnerResult.getAttributes().getNamedItem("userTotalMark").getNodeValue();

double newScore = StringUtil.isEmpty(userTotalMarkStr) ? 0 : new Double(userTotalMarkStr);

//set score grade. if Lams supplies one (and lineitem will have score type) we set score; otherwise (and
// lineitme of type Complete/Incomplete) we set 0
double gradebookMark = 0;
if (lessonMaxPossibleMark > 0) {
    gradebookMark = (newScore / lessonMaxPossibleMark) * Constants.GRADEBOOK_POINTS_POSSIBLE;
}

currentScore.setGrade(new DecimalFormat("##.##").format(gradebookMark));
currentScore.validate();
scorePersister.persist(currentScore);

return gradebookMark;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:33,代码来源:LineitemUtil.java

示例9: emailMemberships

import blackboard.persist.PersistenceException; //导入依赖的package包/类
public List<MailException> emailMemberships()
    throws PersistenceException {
    if (this.unsafeMemberships.isEmpty()) {
        return Collections.EMPTY_LIST;
    }
    
    final List<MailException> mailErrors = new ArrayList<MailException>();        
    
    for (Course course: this.unsafeMemberships.keySet()) {
        final Collection<GroupMembership> memberships = this.unsafeMemberships.get(course);
        final SimpleMailMessage message = this.buildMessage(course, memberships);
        
        if (null != message) {
            try {
                this.mailSender.send(message);
            } catch(MailException e) {
                mailErrors.add(e);
            }
        }
    }
    
    return mailErrors;
}
 
开发者ID:rnicoll,项目名称:learn_syllabus_plus_sync,代码行数:24,代码来源:UnsafeGroupMembershipManager.java

示例10: showStartLessonPage

import blackboard.persist.PersistenceException; //导入依赖的package包/类
/**
    * Shows preparation page with available learning designs. Preview is available.
    */
   private void showStartLessonPage(HttpServletRequest request, HttpServletResponse response, Context ctx)
    throws InitializationException, BbServiceException, PersistenceException, IOException, ServletException {

String lamsServerUrl = LamsPluginUtil.getServerUrl();
request.setAttribute("lamsServerUrl", lamsServerUrl);

// get all user accessible folders and LD descriptions as JSON
String learningDesigns = LamsSecurityUtil.getLearningDesigns(ctx, ctx.getCourse().getCourseId(), null);
request.setAttribute("learningDesigns", learningDesigns);

request.getRequestDispatcher("/modules/create.jsp").forward(request, response);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:LessonManagerServlet.java

示例11: openAuthor

import blackboard.persist.PersistenceException; //导入依赖的package包/类
private void openAuthor(HttpServletRequest request, HttpServletResponse response, Context ctx)
    throws InitializationException, BbServiceException, PersistenceException, IOException {
// Authorise current user for Course Control Panel (automatic redirect)
try {
    if (!PlugInUtil.authorizeForCourseControlPanel(request, response))
	return;
} catch (PlugInException e) {
    throw new RuntimeException(e);
}

// construct Login Request URL for authoring LAMS Lessons
String authorUrl = LamsSecurityUtil.generateRequestURL(ctx, "author", null);
response.sendRedirect(authorUrl);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:OpenLamsPageServlet.java

示例12: openPreview

import blackboard.persist.PersistenceException; //导入依赖的package包/类
/**
    * Starts preview lesson on LAMS server. Launches it.
    */
   private void openPreview(HttpServletRequest request, HttpServletResponse response, Context ctx)
    throws InitializationException, BbServiceException, PersistenceException, IOException {
// Authorize current user for Course Control Panel (automatic redirect)
try {
    if (!PlugInUtil.authorizeForCourseControlPanel(request, response))
	return;
} catch (PlugInException e) {
    throw new RuntimeException(e);
}

// Get the form parameters and convert into correct data types
String strTitle = request.getParameter("title").trim();
String strLdId = request.getParameter("ldId").trim();
long ldId = Long.parseLong(strLdId);

// start lesson-preview in LAMS and get back the lesson ID
User user = ctx.getUser();
Long lsId = LamsSecurityUtil.startLesson(user, "Previews", ldId, strTitle, "", true);
// error checking
if (lsId == -1) {
    response.sendRedirect("lamsServerDown.jsp");
    System.exit(1);
}

// redirect to preview lesson
String previewUrl = LamsSecurityUtil.generateRequestURL(ctx, "learnerStrictAuth", "" + lsId);
response.sendRedirect(previewUrl);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:OpenLamsPageServlet.java

示例13: getLamsLessonsByCourse

import blackboard.persist.PersistenceException; //导入依赖的package包/类
/**
    * Returns all LAMS lessons from the specified course.
    * 
    * @param courseId
    *            BB course id
    * @return list of LAMS lessons
    * @throws PersistenceException
    */
   public static List<Content> getLamsLessonsByCourse(PkId courseId, boolean includeLessonsCreatedByOldNtuPlugin) throws PersistenceException {

ContentDbLoader contentLoader = ContentDbLoader.Default.getInstance();
CourseTocDbLoader cTocDbLoader = CourseTocDbLoader.Default.getInstance();

// get a CourseTOC (Table of Contents) loader. We will need this to iterate through all of the "areas"
// within the course
List<CourseToc> courseTocs = cTocDbLoader.loadByCourseId(courseId);

// iterate through the course TOC items
List<Content> lamsContents = new ArrayList<Content>();
for (CourseToc courseToc : courseTocs) {

    // determine if the TOC item is of type "CONTENT" rather than applicaton, or something else
    if ((courseToc.getTargetType() == CourseToc.Target.CONTENT) && (courseToc.getContentId() != Id.UNSET_ID)) {
	// we have determined that the TOC item is content, next we need to load the content object and
	// iterate through it
	// load the content tree into an object "content" and iterate through it
	List<Content> contents = contentLoader.loadListById(courseToc.getContentId());
	// iterate through the content items in this content object
	for (Content content : contents) {
	    // only LAMS content
	    if ("resource/x-lams-lamscontent".equals(content.getContentHandler())
		    || includeLessonsCreatedByOldNtuPlugin && content.getContentHandler().equals("resource/x-ntu-hdllams")) {
		lamsContents.add(content);
	    }
	}
    }
}

return lamsContents;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:BlackboardUtil.java

示例14: changeLineitemName

import blackboard.persist.PersistenceException; //导入依赖的package包/类
/**
    * Changes lineitem's name. Throws exception if lineitem is not found.
    * 
    * @param _content_id
    * @param _course_id
    * @param newLineitemName
    * @throws PersistenceException
    * @throws ServletException
    * @throws ValidationException
    */
   public static void changeLineitemName(String _content_id, String _course_id, String newLineitemName)
    throws PersistenceException, ServletException, ValidationException {
LineitemDbLoader lineitemLoader = LineitemDbLoader.Default.getInstance();
LineitemDbPersister linePersister = LineitemDbPersister.Default.getInstance();

Id lineitemId = getLineitem(_content_id, _course_id, true);
Lineitem lineitem = lineitemLoader.loadById(lineitemId);
lineitem.setName(newLineitemName);
linePersister.persist(lineitem);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:LineitemUtil.java

示例15: updateLineitemLessonId

import blackboard.persist.PersistenceException; //导入依赖的package包/类
/**
    * Changes lineitem's lamsLessonId. Throws exception if lineitem is not found.
    * 
    * @param bbContentId
    * @param courseIdStr
    * @param newLineitemName
    * @throws PersistenceException
    * @throws ServletException
    * @throws ValidationException
    * @throws IOException 
    * @throws SAXException 
    * @throws ParserConfigurationException 
    */
   public static void updateLineitemLessonId(Content bbContent, String courseIdStr, Long newLamsLessonId, String userName)
    throws PersistenceException, ServletException, ValidationException, IOException, ParserConfigurationException, SAXException {
LineitemDbLoader lineitemLoader = LineitemDbLoader.Default.getInstance();
LineitemDbPersister linePersister = LineitemDbPersister.Default.getInstance();

String _content_id = bbContent.getId().toExternalString();

//update only in case grade center is ON
if (bbContent.getIsDescribed()) {

    Id lineitemId = getLineitem(_content_id, courseIdStr, false);
    //in case admin forgot to check "Grade Center Columns and Settings" option on doing course copy/import
    if (lineitemId == null) {
	createLineitem(bbContent, userName);
	
    //in case he checked it and BB created Lineitem object, then just need to update it
    } else {
	Lineitem lineitem = lineitemLoader.loadById(lineitemId);
	lineitem.setAssessmentId(Long.toString(newLamsLessonId), Lineitem.AssessmentLocation.EXTERNAL);
	linePersister.persist(lineitem);

	updateLamsLineitemStorage(bbContent, lineitem);
    }

}

// store internalContentId -> externalContentId. It's used for GradebookServlet. Store it just in case
PortalExtraInfo pei = PortalUtil.loadPortalExtraInfo(null, null, "LamsStorage");
ExtraInfo ei = pei.getExtraInfo();
ei.setValue(_content_id, Long.toString(newLamsLessonId));
PortalUtil.savePortalExtraInfo(pei);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:46,代码来源:LineitemUtil.java


注:本文中的blackboard.persist.PersistenceException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。