List of usage examples for java.util.logging Level FINE
Level FINE
To view the source code for java.util.logging Level FINE.
Click Source Link
From source file:gov.usgs.anss.query.MultiplexedMSOutputer.java
/** * This does the hard work of sorting - called as a shutdown hook. * TODO: consider recursion.// www. jav a 2 s. c o m * @param outputName name for the output file. * @param files list of MiniSEED files to multiplex. * @param cleanup flag indicating whether to cleanup after ourselves or not. * @throws IOException */ public static void multiplexFiles(String outputName, List<File> files, boolean cleanup, boolean allowEmpty) throws IOException { ArrayList<File> cleanupFiles = new ArrayList<File>(files); ArrayList<File> moreFiles = new ArrayList<File>(); File outputFile = new File(outputName); File tempOutputFile = new File(outputName + ".tmp"); do { // This checks if we're in a subsequent (i.e. not the first) iteration and if there are any more files to process...? if (!moreFiles.isEmpty()) { logger.info("more files left to multiplex..."); FileUtils.deleteQuietly(tempOutputFile); FileUtils.moveFile(outputFile, tempOutputFile); cleanupFiles.add(tempOutputFile); moreFiles.add(tempOutputFile); files = moreFiles; moreFiles = new ArrayList<File>(); } logger.log(Level.FINE, "Multiplexing blocks from {0} temp files to {1}", new Object[] { files.size(), outputName }); BufferedOutputStream out = new BufferedOutputStream(FileUtils.openOutputStream(outputFile)); // The hard part, sorting the temp files... TreeMap<MiniSeed, FileInputStream> blks = new TreeMap<MiniSeed, FileInputStream>( new MiniSeedTimeOnlyComparator()); // Prime the TreeMap logger.log(Level.FINEST, "Priming the TreeMap with files: {0}", files); for (File file : files) { logger.log(Level.INFO, "Reading first block from {0}", file.toString()); try { FileInputStream fs = FileUtils.openInputStream(file); MiniSeed ms = getNextValidMiniSeed(fs, allowEmpty); if (ms != null) { blks.put(ms, fs); } else { logger.log(Level.WARNING, "Failed to read valid MiniSEED block from {0}", file.toString()); } } catch (IOException ex) { // Catch "Too many open files" i.e. hitting ulimit, throw anything else. if (ex.getMessage().contains("Too many open files")) { logger.log(Level.INFO, "Too many open files - {0} deferred.", file.toString()); moreFiles.add(file); } else throw ex; } } while (!blks.isEmpty()) { MiniSeed next = blks.firstKey(); out.write(next.getBuf(), 0, next.getBlockSize()); FileInputStream fs = blks.remove(next); next = getNextValidMiniSeed(fs, allowEmpty); if (next != null) { blks.put(next, fs); } else { fs.close(); } } out.close(); } while (!moreFiles.isEmpty()); if (cleanup) { logger.log(Level.INFO, "Cleaning up..."); for (File file : cleanupFiles) { FileUtils.deleteQuietly(file); } } }
From source file:com.ovea.facebook.client.DefaultFacebookClient.java
@Override public JSONObject me(FacebookToken accessToken) throws FacebookException { List<NameValuePair> qparams = new ArrayList<NameValuePair>(); qparams.add(new BasicNameValuePair(ACCESS_TOKEN, accessToken.value())); JSONType result = get("https", "graph.facebook.com", "/me", qparams); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("me for token " + accessToken + " : " + result); }//from w w w.jav a 2 s . co m checkErrorOn(result); return result.asObject(); }
From source file:jp.ikedam.jenkins.plugins.groovy_label_assignment.GroovyLabelAssignmentProperty.java
/** * Create variables used in a groovy script. * // ww w. j av a 2 s . c o m * @param project * @param actions * @return */ protected Binding createBinding(AbstractProject<?, ?> project, List<Action> actions) { EnvVars env = new EnvVars(); // add environments // ParametersAction is also processed here. // some actions may fail for build is null for (EnvironmentContributingAction a : Util.filter(actions, EnvironmentContributingAction.class)) { try { a.buildEnvVars(null, env); } catch (NullPointerException e) { // nothing to do. LOGGER.log(Level.FINE, String.format("%s: NPE occurred in %s(%s): ignore", project.getName(), a.getDisplayName(), a.getClass().getName()), e); } catch (Exception e) { LOGGER.log(Level.WARNING, String.format("%s: Failed to initialize environment %s(%s): skip", project.getName(), a.getDisplayName(), a.getClass().getName()), e); } } EnvVars.resolve(env); //// As in MatrixRun#getBuildVariables if (project instanceof MatrixConfiguration) { MatrixConfiguration child = (MatrixConfiguration) project; MatrixProject parent = child.getParent(); // pick up user axes AxisList axes = parent.getAxes(); for (Map.Entry<String, String> e : child.getCombination().entrySet()) { Axis a = axes.find(e.getKey()); if (a != null) { a.addBuildVariable(e.getValue(), env); } else { env.put(e.getKey(), e.getValue()); } } } LOGGER.fine(String.format("%s: set environments %s", project.getName(), env.toString())); return new Binding(env); }
From source file:de.theit.jenkins.crowd.CrowdServletFilter.java
/** * {@inheritDoc}/*from www . j a v a2 s . c om*/ * * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, * javax.servlet.ServletResponse, javax.servlet.FilterChain) */ @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; // check if we have a token // if it is not present, we are not / no longer authenticated boolean isValidated = false; try { isValidated = this.configuration.crowdHttpAuthenticator.isAuthenticated(req, res); } catch (OperationFailedException ex) { LOG.log(Level.SEVERE, operationFailed(), ex); } if (!isValidated) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("User is not logged in (anymore) via Crowd => logout user"); } SecurityContext sc = SecurityContextHolder.getContext(); sc.setAuthentication(null); // close the SSO session if (null != this.rememberMe) { this.rememberMe.logout(req, res); } // invalidate the current session // (see SecurityRealm#doLogout()) HttpSession session = req.getSession(false); if (session != null) { session.invalidate(); } SecurityContextHolder.clearContext(); // reset remember-me cookie Cookie cookie = new Cookie(SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, ""); cookie.setPath(req.getContextPath().length() > 0 ? req.getContextPath() : "/"); res.addCookie(cookie); } else { SecurityContext sc = SecurityContextHolder.getContext(); if (!(sc.getAuthentication() instanceof CrowdAuthenticationToken)) { // user logged in via Crowd, but no Crowd-specific // authentication token available // => try to auto-login the user if (null != this.rememberMe) { if (LOG.isLoggable(Level.FINE)) { LOG.fine( "User is logged in via Crowd, but no authentication token available; trying auto-login..."); } Authentication auth = this.rememberMe.autoLogin(req, res); if (null != auth) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("User sucessfully logged in"); } sc.setAuthentication(auth); } } } } } this.defaultFilter.doFilter(request, response, chain); }
From source file:net.chrissearle.flickrvote.web.vote.VoteAction.java
public void prepare() throws Exception { if (logger.isLoggable(Level.FINE)) { logger.fine("prepare"); }/*from www .j a va 2 s. co m*/ voted = false; if (session.containsKey(FlickrVoteWebConstants.FLICKR_USER_SESSION_KEY)) { Photographer photographer = (Photographer) session.get(FlickrVoteWebConstants.FLICKR_USER_SESSION_KEY); voted = challengeService.hasVoted(photographer.getPhotographerId()); if (logger.isLoggable(Level.FINE)) { logger.fine("Setting voted to " + voted); } } Set<ChallengeSummary> votingChallenges = challengeService.getChallengesByType(ChallengeType.VOTING); if (votingChallenges.size() > 0) { challenge = new DisplayChallengeSummary(votingChallenges.iterator().next()); ChallengeItem challengeItem = photographyService.getChallengeImages(challenge.getChallengeTag()); images = new ArrayList<DisplayImage>(challengeItem.getImages().size()); for (ImageItem image : challengeItem.getImages()) { images.add(new DisplayImage(image)); } if (!voted) { Collections.sort(images, new Comparator<DisplayImage>() { public int compare(DisplayImage o1, DisplayImage o2) { return o2.getPostedDate().compareTo(o1.getPostedDate()); } }); } else { Collections.sort(images, new Comparator<DisplayImage>() { public int compare(DisplayImage o1, DisplayImage o2) { return o1.getVoteCount().equals(o2.getVoteCount()) ? o2.getPostedDate().compareTo(o1.getPostedDate()) : o2.getVoteCount().compareTo(o1.getVoteCount()); } }); } } }
From source file:edu.umass.cs.gnsserver.httpserver.GNSHttpServer.java
/** * Try to start the http server at the port. * * @param port// w w w .jav a2 s . c o m * @return true if it was started */ public boolean tryPort(int port) { try { InetSocketAddress addr = new InetSocketAddress(port); httpServer = HttpServer.create(addr, 0); httpServer.createContext("/", new EchoHttpHandler()); httpServer.createContext("/" + GNS_PATH, new DefaultHttpHandler()); httpServer.setExecutor(Executors.newCachedThreadPool()); httpServer.start(); // Need to do this for the places where we expose the insecure http service to the user requestHandler.setHttpServerPort(port); LOGGER.log(Level.INFO, "HTTP server is listening on port {0}", port); return true; } catch (IOException e) { LOGGER.log(Level.FINE, "HTTP server failed to start on port {0} due to {1}", new Object[] { port, e.getMessage() }); return false; } }
From source file:com.google.enterprise.connector.sharepoint.client.SiteDataHelper.java
/** * Gets the collection of all the lists on the sharepoint server which are of * a given type. E.g., DocumentLibrary/*from w ww .j a v a 2 s . c om*/ * * @param webstate The web from which the list/libraries are to be discovered * @return list of BaseList objects. */ public List<ListState> getNamedLists(final WebState webstate) { final ArrayList<ListState> listCollection = new ArrayList<ListState>(); if (webstate == null) { LOGGER.warning("Unable to get the list collection because webstate is null"); return listCollection; } final ArrayOf_sListHolder vLists = Util.makeWSRequest(sharepointClientContext, siteDataWS, new Util.RequestExecutor<ArrayOf_sListHolder>() { public ArrayOf_sListHolder onRequest(final BaseWS ws) throws Throwable { return ((SiteDataWS) ws).getListCollection(); } public void onError(final Throwable e) { LOGGER.log(Level.WARNING, "Call to getListCollection failed.", e); } }); if (vLists == null) { LOGGER.log(Level.WARNING, "Unable to get the list collection"); return listCollection; } final Collator collator = Util.getCollator(); try { final _sList[] sl = vLists.value; if (sl != null) { webstate.setExisting(true); for (_sList element : sl) { String url = null; String strBaseTemplate = null; if (element == null) { continue; } final String baseType = element.getBaseType(); LOGGER.log(Level.FINE, "Base Type returned by the Web Service : " + baseType); if (!collator.equals(baseType, (SPConstants.DISCUSSION_BOARD)) && !collator.equals(baseType, (SPConstants.DOC_LIB)) && !collator.equals(baseType, (SPConstants.GENERIC_LIST)) && !collator.equals(baseType, (SPConstants.ISSUE)) && !collator.equals(baseType, (SPConstants.SURVEYS))) { LOGGER.log(Level.WARNING, "Skipping List [{0}] with unsupported base type [{1}]", new Object[] { element.getTitle(), baseType }); continue; } MessageElement listMetadata = getListMetadata(element.getInternalName()); if (listMetadata == null) { LOGGER.log(Level.WARNING, "Unable to get metadata for List [{0}]. Skipping List", element.getTitle()); continue; } String rootFolder = getMetadataAttributeForList(listMetadata, "RootFolder"); if (Strings.isNullOrEmpty(rootFolder)) { LOGGER.log(Level.WARNING, "Unable to get Root Folder for List [{0}]. Skipping List", element.getTitle()); continue; } String defaultViewItemUrl = getMetadataAttributeForList(listMetadata, "DefaultViewItemUrl"); if (Strings.isNullOrEmpty(defaultViewItemUrl)) { LOGGER.log(Level.WARNING, "Unable to get default View Item Url " + "for List [{0}]. Skipping List", element.getTitle()); continue; } LOGGER.log(Level.FINE, "List [{0}] Root Folder [{1}] Default View Item URL [{2}]", new Object[] { element.getTitle(), rootFolder, defaultViewItemUrl }); String siteUrl = sharepointClientContext.getSiteURL(); if (Strings.isNullOrEmpty(element.getDefaultViewUrl())) { LOGGER.log(Level.WARNING, "List [{0}] with empty default view URL." + " Using root folder for List URL.", element.getTitle()); StringBuilder listUrl = new StringBuilder(siteUrl); if (!siteUrl.endsWith("/")) { listUrl.append("/"); } listUrl.append(rootFolder); url = listUrl.toString(); } else { url = Util.getWebApp(sharepointClientContext.getSiteURL()) + element.getDefaultViewUrl(); } LOGGER.log(Level.INFO, "List url for List [{0}] is [{1}]", new Object[] { element.getTitle(), url }); strBaseTemplate = element.getBaseTemplate(); if (strBaseTemplate == null) { strBaseTemplate = SPConstants.NO_TEMPLATE; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_SLIDELIBRARY)) {// for // SlideLibrary strBaseTemplate = SPConstants.BT_SLIDELIBRARY; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_TRANSLATIONMANAGEMENTLIBRARY)) {// for // TranslationManagementLibrary strBaseTemplate = SPConstants.BT_TRANSLATIONMANAGEMENTLIBRARY; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_TRANSLATOR)) {// for // Translator strBaseTemplate = SPConstants.BT_TRANSLATOR; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_REPORTLIBRARY)) {// for // ReportLibrary strBaseTemplate = SPConstants.BT_REPORTLIBRARY; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_PROJECTTASK)) {// for // ReportLibrary strBaseTemplate = SPConstants.BT_PROJECTTASK; } else if (collator.equals(strBaseTemplate, SPConstants.ORIGINAL_BT_SITESLIST)) {// for // ReportLibrary strBaseTemplate = SPConstants.BT_SITESLIST; } else { // for FormLibrary for (String formTemplate : sharepointClientContext.getInfoPathBaseTemplate()) { if (collator.equals(strBaseTemplate, formTemplate)) { strBaseTemplate = SPConstants.BT_FORMLIBRARY; break; } } } LOGGER.config("List URL :" + url); // Children of all URLs are discovered ListState list = new ListState(element.getInternalName(), element.getTitle(), element.getBaseType(), Util.siteDataStringToCalendar(element.getLastModified()), strBaseTemplate, url, webstate); list.setInheritedSecurity(element.isInheritedSecurity()); list.setApplyReadSecurity(element.getReadSecurity() == 2); String myNewListConst = ""; LOGGER.log(Level.FINE, "getting listConst for list URL [{0}]", defaultViewItemUrl); if (defaultViewItemUrl != null) { final StringTokenizer strTokList = new StringTokenizer(defaultViewItemUrl, SPConstants.SLASH); if (null != strTokList) { while ((strTokList.hasMoreTokens()) && (strTokList.countTokens() > 1)) { final String listToken = strTokList.nextToken(); if (list.isDocumentLibrary() && listToken.equals(SPConstants.FORMS_LIST_URL_SUFFIX) && (strTokList.countTokens() == 1)) { break; } if (null != listToken) { myNewListConst += listToken + SPConstants.SLASH; } } list.setListConst(myNewListConst); LOGGER.log(Level.CONFIG, "using listConst [ " + myNewListConst + " ] for list URL [ " + defaultViewItemUrl + " ] "); // Apply the URL filter here // check if the entire list subtree is to excluded // by comparing the prefix of the list URL with the // patterns if (sharepointClientContext .isIncludedUrl(webstate.getWebUrl() + SPConstants.SLASH + myNewListConst)) { // is included check if actual list url itself // is to be excluded if (sharepointClientContext.isIncludedUrl(url, LOGGER)) { // if a List URL is included, it WILL be // sent as a // Document list.setSendListAsDocument(true); } else { // if a List URL is EXCLUDED, it will NOT be // sent as a // Document list.setSendListAsDocument(false); } // add the attribute(Metadata to the list ) list = getListWithAllAttributes(list, element); listCollection.add(list); } else { // entire subtree is to be excluded // do not construct list state LOGGER.finest("Excluding " + url + " because entire subtree of " + myNewListConst + " is excluded"); } } } // Sort the base list Collections.sort(listCollection); } } } catch (final Throwable e) { LOGGER.log(Level.FINER, e.getMessage(), e); } if (listCollection.size() > 0) { LOGGER.info("Discovered " + listCollection.size() + " lists/libraries under site [ " + webstate + " ] for crawling"); } else { LOGGER.config("No lists/libraries to crawl under site [ " + webstate + " ]"); } return listCollection; }
From source file:org.bonitasoft.engine.api.HTTPServerAPI.java
@Override public Object invokeMethod(final Map<String, Serializable> options, final String apiInterfaceName, final String methodName, final List<String> classNameParameters, final Object[] parametersValues) throws ServerWrappedException { String response = null;/* ww w . ja va 2s . c om*/ try { response = executeHttpPost(options, apiInterfaceName, methodName, classNameParameters, parametersValues, XSTREAM); return checkInvokeMethodReturn(response, XSTREAM); } catch (final UndeclaredThrowableException e) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, e.getMessage(), e); } throw new ServerWrappedException(e); } catch (final Throwable e) { final StackTraceElement[] stackTrace = new Exception().getStackTrace(); StackTraceTransformer.addStackTo(e, stackTrace); throw new ServerWrappedException(e.getMessage() + "response= " + response, e); } }
From source file:com.cyberway.issue.io.WriterPool.java
/** * @param writer Writer to return to the pool. * @throws IOException Problem returning File to pool. */// w w w . ja v a 2 s . c o m public void returnFile(WriterPoolMember writer) throws IOException { try { if (logger.getLevel() == Level.FINE) { logger.fine("Returned " + writer); } this.pool.returnObject(writer); } catch (Exception e) { throw new IOException("Failed restoring writer to pool: " + e.getMessage()); } }
From source file:fr.ortolang.diffusion.bootstrap.BootstrapServiceBean.java
@Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void bootstrap() throws BootstrapServiceException { LOGGER.log(Level.INFO, "Starting bootstrap..."); Map<String, List<String>> anonReadRules = new HashMap<String, List<String>>(); anonReadRules.put(MembershipService.UNAUTHENTIFIED_IDENTIFIER, Collections.singletonList("read")); try {//from ww w. j a v a 2 s. c om if (!registry.exists(MembershipService.SUPERUSER_IDENTIFIER)) { LOGGER.log(Level.FINE, "creating root profile"); membership.createProfile(MembershipService.SUPERUSER_IDENTIFIER, "Super", "User", "root@ortolang.org", ProfileStatus.ACTIVE); } if (!registry.exists(MembershipService.UNAUTHENTIFIED_IDENTIFIER)) { LOGGER.log(Level.FINE, "creating anonymous profile"); membership.createProfile(MembershipService.UNAUTHENTIFIED_IDENTIFIER, "Anonymous", "User", "anon@ortolang.org", ProfileStatus.ACTIVE); LOGGER.log(Level.FINE, "change owner of anonymous profile to root and set anon read rules"); authorisation.updatePolicyOwner(MembershipService.UNAUTHENTIFIED_IDENTIFIER, MembershipService.SUPERUSER_IDENTIFIER); authorisation.setPolicyRules(MembershipService.UNAUTHENTIFIED_IDENTIFIER, anonReadRules); } if (!registry.exists(MembershipService.MODERATORS_GROUP_KEY)) { LOGGER.log(Level.FINE, "creating moderators group"); membership.createGroup(MembershipService.MODERATORS_GROUP_KEY, "Publication Moderators", "Moderators of the platform check technical aspect of publication"); membership.addMemberInGroup(MembershipService.MODERATORS_GROUP_KEY, MembershipService.SUPERUSER_IDENTIFIER); authorisation.setPolicyRules(MembershipService.MODERATORS_GROUP_KEY, anonReadRules); } if (!registry.exists(MembershipService.PUBLISHERS_GROUP_KEY)) { LOGGER.log(Level.FINE, "creating publishers group"); membership.createGroup(MembershipService.PUBLISHERS_GROUP_KEY, "Publishers", "Publishers of the platform validates final publication"); membership.addMemberInGroup(MembershipService.PUBLISHERS_GROUP_KEY, MembershipService.SUPERUSER_IDENTIFIER); authorisation.setPolicyRules(MembershipService.PUBLISHERS_GROUP_KEY, anonReadRules); } if (!registry.exists(MembershipService.REVIEWERS_GROUP_KEY)) { LOGGER.log(Level.FINE, "creating reviewers group"); membership.createGroup(MembershipService.REVIEWERS_GROUP_KEY, "Reviewers", "Reviewers of the platform rate content"); membership.addMemberInGroup(MembershipService.REVIEWERS_GROUP_KEY, MembershipService.SUPERUSER_IDENTIFIER); authorisation.setPolicyRules(MembershipService.REVIEWERS_GROUP_KEY, anonReadRules); } if (!registry.exists(MembershipService.ESR_GROUP_KEY)) { LOGGER.log(Level.FINE, "creating esr group"); membership.createGroup(MembershipService.ESR_GROUP_KEY, "ESR Members", "People from Superior Teaching and Research Group"); authorisation.setPolicyRules(MembershipService.ESR_GROUP_KEY, anonReadRules); } if (!registry.exists(MembershipService.ADMINS_GROUP_KEY)) { LOGGER.log(Level.FINE, "creating admins group"); membership.createGroup(MembershipService.ADMINS_GROUP_KEY, "Administrators", "Administrators of the platform"); authorisation.setPolicyRules(MembershipService.ADMINS_GROUP_KEY, anonReadRules); } if (!registry.exists(BootstrapService.WORKSPACE_KEY)) { LOGGER.log(Level.FINE, "create system workspace"); core.createWorkspace(BootstrapService.WORKSPACE_KEY, "system", "System Workspace", WorkspaceType.SYSTEM.toString()); Properties props = new Properties(); props.setProperty("bootstrap.status", "done"); props.setProperty("bootstrap.timestamp", System.currentTimeMillis() + ""); props.setProperty("bootstrap.version", BootstrapService.VERSION); String hash = core.put(new ByteArrayInputStream(props.toString().getBytes())); core.createDataObject(BootstrapService.WORKSPACE_KEY, "/bootstrap.txt", hash); } if (!authorisation.isPolicyTemplateExists(AuthorisationPolicyTemplate.DEFAULT)) { LOGGER.log(Level.FINE, "create [" + AuthorisationPolicyTemplate.DEFAULT + "] authorisation policy template"); String pid = UUID.randomUUID().toString(); authorisation.createPolicy(pid, MembershipService.SUPERUSER_IDENTIFIER); Map<String, List<String>> defaultPolicyRules = new HashMap<String, List<String>>(); defaultPolicyRules.put(MembershipService.UNAUTHENTIFIED_IDENTIFIER, Arrays.asList("read", "download")); authorisation.setPolicyRules(pid, defaultPolicyRules); authorisation.createPolicyTemplate(AuthorisationPolicyTemplate.DEFAULT, "Default template allows all users to read and download content", pid); } if (!authorisation.isPolicyTemplateExists(AuthorisationPolicyTemplate.FORALL)) { LOGGER.log(Level.FINE, "create [" + AuthorisationPolicyTemplate.FORALL + "] authorisation policy template"); String pid = UUID.randomUUID().toString(); authorisation.createPolicy(pid, MembershipService.SUPERUSER_IDENTIFIER); Map<String, List<String>> forallPolicyRules = new HashMap<String, List<String>>(); forallPolicyRules.put(MembershipService.UNAUTHENTIFIED_IDENTIFIER, Arrays.asList("read", "download")); authorisation.setPolicyRules(pid, forallPolicyRules); authorisation.createPolicyTemplate(AuthorisationPolicyTemplate.FORALL, "All users can read and download this content", pid); } if (!authorisation.isPolicyTemplateExists(AuthorisationPolicyTemplate.AUTHENTIFIED)) { LOGGER.log(Level.FINE, "create [" + AuthorisationPolicyTemplate.AUTHENTIFIED + "] authorisation policy template"); String pid = UUID.randomUUID().toString(); authorisation.createPolicy(pid, MembershipService.SUPERUSER_IDENTIFIER); Map<String, List<String>> authentifiedPolicyRules = new HashMap<String, List<String>>(); authentifiedPolicyRules.put(MembershipService.UNAUTHENTIFIED_IDENTIFIER, Collections.singletonList("read")); authentifiedPolicyRules.put(MembershipService.ALL_AUTHENTIFIED_GROUP_KEY, Arrays.asList("read", "download")); authorisation.setPolicyRules(pid, authentifiedPolicyRules); authorisation.createPolicyTemplate(AuthorisationPolicyTemplate.AUTHENTIFIED, "All users can read this content but download is restricted to authentified users only", pid); } if (!authorisation.isPolicyTemplateExists(AuthorisationPolicyTemplate.ESR)) { LOGGER.log(Level.FINE, "create [" + AuthorisationPolicyTemplate.ESR + "] authorisation policy template"); String pid = UUID.randomUUID().toString(); authorisation.createPolicy(pid, MembershipService.SUPERUSER_IDENTIFIER); Map<String, List<String>> esrPolicyRules = new HashMap<String, List<String>>(); esrPolicyRules.put(MembershipService.UNAUTHENTIFIED_IDENTIFIER, Collections.singletonList("read")); esrPolicyRules.put(MembershipService.ESR_GROUP_KEY, Arrays.asList("read", "download")); esrPolicyRules.put("${workspace.privileged}", Arrays.asList("read", "download")); authorisation.setPolicyRules(pid, esrPolicyRules); authorisation.createPolicyTemplate(AuthorisationPolicyTemplate.ESR, "All users can read this content but download is restricted to ESR users only", pid); } if (!authorisation.isPolicyTemplateExists(AuthorisationPolicyTemplate.PRIVILEGED)) { LOGGER.log(Level.FINE, "create [" + AuthorisationPolicyTemplate.PRIVILEGED + "] authorisation policy template"); String pid = UUID.randomUUID().toString(); authorisation.createPolicy(pid, MembershipService.SUPERUSER_IDENTIFIER); Map<String, List<String>> privilegedPolicyRules = new HashMap<String, List<String>>(); privilegedPolicyRules.put(MembershipService.UNAUTHENTIFIED_IDENTIFIER, Collections.singletonList("read")); privilegedPolicyRules.put(MembershipService.ESR_GROUP_KEY, Collections.singletonList("read")); privilegedPolicyRules.put("${workspace.privileged}", Arrays.asList("read", "download")); authorisation.setPolicyRules(pid, privilegedPolicyRules); authorisation.createPolicyTemplate(AuthorisationPolicyTemplate.PRIVILEGED, "Only privileged users can read and download this content", pid); } if (!authorisation.isPolicyTemplateExists(AuthorisationPolicyTemplate.RESTRICTED)) { LOGGER.log(Level.FINE, "create [" + AuthorisationPolicyTemplate.RESTRICTED + "] authorisation policy template"); String pid = UUID.randomUUID().toString(); authorisation.createPolicy(pid, MembershipService.SUPERUSER_IDENTIFIER); Map<String, List<String>> restrictedPolicyRules = new HashMap<String, List<String>>(); restrictedPolicyRules.put("${workspace.members}", Arrays.asList("read", "download")); authorisation.setPolicyRules(pid, restrictedPolicyRules); authorisation.createPolicyTemplate(AuthorisationPolicyTemplate.RESTRICTED, "Only workspace members can read and download this content, all other users cannot see this content", pid); } InputStream is = getClass().getClassLoader() .getResourceAsStream("forms/" + FormService.IMPORT_ZIP_FORM + ".json"); String json = IOUtils.toString(is, "UTF-8"); if (!registry.exists(FormService.IMPORT_ZIP_FORM)) { LOGGER.log(Level.FINE, "create form : " + FormService.IMPORT_ZIP_FORM); form.createForm(FormService.IMPORT_ZIP_FORM, "Import Zip Process Start Form", json); } else { LOGGER.log(Level.FINE, "update form : " + FormService.IMPORT_ZIP_FORM); form.updateForm(FormService.IMPORT_ZIP_FORM, "Import Zip Process Start Form", json); } is.close(); is = getClass().getClassLoader() .getResourceAsStream("forms/" + FormService.REVIEW_SNAPSHOT_FORM + ".json"); json = IOUtils.toString(is, "UTF-8"); if (!registry.exists(FormService.REVIEW_SNAPSHOT_FORM)) { LOGGER.log(Level.FINE, "create form : " + FormService.REVIEW_SNAPSHOT_FORM); form.createForm(FormService.REVIEW_SNAPSHOT_FORM, "Workspace publication's review form", json); } else { LOGGER.log(Level.FINE, "update form : " + FormService.REVIEW_SNAPSHOT_FORM); form.updateForm(FormService.REVIEW_SNAPSHOT_FORM, "Workspace publication's review form", json); } is.close(); is = getClass().getClassLoader() .getResourceAsStream("forms/" + FormService.MODERATE_SNAPSHOT_FORM + ".json"); json = IOUtils.toString(is, "UTF-8"); if (!registry.exists(FormService.MODERATE_SNAPSHOT_FORM)) { LOGGER.log(Level.FINE, "create form : " + FormService.MODERATE_SNAPSHOT_FORM); form.createForm(FormService.MODERATE_SNAPSHOT_FORM, "Workspace publication's moderation form", json); } else { LOGGER.log(Level.FINE, "update form : " + FormService.MODERATE_SNAPSHOT_FORM); form.updateForm(FormService.MODERATE_SNAPSHOT_FORM, "Workspace publication's moderation form", json); } is.close(); is = getClass().getClassLoader() .getResourceAsStream("forms/" + FormService.PUBLISH_SNAPSHOT_FORM + ".json"); json = IOUtils.toString(is, "UTF-8"); if (!registry.exists(FormService.PUBLISH_SNAPSHOT_FORM)) { LOGGER.log(Level.FINE, "create form : " + FormService.PUBLISH_SNAPSHOT_FORM); form.createForm(FormService.PUBLISH_SNAPSHOT_FORM, "Workspace publication's form", json); } else { LOGGER.log(Level.FINE, "update form : " + FormService.MODERATE_SNAPSHOT_FORM); form.updateForm(FormService.PUBLISH_SNAPSHOT_FORM, "Workspace publication's form", json); } is.close(); is = getClass().getClassLoader().getResourceAsStream("forms/" + FormService.ITEM_FORM + ".json"); json = IOUtils.toString(is, "UTF-8"); if (!registry.exists(FormService.ITEM_FORM)) { LOGGER.log(Level.FINE, "create form : " + FormService.ITEM_FORM); form.createForm(FormService.ITEM_FORM, "Schema Form for an ORTOLANG item", json); } else { LOGGER.log(Level.FINE, "update form : " + FormService.ITEM_FORM); form.updateForm(FormService.ITEM_FORM, "Schema Form for an ORTOLANG item", json); } is.close(); LOGGER.log(Level.FINE, "import metadataformat schemas"); InputStream schemaItemInputStream = getClass().getClassLoader() .getResourceAsStream("schema/ortolang-item-schema-0.16-with-parts.json"); String schemaItemHash = core.put(schemaItemInputStream); core.createMetadataFormat(MetadataFormat.ITEM, "Les mtadonnes de prsentation permettent de paramtrer l\'affichage de la ressource dans la partie consultation du site. Nouvelle fonctionnalit : les sous-parties.", schemaItemHash, "ortolang-item-form", true, true); InputStream schemaInputStream2 = getClass().getClassLoader() .getResourceAsStream("schema/ortolang-acl-schema.json"); String schemaHash2 = core.put(schemaInputStream2); core.createMetadataFormat(MetadataFormat.ACL, "Les mtadonnes de contrle d'accs permettent de paramtrer la visibilit d'une ressource lors de sa publication.", schemaHash2, "", true, false); InputStream schemaWorkspaceInputStream = getClass().getClassLoader() .getResourceAsStream("schema/ortolang-workspace-schema.json"); String schemaWorkspaceHash = core.put(schemaWorkspaceInputStream); core.createMetadataFormat(MetadataFormat.WORKSPACE, "Les mtadonnes associes un espace de travail.", schemaWorkspaceHash, "", true, true); InputStream schemaPidInputStream = getClass().getClassLoader() .getResourceAsStream("schema/ortolang-pid-schema.json"); String schemaPidHash = core.put(schemaPidInputStream); core.createMetadataFormat(MetadataFormat.PID, "Les mtadonnes associes aux pids d'un object.", schemaPidHash, "", true, false); InputStream schemaThumbInputStream = getClass().getClassLoader() .getResourceAsStream("schema/ortolang-thumb-schema.json"); String schemaThumbHash = core.put(schemaThumbInputStream); core.createMetadataFormat(MetadataFormat.THUMB, "Schema for ORTOLANG objects thumbnail", schemaThumbHash, "", false, false); InputStream schemaTemplateInputStream = getClass().getClassLoader() .getResourceAsStream("schema/ortolang-template-schema.json"); String schemaTemplateHash = core.put(schemaTemplateInputStream); core.createMetadataFormat(MetadataFormat.TEMPLATE, "Schema for ORTOLANG collection template", schemaTemplateHash, "", false, false); InputStream schemaTrustRankInputStream = getClass().getClassLoader() .getResourceAsStream("schema/system-trustrank-schema.json"); String schemaTrustRankHash = core.put(schemaTrustRankInputStream); core.createMetadataFormat(MetadataFormat.TRUSTRANK, "Schema for applying a trusted notation on item", schemaTrustRankHash, "", true, true); InputStream schemaRatingInputStream = getClass().getClassLoader() .getResourceAsStream("schema/system-rating-schema.json"); String schemaRatingHash = core.put(schemaRatingInputStream); core.createMetadataFormat(MetadataFormat.RATING, "Schema for applying a rating on item", schemaRatingHash, "", true, true); InputStream schemaAudioInputStream = getClass().getClassLoader() .getResourceAsStream("schema/system-x-audio.json"); String schemaAudioHash = core.put(schemaAudioInputStream); core.createMetadataFormat(MetadataFormat.AUDIO, "Schema for ORTOLANG audio metadata", schemaAudioHash, "", false, false); InputStream schemaVideoInputStream = getClass().getClassLoader() .getResourceAsStream("schema/system-x-video.json"); String schemaVideoHash = core.put(schemaVideoInputStream); core.createMetadataFormat(MetadataFormat.VIDEO, "Schema for ORTOLANG video metadata", schemaVideoHash, "", false, false); InputStream schemaImageInputStream = getClass().getClassLoader() .getResourceAsStream("schema/system-x-image.json"); String schemaImageHash = core.put(schemaImageInputStream); core.createMetadataFormat(MetadataFormat.IMAGE, "Schema for ORTOLANG image metadata", schemaImageHash, "", false, false); InputStream schemaXMLInputStream = getClass().getClassLoader() .getResourceAsStream("schema/system-x-xml.json"); String schemaXmlHash = core.put(schemaXMLInputStream); core.createMetadataFormat(MetadataFormat.XML, "Schema for ORTOLANG XML metadata", schemaXmlHash, "", false, false); InputStream schemaPDFInputStream = getClass().getClassLoader() .getResourceAsStream("schema/system-x-pdf.json"); String schemaPDFHash = core.put(schemaPDFInputStream); core.createMetadataFormat(MetadataFormat.PDF, "Schema for ORTOLANG PDF metadata", schemaPDFHash, "", false, false); InputStream schemaTextInputStream = getClass().getClassLoader() .getResourceAsStream("schema/system-x-text.json"); String schemaTextHash = core.put(schemaTextInputStream); core.createMetadataFormat(MetadataFormat.TEXT, "Schema for ORTOLANG text metadata", schemaTextHash, "", false, false); InputStream schemaOfficeInputStream = getClass().getClassLoader() .getResourceAsStream("schema/system-x-office.json"); String schemaOfficeHash = core.put(schemaOfficeInputStream); core.createMetadataFormat(MetadataFormat.OFFICE, "Schema for ORTOLANG Office metadata", schemaOfficeHash, "", false, false); loadMetadataFormat(MetadataFormat.OAI_DC, "Schema for Dublin Core elements in JSON format", "", true, true); loadMetadataFormat(MetadataFormat.OLAC, "Schema for OLAC elements in JSON format", "", true, true); loadMetadataFormat(MetadataFormat.TCOF, "Schema for TCOF elements in JSON format", "", true, true); LOGGER.log(Level.INFO, "reimport process types"); runtime.importProcessTypes(); } catch (Exception e) { LOGGER.log(Level.SEVERE, "error during bootstrap", e); throw new BootstrapServiceException("error during bootstrap", e); } }