[xwiki-users] The default displayer for users is failing with guest

2014-12-13 Thread Dmitry Bakbardin

Hi! 
The default displayer for users is failing with guest 
(http://jira.xwiki.org/browse/XWIKI-11472)
Fix shown in this issue works fine for colibri skin, but fails for flamingo. 
Does anyone have a solution?


Kind regards,

Dmitry
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] The default displayer for users is failing with guest

2014-12-13 Thread Dmitry Bakbardin

The solution is to fix also templates in flamingo skin  
webapp/skins/flamingo/macros.vm . Now they are separate and flamingo overrides  
webapp/templates/macros.vm
Thanks Victor for help.


Sat, 13 Dec 2014 11:40:41 +0300 от Dmitry Bakbardin haru_mamb...@mail.ru:
Hi! 
The default displayer for users is failing with guest 
(http://jira.xwiki.org/browse/XWIKI-11472)
Fix shown in this issue works fine for colibri skin, but fails for flamingo. 
Does anyone have a solution?


Kind regards,

Dmitry

Kind regards,

Dmitry
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] The default displayer for users is failing with guest

2014-12-13 Thread vinc...@massol.net
Check the commit tab for the issue to see what was done:
http://jira.xwiki.org/browse/XWIKI-11472?page=com.atlassian.jira.plugins.jira-bitbucket-connector-plugin:dvcs-commits-tabpanel

You’ll see the fix was applied to Flamingo vm too so it should work fine.

Thanks
-Vincent

On 13 Dec 2014 at 09:40:56, Dmitry Bakbardin (haru_mamb...@mail.ru) wrote:


Hi!  
The default displayer for users is failing with guest 
(http://jira.xwiki.org/browse/XWIKI-11472)  
Fix shown in this issue works fine for colibri skin, but fails for flamingo. 
Does anyone have a solution?  


Kind regards,  

Dmitry  
___  
users mailing list  
users@xwiki.org  
http://lists.xwiki.org/mailman/listinfo/users  
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] The default displayer for users is failing with guest

2014-12-13 Thread Dmitry Bakbardin

Thank you, Vincent!
Found, fixed. Now I have another problem. 
I modified macros.vm file and attached it to the skin page. Nothing happens. I 
expected it to override this file in the skin folder. As far as I remember it 
worked earlier, now - doesn't. Is it a bug or a feature?


Sat, 13 Dec 2014 11:47:35 +0100 от vinc...@massol.net vinc...@massol.net:
Check the commit tab for the issue to see what was done:
http://jira.xwiki.org/browse/XWIKI-11472?page=com.atlassian.jira.plugins.jira-bitbucket-connector-plugin:dvcs-commits-tabpanel

You’ll see the fix was applied to Flamingo vm too so it should work fine.

Thanks
-Vincent

On 13 Dec 2014 at 09:40:56, Dmitry Bakbardin ( haru_mamb...@mail.ru ) wrote:

Hi! 
The default displayer for users is failing with guest 
(http://jira.xwiki.org/browse/XWIKI-11472)
Fix shown in this issue works fine for colibri skin, but fails for flamingo. 
Does anyone have a solution?


Kind regards,

Dmitry
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Kind regards,

Dmitry
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Changing Metdata of Attachment

2014-12-13 Thread Matthias Wegner
Hi,

i want to create a custom excel-file. For that i want to use a uploaded
template and the give it some values. I write that to the attachment storage
and want to hcange the metainfo. The file creation with the template works
fine, but the metatdata-change is not shown in xwiki. How can i do that? My
code is so far

{{groovy}}
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Calendar;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

ArrayListString header = new ArrayListString();
ArrayListHashtablelt;String, String table = new
ArrayListHashtablelt;String, String();
String sheetName = Data;
String fileName = empty.xls;
String templateName = template.xls;
String templateSpace = Main;
String pageName = ExcelTest;
String xwikiPath = /opt/xwiki/openskies_v6.3;
String templatePath =
xwikiPath+/data/storage/xwiki/+templateSpace+/+pageName+/~this/attachments/+templateName+/+templateName;
String filenamePath =
xwikiPath+/data/storage/xwiki/+templateSpace+/+pageName+/~this/attachments/+fileName+/+fileName;

header.add(X)
header.add(Y)
header.add(Z)

HashtableString, String tableRow = new HashtableString, String();
tableRow.put(X, Q);
tableRow.put(Y, W);
tableRow.put(Z, R);
table.add(tableRow);

tableRow = new HashtableString, String();
tableRow.put(X, E);
tableRow.put(Y, F);
tableRow.put(Z, G);
table.add(tableRow);

public String convert(Long value) {
   return value.toString();
}

try {
   HSSFWorkbook wb = null;
   HSSFSheet sheet = null;
   
   File templateFile = new File(templatePath);
   boolean templateExists = templateFile.exists();
   if (templateExists) {
  POIFSFileSystem fs = new POIFSFileSystem(new
FileInputStream(templateFile));
  wb = new HSSFWorkbook(fs);
  sheet = wb.getSheetAt(0);
   } else {
  wb = new HSSFWorkbook();
  sheet = wb.createSheet(sheetName);
   }

   HSSFRow headerRow = null;
   if (templateExists) {
  headerRow = sheet.getRow(0);
   } else {
  headerRow = sheet.createRow(0);
   }
   for (short i = 0; i  header.size(); i++) {
  HSSFCell cell = null;
  if (templateExists) {
 cell = headerRow.getCell(i);
  } else {
 cell = headerRow.createCell(i);
  }
  cell.setCellValue(header.get(i));
   }

   for (int ii = 0; ii  table.size(); ii++) {
  HSSFRow row = null;
  if (templateExists) {
 row = sheet.getRow(ii+1);
  } else {
 row = sheet.createRow(ii+1);
  }
  for (short i = 0; i  header.size(); i++) {
 HSSFCell cell = null;
 if (templateExists) {
cell = row.getCell(i);
 } else {
cell = row.createCell(i);
 }
 String s = table.get(ii).get(header.get(i));
 cell.setCellValue(s);
  }
   }

   File excelOut = new File(filenamePath);
   FileOutputStream fileOut = new FileOutputStream(filenamePath);
   wb.write(fileOut);
   fileOut.close();

  File meta = new
File(xwikiPath+/data/storage/xwiki/+templateSpace+/+pageName+/~this/attachments/
+ fileName + /~METADATA.xml);
  Document metadata = new SAXBuilder().build(meta);

  Element root = metadata.getRootElement();
  for (Element child : root.getChildren()) {
 if (child.getChildText(filename).equals(fileName)) {
if (child.getChildText(version).equals(1.1)) {
  
child.getChild(filesize).setText(convert(excelOut.length()));
  
child.getChild(date).setText(convert(Calendar.getInstance().getTime().getTime()));
}
 }
  }
  XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
  outputter.output(metadata, new FileOutputStream(meta));

} catch (FileNotFoundException e) {
   e.printStackTrace();
} catch (IOException e) {
   e.printStackTrace();
} catch (JDOMException e) {
   e.printStackTrace();
}

{{/groovy}}

[[Downloadattach:empty.xls]]



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Changing-Metdata-of-Attachment-tp7593478.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users