assignmentId = userSession.getMetaData("assignmentId");
} else {
userSession.addMetaData("assignmentId", assignmentId);
}
Assignment assignment = assignmentDao.getAssignmentById(assignmentId);
if (assignment == null) {
throw new IllegalArgumentException(String.format(
"Could not find an assignment with id '%s'.", assignmentId));
}
AssignmentStatus status = assignment.getStatus();
if (status != AssignmentStatus.ACTIVE) {
throw new IllegalArgumentException(String.format(
"Could not add a video to a non ACTIVE assignment. "
+ "Current status of assignment id '%s' is '%s'.", assignmentId, status));
}
// Max title length is 60 characters or 100 bytes.
if (title.length() > 60) {
title = title.substring(0, 59);
}
VideoEntry newEntry = new VideoEntry();
YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();
mg.setTitle(new MediaTitle());
mg.getTitle().setPlainTextContent(title);
mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, assignment.getCategory()));
mg.setKeywords(new MediaKeywords());
List<String> tags = new ArrayList<String>();
for (int i = 0; i < tagsArray.length(); i++) {