BrightSide Workbench Full Report + Source Code
PortalWindows.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.zul.portal;
19 
20 import java.io.File;
21 import java.io.FileFilter;
22 import java.util.HashMap;
23 import org.amic.util.file.FileUtil;
24 import org.turro.auth.Authentication;
25 import org.turro.elephant.context.ElephantContext;
26 import org.turro.plugin.contacts.IContact;
27 
32 public class PortalWindows extends HashMap<String, PortalContainer> {
33 
34  private final IContact contact = Authentication.getIContact();
35 
36  public void loadContainers() {
37  File root = new File(ElephantContext.getRealPath("/WEB-INF/portal"));
38  if(root.exists()) {
39  for(File f : root.listFiles(new FileFilter() {
40  @Override
41  public boolean accept(File pathname) {
42  return pathname.isFile() && !pathname.isHidden() &&
43  pathname.getName().endsWith(".portal");
44  }
45  })) {
47  pc.setFiles(getUserContainer(f), f);
48  put(FileUtil.getBaseName(f), pc);
49  }
50  }
51  }
52 
53  private File getUserContainer(File f) {
54  File userFile = new File(
55  FileUtil.getParentPath(f.getAbsolutePath()) +
56  "/" + contact.getId() + "/" +
57  f.getName()
58  );
59  return userFile;
60  }
61 
62 }
void setFiles(File userFile, File confFile)